Censorship is a Python project designed to automatically detect and censor NSFW (Not Safe For Work) content in images. The project uses a pre-trained ONNX model for nude detection and provides both censored and debug outputs for each processed image.
- Automatically scans images for NSFW content.
- Censors detected nude regions using pixelation.
- Generates debug images with detection overlays for analysis.
- Logs progress and errors during processing.
- Supports batch processing of images.
- Python 3.8+
- ONNX Runtime
- OpenCV
- nudenet (>=3.4.2)
- libgl1 (system dependency)
Install dependencies:
pip install -r requirements.txtor :
pip install --upgrade "nudenet>=3.4.2";
pip install opencv-python;sudo apt-get install -y libgl1Place images to be processed in the files/ directory.
Run the main script:
source .venv/bin/activatepython main.pyYou can also customize parameters, for example:
python main.py --input my_images --output results --pixel-size 8 --debug --force-process --save-result-json| Argument | Default | Description |
|---|---|---|
-i, --input |
files |
Input directory containing images to process |
-o, --output |
output |
Output directory to save processed images |
-e, --extensions |
.jpeg .jpg .png |
List of image file extensions to process |
-r, --recursive |
(flag) | Recursively search for images in subdirectories |
-p, --pixel-size |
3 |
Pixelation block size for censorship (higher = more pixelated, range: 1-256) |
-d, --debug |
(flag) | Enable debug mode to save debug images with detection overlays |
--save-result-json |
(flag) | Save the results to a JSON file |
-l, --labels |
FEMALE_GENITALIA and MALE_GENITALIA | List of labels to detect |
--force-process |
(flag) | Force processing of images even when they have no changes |
--logpath |
logs |
Folder to the log file |
--loglevel |
INFO |
Logging level for the log file (DEBUG, INFO, WARNING, ERROR, CRITICAL) |