YOLO Dataset Tools - Comprehensive toolkit for YOLO format dataset processing
Project description
๐ฏ YDT - YOLO Dataset Tools
A Professional Toolkit for YOLO Dataset Processing
โจ Features
๐ผ๏ธ Image Processing
|
๐ Dataset Operations
|
๐๏ธ Visualization
|
๐ฏ Format Support
|
๐ฆ Installation
Install from PyPI:
pip install yolodt
Or install from source:
git clone https://github.com/yourusername/ydt.git
cd ydt
pip install -e .
๐ Quick Start
# Try it out!
ydt image slice -i ./images -o ./output
ydt image slice -i ./images -o ./output -c 3 -d 2
ydt viz dataset -i ./dataset
ydt image slice -i image.jpg -o ./output -c 2
ydt image augment -i image.jpg -o ./output -a 45 90
ydt image crop-coords -i image.jpg -o ./output -c "100,50,600,400"
๐ป Usage
Command Line
# Image processing
# Slice images (directory or single file)
ydt image slice -i ./imgs -o ./out -c 3
ydt image slice -i image.jpg -o ./out -c 2 # NEW: Single file support
ydt image slice -i ./imgs -o ./out -c 3 -d 2 -r 0.1 --overlap-vertical 0.05
# Resize images
ydt image resize -i ./images -o ./resized -s 640 800 1024
ydt image resize -i image.jpg -o ./resized -s 640 # Single file support
# Augment images (directory or single file)
ydt image augment -i data.yaml -o ./aug
ydt image augment -i image.jpg -o ./aug -a 45 90 # NEW: Single file support
# Extract video frames
ydt image video -i ./videos -o ./frames -s 30
ydt image video -i ./videos -o ./frames --parallel -w 4
# Crop by coordinates (directory or single file)
ydt image crop-coords -i ./images -o ./cropped -c "100,50,600,400"
ydt image crop-coords -i image.jpg -o ./cropped -c "100,50,600,400" # NEW: Single file support
# Dataset operations
ydt dataset split -i data.yaml -o ./split -r 0.8
ydt dataset merge -i ./ds1 ./ds2 -o ./merged
ydt dataset synthesize -t ./targets -b ./backgrounds -o ./synthetic --objects-per-image 2-5 --split train
ydt dataset synthesize -t ./targets -b ./backgrounds -o ./synthetic --data-yaml ./data.yaml --rotation-range=-20,20 # With class validation and limited rotation
ydt dataset auto-label -i ./images -m ./yolo11n.pt --format bbox -o ./labeled
# Visualization
ydt viz dataset -i ./dataset
ydt viz letterbox -i ./image.jpg
ydt viz augment -i ./image.jpg
Python API
from ydt.image import (
slice_dataset,
augment_dataset,
extract_frames,
process_images_multi_method,
concat_images_horizontally,
concat_images_vertically
)
from ydt.dataset import split_dataset, DatasetSynthesizer, auto_label_dataset
from ydt.visual import visualize_dataset, visualize_letterbox
# Slice large images (directory or single file)
slice_dataset("./dataset", "./sliced", horizontal_count=3)
slice_dataset("image.jpg", "./sliced", horizontal_count=2) # NEW: Single file support
# Grid slicing (2ร3 = 6 slices)
slice_dataset("./dataset", "./sliced", horizontal_count=2, vertical_count=3)
# Resize images with both scale and crop methods
process_images_multi_method("./images", "./resized", target_sizes=[640, 800, 1024])
# Concatenate images
concat_images_horizontally("img1.jpg", "img2.jpg", "output.jpg", alignment="center")
# Extract frames from videos
extract_frames("./videos", "./frames", step=30)
# Split dataset
split_dataset("./data.yaml", "./split", train_ratio=0.8)
# Auto-label images
result = auto_label_dataset(
input_dir="./images",
model_path="./yolo11n.pt",
format_type="bbox",
output_dir="./labeled"
)
# Generate synthetic dataset with custom parameters
synthesizer = DatasetSynthesizer(
target_dir="./targets",
background_dir="./backgrounds",
output_dir="./synthetic",
objects_per_image=(2, 5), # 2-5 objects per image
split_mode="trainval", # Generate train+val
train_ratio=0.8, # 80% train, 20% val
data_yaml_path="./data.yaml", # Validate class names (e.g., bn_back.jpg requires 'bn' in names)
rotation_range=(-20, 20) # Limit rotation to ยฑ20 degrees
)
stats = synthesizer.synthesize_dataset(num_images=1000)
# Visualize dataset
visualize_dataset("./dataset", scan_train=True)
visualize_letterbox("./image.jpg", output_dir="./output")
๐ฆ What's Inside
ydt/
โโโ ๐ผ๏ธ image/ # Image processing
โโโ ๐ dataset/ # Dataset operations
โโโ ๐๏ธ visual/ # Visualization
โโโ ๐ ๏ธ core/ # Core utilities
โโโ ๐ค auto_label/ # Auto-labeling
โโโ โก cli/ # CLI interface
๐ฏ Key Features
Dual Format Support
Automatically detects and handles both formats:
| Format | Values | Description |
|---|---|---|
| OBB | 9 values | class_id x1 y1 x2 y2 x3 y3 x4 y4 |
| BBox | 5 values | class_id x_center y_center width height |
Smart Slicing
Powered by SAHI, intelligently slice large images while preserving label accuracy. Supports both horizontal and grid slicing with configurable overlap ratios.
# Horizontal slicing (default)
ydt image slice -i ./images -o ./sliced -c 3 -r 0.1
# Grid slicing (3ร2 = 6 slices)
ydt image slice -i ./images -o ./sliced -c 3 -d 2 -r 0.1 --overlap-vertical 0.05
# Fine grid slicing with custom overlap
ydt image slice -i ./images -o ./sliced -c 4 -d 3 -r 0.05 --overlap-vertical 0.02
Video Frame Extraction
Extract frames from video files for dataset creation. Supports both sequential and parallel processing.
# Sequential processing (default)
ydt image video -i ./videos -o ./frames -s 30
# Parallel processing for multiple videos
ydt image video -i ./videos -o ./frames --parallel -w 4
Features:
- ๐ฏ Smart worker count auto-detection
- โก Concurrent video decoding
- ๐ Progress tracking per video
- ๐ Automatic fallback for single videos
Auto-Labeling
Automatically label images using YOLO models with support for both BBox and OBB formats:
ydt dataset auto-label -i ./images -m ./yolo11n.pt --format bbox -o ./labeled
Features:
- ๐ฏ Support for both BBox and OBB formats
- ๐ค Automatic format detection and conversion
- ๐ Clean output directory structure
- โ๏ธ Configurable confidence and IOU thresholds
- ๐ Preview mode with
--dry-run
Interactive Visualization
Browse your dataset with keyboard controls:
n- Next imagep- Previous imageq- Quit
ydt viz dataset -i ./dataset
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Ultralytics - YOLO framework
- SAHI - Slicing aided hyper inference
- Albumentations - Image augmentation
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yolodt-0.2.7.tar.gz.
File metadata
- Download URL: yolodt-0.2.7.tar.gz
- Upload date:
- Size: 66.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04563287c509ad5e05ccb5d8a82c1d2b20d61953dfe5c1dfa9044569598e9d36
|
|
| MD5 |
f2615001e5c7425bccf1e892a07e116f
|
|
| BLAKE2b-256 |
bfdac8b26a6f4349867909341a8b0ecdfe679dd0ae522b3564940a25a35efef3
|
File details
Details for the file yolodt-0.2.7-py3-none-any.whl.
File metadata
- Download URL: yolodt-0.2.7-py3-none-any.whl
- Upload date:
- Size: 64.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c06753aa38c33c4dc213f96cab81ada0dcf217abe7e94a3fc8b99c44297012f
|
|
| MD5 |
8f36adedcdf7ba4d413479ac85818a26
|
|
| BLAKE2b-256 |
13be174a9c6a230f04b883518fe357dac27463bcfed19575624d155dbb963b84
|