Skip to content
This repository was archived by the owner on Apr 8, 2023. It is now read-only.

Commit 7d3a1fe

Browse files
committed
优化模型支持GPU加速
1 parent e06af97 commit 7d3a1fe

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

README.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![](https://jitpack.io/v/devzwy/open_nsfw_android.svg)](https://jitpack.io/#devzwy/open_nsfw_android) [![](https://img.shields.io/badge/Base-TensorFlow-brightgreen.svg)](https://github.com/devzwy/open_nsfw_android) [![](https://img.shields.io/badge/license-Apache%202-green.svg)](https://www.apache.org/licenses/LICENSE-2.0)
33
[![](https://img.shields.io/badge/%E4%BD%9C%E8%80%85-赵文贇-orange.svg)](https://github.com/devzwy/open_nsfw_android) [![](https://img.shields.io/badge/QQ-3648415-brightgreen.svg)](https://github.com/devzwy/KUtils) [![](https://img.shields.io/badge/[email protected])](https://github.com/devzwy/open_nsfw_android) ![Mozilla Add-on](https://img.shields.io/amo/stars/dustman.svg?label=stars&logo=1&logoColor=1&style=popout)
44

5-
### 色情图片离线识别,基于TensorFlow实现。识别只需200ms,可断网测试,成功率99%,调用只要一行代码,从雅虎的开源项目open_nsfw移植,tflite(6M)为训练好的模型(已量化),该模型文件可用于iOS、java、C++等平台,Python使用生成的tfLite文件检测图片的速度远远快于使用原模型.
5+
### 色情图片离线识别,基于TensorFlow实现。识别只需20ms,可断网测试,成功率99%,调用只要一行代码,从雅虎的开源项目open_nsfw移植,该模型文件可用于iOS、java、C++等平台
66
### iOS请参考:[issues13](https://github.com/devzwy/open_nsfw_android/issues/13)
77
### Python参考:[NSFW-Python](https://github.com/devzwy/NSFW-Python)[Python-TensorflowLite-Api](https://tensorflow.google.cn/api_docs/python/tf/lite)[Python-Tensorflow-Api](https://tensorflow.google.cn/api_docs/python/tf)
88
### Java参考:[Tensorflow-Api](https://tensorflow.google.cn/api_docs/java/reference/org/tensorflow/package-summary)
@@ -20,8 +20,8 @@
2020
#### 1.3.1版本优化说明:
2121
模型大小改动较大,原量化模型虽小(6M),但对GPU加速支持不友好,新模型大约26M,完美支持GPU加速并优化识别精度,加速效果明显。建议全部升级该版本。__新版本的GPU加速默认开启状态__,SDK默认会检测设备是否支持,不支持时会自动取消加速(老版本会奔溃)
2222

23-
### 使用
24-
- Add it in your root build.gradle at the end of repositories:
23+
### 使用方式一 (建议)
24+
- 添加远程仓库支持
2525
```
2626
allprojects {
2727
repositories {
@@ -31,14 +31,29 @@
3131
}
3232
```
3333

34-
- Add the dependency [![](https://jitpack.io/v/devzwy/open_nsfw_android.svg)](https://jitpack.io/#devzwy/open_nsfw_android)
34+
- 配置依赖 [![](https://jitpack.io/v/devzwy/open_nsfw_android.svg)](https://jitpack.io/#devzwy/open_nsfw_android) (编译过程报错时请自行使用梯子)
3535

3636
```
3737
dependencies {
3838
//versionCode:上面小icon中最新版本号
3939
implementation 'com.github.devzwy:open_nsfw_android:[versionCode]'
4040
}
4141
42+
```
43+
44+
### 使用方式二,源码依赖方式
45+
- 克隆源码
46+
```
47+
git clone 'https://github.com/devzwy/open_nsfw_android.git'
48+
```
49+
50+
- 项目中依赖lib
51+
52+
```
53+
dependencies {
54+
implementation project(path: ':OpenNSFW')
55+
}
56+
4257
```
4358
- 扫描时报如下错误
4459
```
@@ -55,13 +70,13 @@ __请添加__
5570
```
5671

5772

58-
- 使用(请使用最新版本1.3.0)
73+
- 使用(请使用最新版本1.3.1)
5974
- 建议在Application中全局初始化
6075

6176
```
6277
Classifier.Build()
6378
.context(this) //必须调用 否则会有异常抛出
64-
// .isOpenGPU(true)//默认不开启GPU加速 部分机型开启会奔溃,自行选择,默认false
79+
// .isOpenGPU(true)//默认不开启GPU加速 ,默认true
6580
// .numThreads(10) //分配的线程数 根据手机配置设置,默认1
6681
.build()
6782
```

demo/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ android {
2424
}
2525
}
2626

27-
dataBinding {
28-
enabled = true
27+
buildFeatures{
28+
dataBinding = true
2929
}
3030

3131

@@ -83,8 +83,8 @@ dependencies {
8383
implementation "org.jetbrains.anko:anko:0.10.5"
8484

8585
//NSFW鉴黄库
86-
// implementation 'com.github.devzwy:open_nsfw_android:1.3.0'
87-
implementation project(path: ':OpenNSFW')
86+
implementation 'com.github.devzwy:open_nsfw_android:1.3.1'
87+
// implementation project(path: ':OpenNSFW')
8888
implementation 'pub.devrel:easypermissions:3.0.0'
8989

9090
implementation 'com.github.LuckSiege.PictureSelector:picture_library:2.2.5'

demo/src/main/java/com/zwy/demo/NSFWApplication.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class NSFWApplication : MultiDexApplication() {
2828
//初始化鉴黄库NSFW
2929
Classifier.Build()
3030
.context(this) //必须调用 否则会有异常抛出
31-
.isOpenGPU(true)//默认不开启GPU加速,默认为true
32-
.numThreads(100) //分配的线程数 根据手机配置设置,默认1
31+
// .isOpenGPU(true)//默认不开启GPU加速,默认为true
32+
// .numThreads(100) //分配的线程数 根据手机配置设置,默认1
3333
.build()
3434
//全局注入对象
3535
startKoin {

0 commit comments

Comments
 (0)