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.
open_nsfw_android/README_EN.md

4.4 KiB

open_nsfw_android

Download Plugin on redmine.org

中文文档

The off-line identification of pornographic images is based on tensorflow. Identification only takes 20ms, can be disconnected test, the success rate is 99%, call as long as a line of code, open from the open source project of Yahoo_ Nsfw transplantation, the model file can be used in IOS, Java, C + + and other platforms

iOS like this:issues13

Python like this:NSFW-PythonPython-TensorflowLite-ApiPython-Tensorflow-Api

Java like this:Tensorflow-Api

C++ like this:TensorflowLite-Api

JavaScript like thisjs doc

Python and C + + have two ways to feed data. You can select PB model or tflite file according to your needs. Please refer to the above link for details. Java can only load PB model at present. Other platforms can [Google]( https://www.google.cn )

This project removes the test picture, please download demo and test by yourself

picture

图片

start use(As of version 1.3.9, dependencies are moved from jetpack to Maven repository, which can be directly dependent in the project without adding jetpack support)

  • Open tflite support
  android {
        aaptOptions {
            noCompress "tflite"
        }
  }
  • Dependencies Download
    //Optional Quick initialization of scanner, can avoid initialization code
    implementation 'com.zwy.nsfw:nsfw_initializer:lastVersion'
    //must Scanner core file
    implementation 'com.zwy.nsfw:nsfw:lastVersion'
    //must tensorflow
    implementation 'org.tensorflow:tensorflow-lite:2.1.0'
    implementation 'org.tensorflow:tensorflow-lite-gpu:2.1.0'
    //Method 1: put the model file in the assets root directory and name it nsfw.tflite
    NSFWHelper.init(context = this@Application)

    //Method 2 is applicable to the product that strictly controls the size of the APK and cannot directly put the model file in the APK. It can be initialized by specifying the model path after the user opens the APK background and downloads it silently
    NSFWHelper.init(modelPath = "modelPath")

    //Method 3: put the model file in the assets root directory and name it nsfw.tflite To refer to the library can avoid initializing the code
    implementation 'com.zwy.nsfw:nsfw_initializer:lastVersion'

  • GetNSFWScore:
    //val mNSFWScoreBean:NSFWScoreBean =  File.getNSFWScore()
    //val mNSFWScoreBean:NSFWScoreBean =  Bitmap.getNSFWScore()
    //val mNSFWScoreBean:NSFWScoreBean = NSFWHelper.getNSFWScore(bitmap)

    mNSFWScoreBean.sfw   ... The more approximate the non yellow value is, the safer it is
    mNSFWScoreBean.nsfw   ... The more the Yellow value is, the more dangerous it will be
    mNSFWScoreBean.timeConsumingToLoadData  ... Load data in milliseconds
    mNSFWScoreBean.timeConsumingToScanData  ... Scan picture in milliseconds

Android mobile phone directClick me to install

Scan code to download

pic