This Python project detects nude and semi-nude images using the OpenNSFW2 library, blurs them, and organizes them into separate folders. It is designed to help automate the process of identifying and handling sensitive content in image datasets.
nude_images
).blurred_images
).Before running the application, ensure you have the following installed:
opennsfw2
(for NSFW detection)Pillow
(for image processing)shutil
(for file operations)You can install the required dependencies using the following command:
pip install opennsfw2 pillow
Clone this repository:
git clone https://github.com/wprashed/guardianai cd guardianai
Install the required dependencies:
pip install -r requirements.txt
Create the necessary folders:
mkdir input_images nude_images blurred_images
Place your images in the input_images
folder.
Run the script:
python app.py
The script will:
input_images
folder.nude_images
folder.blurred_images
folder.Adjust the sensitivity of detection by modifying the threshold
variable in the script:
threshold = 0.6 # Default value; adjust between 0 and 1
The project uses the following folder structure:
project/
├── input_images/ # Place your images here
├── nude_images/ # Original nude/semi-nude images will be moved here
├── blurred_images/ # Blurred nude/semi-nude images will be moved here
├── temp_blurred/ # Temporary folder for blurred images (auto-cleaned)
├── app.py # The Python script
├── README.md # Project documentation
└── requirements.txt # List of dependencies
Adjust Blur Intensity:
Modify the radius
parameter in the blur_image()
function to control the strength of the blur:
blurred_img = img.filter(ImageFilter.GaussianBlur(radius=20)) # Default radius
Change Detection Threshold:
Adjust the threshold
variable in the process_images()
function to make the detection stricter or more lenient:
threshold = 0.6 # Higher values make detection stricter
Output Folder Names:
Change the folder names in the process_images()
function if you want to use different folder names:
nude_folder = "nude_images" blurred_folder = "blurred_images"
Error: Pillow Not Installed:
If you encounter an error related to Pillow
, install it using:
pip install pillow
Error: File Overwrite Issues:
Ensure filenames are unique or modify the script to append a suffix to filenames when saving blurred images.
Temporary Folder Cleanup:
The temp_blurred
folder is automatically deleted if empty. If issues persist, manually delete it after running the script.
Contributions are welcome! If you'd like to contribute, please follow these steps:
This project is licensed under the MIT License. Feel free to use, modify, and distribute it as per the terms of the license.
Pillow
library for providing robust image processing capabilities.There are no models linked
There are no datasets linked
There are no models linked
There are no datasets linked