symisc / pixlab-php-nsfw
PHP 类,用于通过 PixLab 机器视觉 API 对 NSFW 内容进行分类
dev-master
2018-08-21 22:55 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-29 05:55:19 UTC
README
一个 单PHP类,用于通过 PixLab 机器视觉 API 对 NSFW内容(例如用户图片上传)进行分类 - https://pixlab.io/cmd?id=nsfw
要求
PixLab PHP NSFW 类支持 PHP 5.3, 5.4, 5.5, 5.6, 7.0, 7.1, 7.2 和 HHVM。
安装
通过 Composer 安装 PHP NSFW 类
$ composer require symisc/pixlab-php-nsfw
或者只需将 pixlab.php 放置到您的源树中即可完成操作!
使用示例
<?php require_once "pixlab.php"; # Target Image: Change to any link (Possibly adult) you want or switch to POST # if you want to upload your image directly. $img = 'https://i.redd.it/oetdn9wc13by.jpg'; # Your PixLab key - Get one from https://pixlab.io/dashboard $key = 'My_Pixlab_Key'; # Blur an image based on its NSFW score $pix = new Pixlab($key); /* Invoke NSFW */ if( !$pix->get('nsfw',['img' => $img]) ){ echo $pix->get_error_message(); die; } /* Grab the NSFW score */ $score = $pix->json->score; if( $score < 0.5 ){ echo "No adult content were detected on this picture\n"; }else{ echo "Censuring NSFW picture...\n"; /* Call blur with the highest possible radius and sigma */ if( !$pix->get('blur',array('img' => $img,'rad' => 50,'sig' =>30)) ){ echo $pix->get_error_message(); }else{ echo "Censured Picture: ".$pix->json->link."\n"; } } ?>
PixLab 资源
PixLab 资源 & 示例集。示例集包含各种编程语言的实用示例和可运行的代码,旨在让读者熟悉 PixLab API。如果您想了解入门课程,请参考
欢迎复制/粘贴并运行这些示例来查看 API 的实际效果。