wd14 - veka-server/onnx-php GitHub Wiki
wd14
model sources : https://huggingface.co/SmilingWolf/wd-convnext-tagger-v3
require_once(__DIR__.'/../vendor/autoload.php');
Onnx\Library::setFolder(__DIR__.'/../');
Onnx\Library::install();
$ia = new class extends \Onnx\Task\Vision {
protected array $tags = [];
protected $rescale_factor = 1 ;
protected $format = 'rgb';
protected $height = 448;
protected $width = 448;
protected $shape = 'bhwc'; /* batch channel height width */
protected mixed $modelNameOrPath = '..\WD14-v3\wd14-convnext-tagger-v3.onnx' ;
public function __construct(array $config = [], $lib = null) {
parent::__construct($config);
/** load tags from csv */
$list_csv = new CSV('..\WD14-v3\selected_tags_convnext_v3.csv', true);
$this->tags = [];
foreach ($list_csv as $key => $line) {
$this->tags[$key-2] = $line['name'];
}
}
};
$ia->loadModel();
$tags = $ia->getTags( __DIR__ . '\images\sexy.jpg');
var_dump($tags);