nsfw‐detection - veka-server/onnx-php GitHub Wiki

nsfw-detection

model sources onnx : https://github.com/iola1999/nsfw-detect-onnx

model sources original : https://github.com/GantMan/nsfw_model

require_once(__DIR__.'/../vendor/autoload.php');

Onnx\Library::setFolder(__DIR__.'/../');
Onnx\Library::install();

$ia = new Onnx\Task\Vision(config:[
    'tags' => [ 0 => "drawings", 1 => "hentai", 2=> "neutral", 3=> "porn", 4 => "sexy"]
    ,'rescale_factor' => 0.00392156862745098
    ,'format' => 'rgb'
    ,'height' => 299
    ,'width' => 299
    ,'shape' => 'bhwc'  /* batch channel height width */
    ,'modelNameOrPath' => __DIR__.'/../models/nsfw-model-299-onnx-opset15.onnx'
]);

$ia->loadModel();
$tags = $ia->getTags( __DIR__ . '\images\sexy.jpg');
var_dump($tags);