GithubHelp home page GithubHelp logo

sumitm0432 / explicit-content-classifier-using-resnet Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 2.0 84.07 MB

The objective of this project is to classify explicit content that contains inappropriate images like pornography and Hentai. The classifier used for this is ResNet50 and ResNet101 also known as Residual Neural Network. There are five categories that the model is trained on which are Porn, Hentai, Sexy, Drawing, and Neutral. Porn, Hentai, and Sexy can be classified as NSFW (Not Safe For Work) further and the other two are SFW (Safe For Work).

License: Apache License 2.0

Python 20.68% Jupyter Notebook 79.32%
data-science resnet-50 resnet-101 pytorch deep-learning python

explicit-content-classifier-using-resnet's Introduction

Explicit-Content-Classifier-using-ResNet

Objective

Nowadays, The amount of explicit content available on the internet is ginormous and this type of content can be strayed and uploaded to websites that do not endorse these or some sites that are not 18+, hence classifying this type of content is really of paramount significance.

The objective of this project is to classify explicit content that contains inappropriate images like pornography and Hentai. The classifier used for this is ResNet50 and ResNet101 also known as Residual Neural Network. There are five categories that the model is trained on which are Porn, Hentai, Sexy, Drawing, and Neutral. Porn, Hentai, and Sexy can be classified as NSFW (Not Safe For Work) further and the other two are SFW (Safe For Work).

Dataset

The dataset is taken from various sources like Kaggle, Internet Archive, and Github. The dataset sources contained explicit images of different genre, hence they are picked according to the used classes. The final dataset contained around 170,000 images from which 10,000 images are used for testing (2000 per class). As for Validation, from 160,000 images about 10% are used for validation.

The data augmentation is also done on Drawings and Hentai classes as the number of images was on the lower side. For data augmentation, 4 attributes were changed randomly that are brightness, horizontal flip, grayscale, and rotation of 30 degrees.

Files

  • config.py - Configuration File
  • Data_Augmentation.py - Contains code for data augmentation as explained above.
  • Split.py - Used to split the dataset into train and test.
  • dataset_prep.py - Preprocessing is done in the file.
  • engine.py - Contains the training function for the model [training and validation]
  • metrics.py - Contains the metrics for evaluation like confusion matrix plot
  • model.py - contains the PyTorch Models -- Resnet50 and Resnet101
  • predict.py - Use the model to predict on Test Dataset.
  • train.py - main run file

Preprocessing

For preprocessing, the images are resized to 224x224 as the model input size was the same and the images were normalized as well (given in the data_prep.py) and finally converted to a Tensor.

Model

Two models were trained named ResNet50 and ResNet101 from the Torchvision Model library. Accuracy, classification report, and confusion metrics are used to judge the performances of the model. Each model is trained for 2 and 5 epochs with 0.001 and 0.0001 Learning rates. The loss curve and confusion matrix plotted are given in the Images folder.

The framework used for models is PyTorch.

How to Run

Run the gui.py file in the GUI folder
The GUI, I made is pretty Simple, it has three options:

  • Choose Folder: Choose the folder that contains the images.
  • Predict: Do the predictions using the saved model in the Output Folder. [new models can also be trained]
  • Exit: Self Explanatory

explicit-content-classifier-using-resnet's People

Contributors

sumitm0432 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.