NudeNet: An ensemble of Neural Nets for Nudity Detection and Censoring

Part 1: Nudity detection with image classification

The Why: I sincerely believe in not re-inventing the wheel. At the time of starting this project, Yahoo’s open_nsfw is the only decently working nudity detection module available. It is quiet outdated and the data isn’t available to public. There is no (AFAIK) open-source project available for censoring of exposed parts.

# Resizing and removing duplicates
mogrify -geometry x320 *
fdupes -rdN ./
# Random rotation, flips, zoom, distortion, contrast, skew and brightness
pipeline.rotate(probability=0.2, max_left_rotation=20, max_right_rotation=20)
pipeline.zoom(probability=0.2, min_factor=1.1, max_factor=1.5)
pipeline.random_distortion(probability=0.2, grid_width=4, grid_height=4, magnitude=8)pipeline.random_brightness(probability=0.2, min_factor=0.5, max_factor=3)pipeline.random_color(probability=0.2, min_factor=0.5, max_factor=3)
pipeline.random_contrast(probability=0.2, min_factor=0.5, max_factor=3)
pipeline.skew(probability=0.2, magnitude=0.4)
# For l2
for layer in model.layers: layer.W_regularizer = l2(..)
# Or for dropout add dropout between the fully connected layers and redefine the model using functional API.
Precision and Recall of NudeNet’s classifier
Precision and Recall of GantMan’s nsfw_model
Precision and Recall of Yahoo’s Open NSFW
NudeNet precision and recall on the dataturks dataset
GantMan’s nsfw_model precision and recall on the dataturks dataset
# installing the project
pip install git+
# Using the classifier
from NudeNet import NudeClassifier
classifier = NudeClassifier('classifier_checkpoint_path')



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store