This is a Python script to auto-detect and auto-crop a person in a image.
This script uses Tensorflow and SSD Mobilenet V2 (COCO) to recognize people in a photo, then crop the photo to the single person.
- Windows and Linux command-line auto-install scripts
- Creates automatically the Python virtual environment and install requirements
- Downloads automatically the SSD Mobilenet V2 COCO model
- Supports GPU computing
- Images extension supported: .jpg, .jpeg, .png, .webp, .bmp
- Auto-crop a person if found
- If there is more than one person in the photo, it will create more photos
- Batch processing a input folder
- Option to save image in a specific format or save as input format
- Python 3.10 installed (with Python-pip)
- Download the repository
- Just run the .bat or .sh scripts.
- If Windows:
run.bat
- If Linux:
run.sh
(be sure tochmod +x
the script)
- If Windows:
If the automatic script does not work or if you want to use the python script directly.
- First, create a folder (name of your choice) and open a terminal in it.
- Create a Python virtual environment:
python -m venv venv
-
Activate the environment:
- If Windows:
./venv/Scripts/activate
- If Linux:
source venv/bin/activate
- If Windows:
-
Install the requirements:
pip install -r requirements.txt
- Run the Python script
person_autocrop.py
with:
python person_autocrop.py