This Python script filters .jpg images in a folder based on face detection (using MediaPipe) and file size. Images that contain a detected face and fall within the defined size limits are copied to a target folder.
- Select source and target folders via a simple GUI (Tkinter)
- Face detection using MediaPipe
- Progress display with
tqdm - Filters images based on minimum and maximum file size
- Automatically copies valid images
- Python 3.7 or higher
Install the required packages with:
pip install -r requirements.txtRequired packages:
mediapipepillownumpytqdm
Alternatively:
pip install mediapipe pillow numpy tqdm- Run the script:
python FaceDetectionSort.py- A dialog window will open asking you to select the source folder that contains the images.
- Then, select the target folder where the filtered images should be copied.
- The script will process all
.jpgimages:- Skips images that are below or above the defined size threshold
- Detects faces with a configurable confidence threshold (default:
0.75) - Displays progress and status in the console
You can change these at the top of the main.py file:
FACE_DETECTION_THRESHOLD = 0.75 # Confidence threshold for face detection
MIN_FILE_SIZE_KB = 100 # Minimum file size in KB
MAX_FILE_SIZE_MB = 15 # Maximum file size in MB