A CLI tool for managing and analyzing image datasets for model training
Project description
ModelPrep
A command-line tool for managing image datasets, optimized for training object detection models. ModelPrep simplifies the process of preparing and managing image datasets for machine learning, with special focus on person detection and small object detection scenarios.
Quick Start
# Install ModelPrep
pip install modelprep
# Show dataset information
modelprep show
# Create person crops
modelprep person-crop create
# Train a model
modelprep train --size small
Installation
pip install modelprep
Commands
Dataset Management
# Show dataset information
modelprep show # Show all images and their properties
modelprep show --small-images # Show only small images (<32x32)
# Remove images
modelprep remove --small-images # Remove small images (<32x32)
Person Crop Operations
# Create and manage person crops
modelprep person-crop create --padding 20 # Create person crops with 20% padding
modelprep person-crop show # Show all person crops
modelprep person-crop show --sort-by-size # Sort by size (large to small)
modelprep person-crop show --sort-by-size --reverse # Sort by size (small to large)
# Manage small person crops
modelprep person-crop show-small --min-size-kb 10 --min-pixels 100 # Preview small crops
modelprep person-crop remove-small --min-size-kb 10 --min-pixels 100 # Remove small crops
# Dataset integration
modelprep person-crop add-to-dataset # Add person crops to dataset
modelprep person-crop add-to-dataset --train-split 0.7 --valid-split 0.2 --test-split 0.1 # Add person crops to dataset with split
modelprep person-crop remove-from-dataset # Remove person crops from dataset
Training YOLOv8 Models
# Basic training (auto-names with current date)
modelprep train
# Train with nohup
modelprep train --nohup
# Train with different size parameters
modelprep train --size nano # Fastest training
modelprep train --size small # Default
modelprep train --size medium # Better accuracy
modelprep train --size large # High accuracy
modelprep train --size xlarge # Best accuracy
# Advanced training options
modelprep train \
--size medium \ # Model size
--epochs 300 \ # Number of epochs
--batch 256 \ # Batch size (adjust for GPU)
--img 640 \ # Image size
--device 0 \ # GPU device (empty for auto)
--project "my_project" \ # Project name
--name "exp1" # Experiment name
# Training management
modelprep train --resume # Resume from last checkpoint
modelprep train --weights "runs/train/Nov14/weights/best.pt" # Resume from specific weights
modelprep train --val-only --weights "runs/train/best.pt" # Validation only
modelprep train --nohup # SSH-safe training
# Monitor training status
modelprep status # Show latest training status
modelprep status --name Nov14 # Show specific training status
modelprep status --follow # Follow log output (like tail -f)
modelprep status -f -n Nov14 -n 100 # Follow specific training, show 100 lines
Roboflow Integration
# Project management
modelprep roboflow create-project --project-name "my_project" \
--project-type "object-detection" \
--project-license "CC BY 4.0" \
--annotation "object-detection"
# Upload datasets
modelprep roboflow upload --project-name "my_project" --dataset-name "person-crops"
Features
- Complete dataset management and analysis
- Automated person cropping with annotation adjustment
- Size-based filtering and sorting
- YOLOv8 training optimized for small object detection
- SSH-safe training with nohup
- Roboflow integration for dataset management
- Rich CLI output with formatted tables
Requirements
- Python 3.7+
- Ultralytics (YOLOv8)
- Pillow (PIL)
- Typer
- Rich
- Roboflow
- python-dotenv
- tqdm
Development
# Installation
make help # Show all make commands
make develop # Install for development
make install # Install for production
make clean # Clean up everything
make format # Format code
# Testing
make test # Run all tests
make test-ci # Run tests with coverage report
pytest tests/ -v # Run tests directly
# Release Management
make release # Create a new release
Testing
# Install test dependencies
pip install -e ".[test]"
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
If you encounter any problems, please file an issue along with a detailed description.
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
modelprep-0.2.7.tar.gz
(18.3 kB
view details)
Built Distribution
modelprep-0.2.7-py3-none-any.whl
(14.6 kB
view details)
File details
Details for the file modelprep-0.2.7.tar.gz
.
File metadata
- Download URL: modelprep-0.2.7.tar.gz
- Upload date:
- Size: 18.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7be82b1154ed744bf38cc4341bf2ec0227300f2149c40575b2ace675a8d70f21 |
|
MD5 | 64b01a9531fc56aae9ce11d9ec40f0c3 |
|
BLAKE2b-256 | 24b97617120ba635e24a346138ec2522ca2f23cfa422c1dd0aa68004a7688417 |
File details
Details for the file modelprep-0.2.7-py3-none-any.whl
.
File metadata
- Download URL: modelprep-0.2.7-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6ccacb7fa9ff74afdf6431226cd4fdc38a0c2ca011e5aec80c185831b9d2199 |
|
MD5 | 7c925527800238648e433daabf609b94 |
|
BLAKE2b-256 | c213716d104dedae2c2ecd97b235c8aa67ccc64e517a4fe7d3385c8a515170d1 |