Giter VIP home page Giter VIP logo

nsfw-detection-pytorch's Introduction

NSFW-Detection-Pytorch

Description

In this repository you can find an effective CNN model for detecting NSFW content in images. It achieves a 97.70% accuracy on the pornography-2k dataset. Apart from the provided code you need to reproduce the model, you can also use this model as python module (see below).

Usage

First install the python module:

pip install --upgrade nsfwdetection

Then use the model by:

#import the model
from nsfw_detector.model import Model

# initialize the model
net = Model()

# make a prediction
output = net.predict(<imagepath>)

# make multiple predictions
output = net.predict([<imagepath>, <imagepath>])

The model's output is as follows: {'image_path': {'Label': SFW or NSFW , 'Score': 0 to 1 }}

Reproducability

Using the provided code you can retrain the model. Regarding the training/testing data, the corresponding splits are provided in folder "splits". You can find and download the necessary data from here (this is a private dataset, due to its content and you should send a request to gain access - find more info in the link) and here. After downloading the 2 datasets, you should run the

python script1_extract_image_frames.py

to extract the frames from the videos of the pornography-2k dataset and then you can run the

bash train_exps.sh 

to start training the model.

Results Visualisation

As you can see in the following attention maps, the model exhibits high accuracy in terms of the image regions it focuses. (Censored images)

nsfw-detection-pytorch's People

Contributors

gsarridis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

thinkwelltwd

nsfw-detection-pytorch's Issues

can not import this model

Thank you for your contribution. But I can't use it normally, I executed it correctly
pip install --upgrade nsfwdetection
And prompt me to install correctly. But I still can't import this library, I can't figure out where the problem is. I can use other commonly used libraries normally.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.