text stringclasses 4
values |
|---|
opencv-python |
numpy |
pillow |
tqdm |
Human Face Filter Tool
A simple local dataset cleaning tool for detecting and separating images that contain human faces.
This tool scans a local dataset folder using OpenCV YuNet face detection and moves images with detected human faces into a separate removed_human_faces folder.
It is designed for dataset preparation workflows where human face images should be filtered out before uploading or using the cleaned dataset.
Features
- Detects human faces using OpenCV YuNet
- Moves detected face images outside the dataset folder
- Keeps the original folder structure when moving files
- Supports common image formats such as JPG, PNG, WEBP, BMP, and TIFF
- Uses strict landmark geometry checks to reduce false positives
- Safer default behavior: files are moved, not deleted
Folder Structure
human-face-filter-tool/
├─ dataset/
├─ face_detection_yunet.onnx
├─ remove_face_images.py
├─ remove_face_images.bat
├─ requirements.txt
└─ README.md
After running the script, images with detected human faces will be moved to:
removed_human_faces/
Installation
Install the required Python packages:
pip install -r requirements.txt
Usage
Place the images you want to scan inside the dataset folder.
Then run:
python remove_face_images.py
On Windows, you can also run:
remove_face_images.bat
Output
The script scans all supported image files inside:
dataset/
Images that contain detected human faces are moved to:
removed_human_faces/
Images without detected human faces remain inside:
dataset/
Important Notes
This tool does not modify the image content. It only moves images that are detected as containing human faces.
By default, files are not deleted. They are moved to removed_human_faces for manual review.
Do not upload the removed_human_faces folder if your goal is to publish only the cleaned dataset.
Detection Settings
The script uses strict filtering settings to reduce false positives, especially for nature, animal, texture, and object images.
Main safety settings include:
SCORE_THRESHOLD = 0.80
MIN_FACE_AREA_RATIO = 0.0015
MAX_IMAGE_SIDE_FOR_SCAN = 1280
DELETE_INSTEAD_OF_MOVE = False
You can adjust these values inside remove_face_images.py if needed.
Recommended Workflow
- Put your raw images inside the
datasetfolder. - Run the script.
- Review the
removed_human_facesfolder. - Keep only the cleaned
datasetfolder for your final dataset workflow.
Requirements
- Python 3.9+
- OpenCV
- NumPy
- Pillow
- tqdm
Install all requirements with:
pip install -r requirements.txt
License
Please check the license terms of the YuNet ONNX model and any datasets you process with this tool.
Disclaimer
Face detection may not be perfect. Always manually review important datasets before publishing, training, or distribution.
- Downloads last month
- 24