图片鉴黄 图片识别 nsfw ios framework

2020-07-27  本文已影响0人  iloverain

描述

图片鉴黄, 一般使用阿里或者腾讯的oss服务的时候, 可以选择图片识别中的鉴黄功能, 但是只能检测服务器上的数据, 并且阿里的服务只能用于国内节点, 腾讯的没了解

图片识别本就是比较常见的机器学习功能, 网上也有不上开源的训练模型

NsfwImgDetector 集成了雅虎开源的训练模型, 准确率高于99.9%以上, 对比github上一个只有17k的model, 精确度有了保证, 但是文件也比价大(23M), 会使app的安装包增加 50M以上

NsfwImgDetector 是swift开发的iOS framework

使用方法

@available(iOS 11.0, *)
func filter(image:UIImage) {

 let detector = NsfwImgDetector()
​
 detector.check(image: image) { (isNoSafe, confidence) in
     print("isNoSafe:\(isNoSafe) confidence:\(confidence)")
     f isNoSafe == false {
     //safe
     }else if (confidence > 0.9) {
     // porn
     }else if (confidence > 0.5) {
     // sexy picture, may little porn
    }else {
    // sexy picture
    }
 }
}

安装

NsfwImgDetector is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'NsfwImgDetector'

github链接
https://github.com/Zhulmin/NsfwImgDetector

上一篇下一篇

猜你喜欢

热点阅读