From 7d3a1fe451993a4ca26cebe8afedd087c48b6c9a Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 9 Jun 2020 11:56:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=A8=A1=E5=9E=8B=E6=94=AF?= =?UTF-8?q?=E6=8C=81GPU=E5=8A=A0=E9=80=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 27 ++++++++++++++----- demo/build.gradle | 8 +++--- .../main/java/com/zwy/demo/NSFWApplication.kt | 4 +-- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 898b9d68..2633a492 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![](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) [![](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/Mail-dev_zwy@aliyun.com-green.svg)](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) -### 色情图片离线识别,基于TensorFlow实现。识别只需200ms,可断网测试,成功率99%,调用只要一行代码,从雅虎的开源项目open_nsfw移植,tflite(6M)为训练好的模型(已量化),该模型文件可用于iOS、java、C++等平台,Python使用生成的tfLite文件检测图片的速度远远快于使用原模型. +### 色情图片离线识别,基于TensorFlow实现。识别只需20ms,可断网测试,成功率99%,调用只要一行代码,从雅虎的开源项目open_nsfw移植,该模型文件可用于iOS、java、C++等平台 ### iOS请参考:[issues13](https://github.com/devzwy/open_nsfw_android/issues/13) ### 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) ### Java参考:[Tensorflow-Api](https://tensorflow.google.cn/api_docs/java/reference/org/tensorflow/package-summary) @@ -20,8 +20,8 @@ #### 1.3.1版本优化说明: 模型大小改动较大,原量化模型虽小(6M),但对GPU加速支持不友好,新模型大约26M,完美支持GPU加速并优化识别精度,加速效果明显。建议全部升级该版本。__新版本的GPU加速默认开启状态__,SDK默认会检测设备是否支持,不支持时会自动取消加速(老版本会奔溃) -### 使用 -- Add it in your root build.gradle at the end of repositories: +### 使用方式一 (建议) +- 添加远程仓库支持 ``` allprojects { repositories { @@ -31,7 +31,7 @@ } ``` -- Add the dependency [![](https://jitpack.io/v/devzwy/open_nsfw_android.svg)](https://jitpack.io/#devzwy/open_nsfw_android) +- 配置依赖 [![](https://jitpack.io/v/devzwy/open_nsfw_android.svg)](https://jitpack.io/#devzwy/open_nsfw_android) (编译过程报错时请自行使用梯子) ``` dependencies { @@ -39,6 +39,21 @@ implementation 'com.github.devzwy:open_nsfw_android:[versionCode]' } +``` + +### 使用方式二,源码依赖方式 +- 克隆源码 +``` + git clone 'https://github.com/devzwy/open_nsfw_android.git' +``` + +- 项目中依赖lib + +``` + dependencies { + implementation project(path: ':OpenNSFW') + } + ``` - 扫描时报如下错误 ``` @@ -55,13 +70,13 @@ __请添加__ ``` -- 使用(请使用最新版本1.3.0) +- 使用(请使用最新版本1.3.1) - 建议在Application中全局初始化 ``` Classifier.Build() .context(this) //必须调用 否则会有异常抛出 -// .isOpenGPU(true)//默认不开启GPU加速 部分机型开启会奔溃,自行选择,默认false +// .isOpenGPU(true)//默认不开启GPU加速 ,默认true // .numThreads(10) //分配的线程数 根据手机配置设置,默认1 .build() ``` diff --git a/demo/build.gradle b/demo/build.gradle index 02d92dfb..0a736ef7 100644 --- a/demo/build.gradle +++ b/demo/build.gradle @@ -24,8 +24,8 @@ android { } } - dataBinding { - enabled = true + buildFeatures{ + dataBinding = true } @@ -83,8 +83,8 @@ dependencies { implementation "org.jetbrains.anko:anko:0.10.5" //NSFW鉴黄库 -// implementation 'com.github.devzwy:open_nsfw_android:1.3.0' - implementation project(path: ':OpenNSFW') + implementation 'com.github.devzwy:open_nsfw_android:1.3.1' +// implementation project(path: ':OpenNSFW') implementation 'pub.devrel:easypermissions:3.0.0' implementation 'com.github.LuckSiege.PictureSelector:picture_library:2.2.5' diff --git a/demo/src/main/java/com/zwy/demo/NSFWApplication.kt b/demo/src/main/java/com/zwy/demo/NSFWApplication.kt index 71408023..ba1b7f6b 100644 --- a/demo/src/main/java/com/zwy/demo/NSFWApplication.kt +++ b/demo/src/main/java/com/zwy/demo/NSFWApplication.kt @@ -28,8 +28,8 @@ class NSFWApplication : MultiDexApplication() { //初始化鉴黄库NSFW Classifier.Build() .context(this) //必须调用 否则会有异常抛出 - .isOpenGPU(true)//默认不开启GPU加速,默认为true - .numThreads(100) //分配的线程数 根据手机配置设置,默认1 +// .isOpenGPU(true)//默认不开启GPU加速,默认为true +// .numThreads(100) //分配的线程数 根据手机配置设置,默认1 .build() //全局注入对象 startKoin {