Skip to main content

Looking for contributors/ maintainers for this repo: I have become busy with other stuff in the last years, still trying to maintain this repo as it is the current best OSS option for nudity detection, Looking for interested mainttainer, who can add/ work on more features for this repo (with my help of course)

NudeNet: lightweight Nudity detection

https://nudenet.notai.tech/ in-browser demo (the detector is run client side, i.e: in your browser, images are not sent to a server)

pip install --upgrade "nudenet>=3.4.2"
from nudenet import NudeDetector
detector = NudeDetector()
# the 320n model included with the package will be used

detector.detect('image.jpg') # Returns list of detections

detector.detect_batch(['image_1.jpg', 'image_2.jpg']) # Returns list of [list of detections]
  • Python package example in colab

  • detect and detect_batch accept file path(s), opencv image(s), image bytes(s), open(image_path, 'rb') (buffereader) objects

Available models

Model resolution trained based on onnx link pytorch link
320n 320x320 ultralytics yolov8n link link
640m 640x640 ultralytics yolov8m link link
# To use the 640m model, download the onnx file and pass the path to the model_path argument

detector = NudeDetector(model_path="downloaded_640m.onnx path", inference_resolution=640)
  • 320n is the default model and is included in the nudenet python package by default
detection_example = [
 {'class': 'BELLY_EXPOSED',
  'score': 0.799403190612793,
  'box': [64, 182, 49, 51]},
 {'class': 'FACE_FEMALE',
  'score': 0.7881264686584473,
  'box': [82, 66, 36, 43]},
 ]
nude_detector.censor('image.jpg') # returns censored image output path

# optional censor(self, image_path, classes=[], output_path=None) classes and output_path can be passed
all_labels = [
    "FEMALE_GENITALIA_COVERED",
    "FACE_FEMALE",
    "BUTTOCKS_EXPOSED",
    "FEMALE_BREAST_EXPOSED",
    "FEMALE_GENITALIA_EXPOSED",
    "MALE_BREAST_EXPOSED",
    "ANUS_EXPOSED",
    "FEET_EXPOSED",
    "BELLY_COVERED",
    "FEET_COVERED",
    "ARMPITS_COVERED",
    "ARMPITS_EXPOSED",
    "FACE_MALE",
    "BELLY_EXPOSED",
    "MALE_GENITALIA_EXPOSED",
    "ANUS_COVERED",
    "FEMALE_BREAST_COVERED",
    "BUTTOCKS_COVERED",
]

Docker

docker run -it -p8080:8080 ghcr.io/notai-tech/nudenet:latest
curl -F f1=@"images.jpeg" "http://localhost:8080/infer"

{"prediction": [[{"class": "BELLY_EXPOSED", "score": 0.8511635065078735, "box": [71, 182, 31, 50]}, {"class": "FACE_FEMALE", "score": 0.8033977150917053, "box": [83, 69, 21, 37]}, {"class": "FEMALE_BREAST_EXPOSED", "score": 0.7963727712631226, "box": [85, 137, 24, 38]}, {"class": "FEMALE_BREAST_EXPOSED", "score": 0.7709134817123413, "box": [63, 136, 20, 37]}, {"class": "ARMPITS_EXPOSED", "score": 0.7005534172058105, "box": [60, 127, 10, 20]}, {"class": "FEMALE_GENITALIA_EXPOSED", "score": 0.6804671287536621, "box": [81, 241, 14, 24]}]], "success": true}

Some interesting projects based on NudeNet

1 - by https://github.com/w-e-w, censor extension ps://github.com/notAI-tech/NudeNet/issues/131

Release files for nudenet 3.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nudenet 3.4.2
File Size Uploaded
nudenet-3.4.2.tar.gz 10.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for nudenet 3.4.2
File Interpreter ABI Platform
nudenet-3.4.2-py3-none-any.whl Python 3 none any Details

Total release size: 21.2 MB

Release files / nudenet-3.4.2.tar.gz

Download URL nudenet-3.4.2.tar.gz
Size 10.6 MB
Tags Source
SHA-256 checksum
How to use checksums
b20645d5f06bbb10006e6d4dc8a9513cf684269bbcffb0557a3ed6831aa90d75
BLAKE2b-256 checksum
How to use checksums
048f9e4862f004f648d240039ebffda2441d230741c164efaa25038051b56c60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / nudenet-3.4.2-py3-none-any.whl

Download URL nudenet-3.4.2-py3-none-any.whl
Size 10.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
5937dbd84e5d8e5de038f08ffea5a1bb50a08475776bf2b4795914ce0eaf0331
BLAKE2b-256 checksum
How to use checksums
1cee1aa02d44ba958cc77e16ff1e41a0aac5e721037db7bf62b9c9d124917f87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.4
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page