This repository is dedicated for building a classifier to detect NSFW Images & Videos.
To use this project, first clone the repo on your device using the command given below:
git init
git clone https://github.com/LaxmanSinghTomar/nsfw-classifier.git
Install the required libraries & packages using:
pip install requirements.txt
To download the dataset upon which the model was trained run:
python src/scripts/data.sh
If run successfully, this should create a directory data
in the project directory.
To run a quick demo using an image and a video run:
python src/scripts/inference.sh
To identify whether an image contains NSFW content or not using the default model run:
python src/inference/inference_image.py [img-path]
To identify whether a video is NSFW or not using the default model run:
python src/inference/inference_video.py [video-path]
Output Video is saved in the output
directory.
Note: The default trained model is MobileNetv2 which is smaller in size due to which loads quickly and is good for inference.
. ├── LICENSE ├── models <- Trained and Serialized Models ├── notebooks <- Jupyter Notebook ├── NSFW Classifier.png ├── output <- Output for Videos ├── README.md ├── references <- Reference Materials to understand Approaches & Solutions ├── reports <- Reports & Figures Generated │ ├── figures ├── requirements.txt <- Requirements File for reproducing the analysis environment └── src ├── config.py <- Script for Configuration like File Paths, default Model ├── inference <- Scripts for running an inference on either image/video using trained model │ ├── inference_image.py │ └── inference_video.py ├── models <- Scripts to train the ML Models │ ├── efficientnet.py │ ├── mobilenet.py │ └── nasnetmobile.py ├── scripts <- Scripts to download dataset and run inference on an image/video for Demo │ ├── data.sh │ └── inference.sh └── visualizations <- Scripts to create exploratory and results oriented visualizations └── visualizations.py
If you wish to change the default model for predictions i.e. MobileNetv2, change MODEL_PATH
in src/config.py
to the either of the models available in models
directory.