update README.md

pull/34/head
5 years ago
parent d8a2e0783f
commit 54c2d9a6d7
  1. 52
      README.md
  2. 4
      app/build.gradle
  3. 6
      app/src/main/java/com/example/open_nsfw_android/DemoApplication.kt
  4. BIN
      img/2.png

@ -47,45 +47,30 @@ __请添加__
``` ```
- 使用 - 使用(请使用最新版本1.3.0)
- 建议在Application中全局初始化
``` ```
val nsfwHelper = NSFWHelper.init(NSFWConfig(assets)) Classifier.Build()
val nsfwBean = nsfwHelper?.scanBitmap(bitmap)!! .context(this) //必须调用 否则会有异常抛出
nsfwBean.sfw // .isOpenGPU(true)//默认不开启GPU加速 部分机型开启会奔溃,自行选择,默认false
nsfwBean.nsfw // .numThreads(10) //分配的线程数 根据手机配置设置,默认1
if(nsfwBean.nsfw>0.3){ .build()
Log.e("NSFW","图片涉黄")
}
``` ```
- kotlin可直接使用File.getNsfwScore(mAssetManager: AssetManager): NsfwBean 或 Bitmap.getNsfwScore(mAssetManager: AssetManager): NsfwBean 直接获取鉴定结果(NSFWHelper 1.2.9版本开始支持),比如 - 使用:
``` ```
val bitmap = BitmapFactory.decodeFile(path) //方式一:
val nsfwBean = Classifier.Build().context(this).build().run(bitmap)
val nsfwScore = bitmap.getNsfwScore(assets) //方式二
val nsfwBean = bitmap.getNsfwScore()
if(nsfwBean.nsfw>0.3){ //方式三
val nsfwBean = file.getNsfwScore()
Log.e("NSFW","图片涉黄")
}
```
```
val file = File(lm.path)
val nsfwScore = file.getNsfwScore(assets)
if(nsfwBean.nsfw>0.3){
Log.e("NSFW","图片涉黄")
}
```
### 安卓手机直接[点我安装](https://fir.im/1rj9) nsfwBean.sfw ... 非涉黄数值 数值越大约安全
nsfwBean.nsfw ... 涉黄数值 数值越大约危险
```
### 安卓手机直接[点我安装](http://d.7short.com/1rj9)
### 扫码下载 ### 扫码下载
@ -93,5 +78,4 @@ __请添加__
### Demo运行结果: ### Demo运行结果:
![图片](https://github.com/devzwy/open_nsfw_android/blob/master/img/1.png) ![图片](https://github.com/devzwy/open_nsfw_android/blob/master/img/1.png)

@ -54,6 +54,6 @@ dependencies {
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50' implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.50'
implementation 'com.github.LuckSiege.PictureSelector:picture_library:2.2.5' implementation 'com.github.LuckSiege.PictureSelector:picture_library:2.2.5'
// implementation project(path: ':nsfw') // implementation project(path: ':nsfw')
implementation project(path: ':OpenNSFW') // implementation project(path: ':OpenNSFW')
// implementation 'com.github.devzwy:open_nsfw_android:1.2.7' implementation 'com.github.devzwy:open_nsfw_android:1.3.0'
} }

@ -6,6 +6,10 @@ import com.zwy.opennsfw.core.Classifier
class DemoApplication : Application() { class DemoApplication : Application() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
Classifier.Build().context(this).build() Classifier.Build()
.context(this) //必须调用 否则会有异常抛出
// .isOpenGPU(true)//默认不开启GPU加速 部分机型开启会奔溃,自行选择,默认false
// .numThreads(10) //分配的线程数 根据手机配置设置,默认1
.build()
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

After

Width:  |  Height:  |  Size: 93 KiB

Loading…
Cancel
Save