You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jason 4c984916e4 Merge remote-tracking branch 'origin/dev' into dev 5 years ago
.github Update FUNDING.yml 5 years ago
.idea 优化模型支持GPU加速 5 years ago
OpenNSFW 优化模型支持GPU加速 5 years ago
app 更新Demo(未完待续..) 5 years ago
demo 优化模型支持GPU加速 5 years ago
gradle/wrapper 更新Demo(未完待续..) 5 years ago
img 更新Demo(未完待续..) 旋转图片 5 years ago
.gitattributes Update .gitattributes 6 years ago
.gitignore Match GitHub usage protocol 6 years ago
LICENSE Create LICENSE 5 years ago
README.md 更新Demo(未完待续..) 旋转图片 5 years ago
build.gradle 更新Demo(未完待续..) 5 years ago
gradle.properties 优化模型支持GPU加速 5 years ago
gradlew 重构库,升级到1.3.0 5 years ago
gradlew.bat first commit. 6 years ago
settings.gradle 优化模型支持GPU加速 5 years ago

README.md

open_nsfw_android

Mozilla Add-on

色情图片离线识别,基于TensorFlow实现。识别只需200ms,可断网测试,成功率99%,调用只要一行代码,从雅虎的开源项目open_nsfw移植,tflite(6M)为训练好的模型(已量化),该模型文件可用于iOS、java、C++等平台,Python使用生成的tfLite文件检测图片的速度远远快于使用原模型.

iOS请参考:issues13

Python参考:NSFW-PythonPython-TensorflowLite-ApiPython-Tensorflow-Api

Java参考:Tensorflow-Api

C++参考:TensorflowLite-Api

JavaScript参考JS相关文档

其中Python、C++均有两种数据喂入的方式,可根据需求选择pb模型或tfLite文件,详细请参考上面的链接.Java的目前只能加载pb模型。其他的平台可自行百度

pb模型下载

本项目移除测试图片,请下载Demo后自行配图测试

即将优化Demo使用MVVM模式,可用作开发脚手架使用

Kotlin+okhttp3+rxjava2+retrofit2+koin+glide+greendao+databinding+Livedata

MVVM

使用

  • Add it in your root build.gradle at the end of repositories:
	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
  • Add the dependency
	dependencies {
	         //versionCode:上面小icon中最新版本号
	        implementation 'com.github.devzwy:open_nsfw_android:[versionCode]'
	}

  • 扫描时报如下错误
java.lang.NullPointerException: Attempt to invoke virtual method 'com.zwy.nsfw.api.NsfwBean com.zwy.nsfw.Classifier.run(android.graphics.Bitmap)' on a null object reference

请添加

  android {
        ...
        aaptOptions {
            noCompress "tflite"
        }
  }
  • 使用(请使用最新版本1.3.0)
  • 建议在Application中全局初始化
        Classifier.Build()
            .context(this) //必须调用 否则会有异常抛出
//            .isOpenGPU(true)//默认不开启GPU加速 部分机型开启会奔溃,自行选择,默认false
//            .numThreads(10) //分配的线程数 根据手机配置设置,默认1
            .build()
  • 使用:
         //方式一:
        val nsfwBean = Classifier.Build().context(this).build().run(bitmap)
        //方式二
        val nsfwBean = bitmap.getNsfwScore()
        //方式三
        val nsfwBean = file.getNsfwScore()

        nsfwBean.sfw   ... 非涉黄数值 数值越大约安全
        nsfwBean.nsfw   ... 涉黄数值  数值越大约危险

安卓手机直接点我安装

扫码下载

图片

Demo运行结果:

图片