Skip to main content

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

  1. Clone this repository
  2. Install the required dependencies:
pip install ultralytics rich typer opencv-python
  1. 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

  1. The script prompts you to select an input directory.
  2. It processes all images in the selected directory (and subdirectories if recursive option is enabled).
  3. Detected persons are cropped from the images with the specified margin.
  4. Cropped images are saved in a 'cropped' subdirectory within the input directory.
  5. Images with no detected persons are saved in a 'no-person' subdirectory.
  6. After processing, you have the option to remove small images based on a size threshold.

Metadata

Release files for crop-people-yolo-cli 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for crop-people-yolo-cli 1.4.0
File Size Uploaded
crop_people_yolo_cli-1.4.0.tar.gz 20.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for crop-people-yolo-cli 1.4.0
File Interpreter ABI Platform
crop_people_yolo_cli-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 44.1 kB

Release files / crop_people_yolo_cli-1.4.0.tar.gz

Download URL crop_people_yolo_cli-1.4.0.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
62dd87f1890633451c71a3d9f4f54d397c039440f31dbf7c083e2571550a40ba
BLAKE2b-256 checksum
How to use checksums
989e44385c0b63e0da4505bd4b49d6866fa9a1360f76e20c9a103a7b4734adc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.15

Release files / crop_people_yolo_cli-1.4.0-py3-none-any.whl

Download URL crop_people_yolo_cli-1.4.0-py3-none-any.whl
Size 23.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8b60b97153170612527b1239a203adaf3e29425317ae11cb502d04d4957d9585
BLAKE2b-256 checksum
How to use checksums
697d4b034a82aef2a0c1af5752d0ab375e8f5be50bfd4166f684722fef62cba4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.15

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page