CLI tool to crop people from images using YOLOvX
Project description
YOLOv8 Person Cropping Tool
This tool uses YOLOv8 to detect and crop persons from images. It's designed to process multiple images, optionally searching recursively through directories, and can crop either the largest detected person or all detected persons in each image.
Features
- Uses YOLOv8 for accurate person detection
- Supports multiple YOLOv8 models (yolov8x.pt, yolov8m.pt, yolov8s.pt)
- Processes images in parallel for faster execution
- Allows recursive directory search
- Option to crop all detected persons or just the largest one
- Adds customizable margin to cropped images
- Saves images with no detected persons in a separate directory
- Option to remove small images after processing
Installation
- Clone this repository
- Install the required dependencies:
pip install ultralytics rich typer opencv-python
- Ensure you have the YOLOv8 models in your home directory under a
yolov8
folder.
Usage
Run the script using the following command:
python main.py [OPTIONS]
Options
--margin-percentage INTEGER
: Margin percentage for bounding box (default: 3, recommended range: 0-10)--model-size INTEGER
: Model size (default: 640, recommended: 320, 640, or 1280)--model TEXT
: YOLOv8 model to use (options: yolov8x.pt, yolov8m.pt, yolov8s.pt)--recursive / --no-recursive
: Search for images recursively (default: False)--crop-all / --no-crop-all
: Crop all detected persons instead of just the largest (default: False)
How it works
- The script prompts you to select an input directory.
- It processes all images in the selected directory (and subdirectories if recursive option is enabled).
- Detected persons are cropped from the images with the specified margin.
- Cropped images are saved in a 'cropped' subdirectory within the input directory.
- Images with no detected persons are saved in a 'no-person' subdirectory.
- After processing, you have the option to remove small images based on a size threshold.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
crop_people_cli-1.3.0.tar.gz
(5.3 kB
view details)
Built Distribution
File details
Details for the file crop_people_cli-1.3.0.tar.gz
.
File metadata
- Download URL: crop_people_cli-1.3.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab678e9102182e63bb4b118aa2c5c072b9045e87b0815cb2db944b7d0d09b51e |
|
MD5 | b10f4247f8a1c03007c57c8dc517be5a |
|
BLAKE2b-256 | 67addf0cb50022d595c886717bf97212f2231c2b8e496e8f4fa0edb513651adc |
File details
Details for the file crop_people_cli-1.3.0-py3-none-any.whl
.
File metadata
- Download URL: crop_people_cli-1.3.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc27e921538da61aa309f62d5113870db5e723a232d6f7adb524a8c9f4cf9207 |
|
MD5 | cc3a8791231dc0c3220a47027db0bb6c |
|
BLAKE2b-256 | afe3c4d785867f8af79f78d3891cc0029ad15c13cd069aa5a815179c9755f45a |