PHP code example of alisoleimani / nsfw-detector
1. Go to this page and download the library: Download alisoleimani/nsfw-detector library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
alisoleimani / nsfw-detector example snippets
$filePath = "path-to-file/file.png";
$data = NSFW::predict($filePath);
// data will be like
// {'drawings': 0.0024894224479794502, 'hentai': 0.0009175422019325197, 'neutral': 0.9905469417572021, 'porn': 0.00509273586794734, 'sexy': 0.0009534107521176338}
// The higher these values, the more likely the photo is to be unsafe
$filePath = "path-to-file/file.png";
$situation = NSFW::detect($filePath);
// if $sitation is true it means image is not safe and if its false image will be secure