1 Star 0 Fork 1

合金来了 / open_nsfw_android

forked from sanzao / open_nsfw_android 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

open_nsfw_android

Mozilla Add-on

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

页面最底部有测试Demo和效果图片,请勿在公共场所打开。

使用

  • 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"
        }
  }
  • 使用
  val nsfwHelper = NSFWHelper.init(NSFWConfig(assets))
  val nsfwBean = nsfwHelper?.scanBitmap(bitmap)!!
  nsfwBean.sfw
  nsfwBean.nsfw
  if(nsfwBean.nsfw>0.3){
    Log.e("NSFW","图片涉黄")
  }
  • kotlin可直接使用File.getNsfwScore(mAssetManager: AssetManager): NsfwBean 或 Bitmap.getNsfwScore(mAssetManager: AssetManager): NsfwBean 直接获取鉴定结果(NSFWHelper 1.2.9版本开始支持),比如:
  val bitmap = BitmapFactory.decodeFile(path)
  
  val nsfwScore = bitmap.getNsfwScore(assets)
  
  if(nsfwBean.nsfw>0.3){
  
      Log.e("NSFW","图片涉黄")
      
  }

      val file = File(lm.path)
      
      val nsfwScore = file.getNsfwScore(assets)
      
      if(nsfwBean.nsfw>0.3){
      
          Log.e("NSFW","图片涉黄")
          
      }
      

点我下载apk

扫码下载

图片

Demo运行结果:

提示:下面的图片不要在公共场所打开!!!

提示:下面的图片不要在公共场所打开!!!

提示:下面的图片不要在公共场所打开!!!

提示:下面的图片不要在公共场所打开!!!

提示:下面的图片不要在公共场所打开!!!

提示:下面的图片不要在公共场所打开!!!

提示:下面的图片不要在公共场所打开!!!

提示:下面的图片不要在公共场所打开!!!

提示:下面的图片不要在公共场所打开!!!

图片

空文件

简介

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

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/lvhejin/open_nsfw_android.git
git@gitee.com:lvhejin/open_nsfw_android.git
lvhejin
open_nsfw_android
open_nsfw_android
master

搜索帮助