This utility uses the YoloV8 model for detecting people, and the YoloV8-face model for detecting faces.
It processes a directory of images, detects the people with faces, auto-crops the images (as a copy) and saves them to a specified directory.
Processing results for 25 images from Unsplash
python "main.py" --images_directory "unsplash-images" --results_folder "unsplash-images-results" --crop_ratio "(3,4)" --person_percent_detection_cutoff 0.075 --person_padding_percent 0.02
- Git
- Python 3.10
- Open
cmd
- Clone the repository
git clone https://github.com/djbielejeski/autocropper-supervision
- Navigate into the repository
cd autocropper-supervision
python -m venv autocropper-supervision-venv
autocropper-supervision-venv\Scripts\activate.bat
pip install -r requirements.txt
python "main.py" --images_directory "C:/Images"
cmd> deactivate
python "main.py" --images_directory "C:\\images" --results_folder "C:\\results" --crop_ratio "(3,4)" --person_percent_detection_cutoff 0.075 --person_padding_percent 0.02
Command | Type | Example | Description |
---|---|---|---|
--images_directory |
string | "C:\\images" |
The path the images folder to process |
--results_folder |
string | "C:\\results" |
Optional Defaults to \results |
--crop_ratio |
tuple | (3,4) |
Optional Defaults to (3,4) . Available Options: (1,1) , (2,3) , or (3,4) |
--person_percent_detection_cutoff |
float | 0.075 |
Optional Defaults to 0.075 . Percentage of the overall image that must contain a person to be detected. Useful for removing background people from the results |
--person_padding_percent |
float | 0.02 |
Optional Defaults to 0.02 . Percent of the detected person to add padding for. Example: Detected person is 512x512px , will add 512px * 0.02 => 10px of padding. |