Skip to main content

YOLO Dataset Tools - Comprehensive toolkit for YOLO format dataset processing

Project description

๐ŸŽฏ YDT - YOLO Dataset Tools

A Professional Toolkit for YOLO Dataset Processing

Python Version License Code style: black Type Checked

English | ็ฎ€ไฝ“ไธญๆ–‡


โœจ Features

๐Ÿ–ผ๏ธ Image Processing

  • ๐Ÿ“ SAHI-powered smart slicing
  • ๐Ÿ”„ Rotation with OBB transformation
  • ๐Ÿ“ Multi-method resize (scale & crop)
  • ๐Ÿ“ Coordinate-based precision cropping
  • ๐ŸŽจ HSV color augmentation
  • ๐ŸŽฌ Video frame extraction
  • ๐Ÿš€ Multi-threaded video processing

๐Ÿ“Š Dataset Operations

  • โœ‚๏ธ Smart train/val split
  • ๐Ÿ”— Multi-dataset merging
  • ๐ŸŽฒ Synthetic data generation
  • ๐Ÿค– YOLO auto-labeling
  • ๐Ÿ“ฆ Batch processing

๐Ÿ‘๏ธ Visualization

  • ๐Ÿ–ผ๏ธ Interactive dataset browser
  • โŒจ๏ธ Keyboard controls (n/p/q)
  • ๐ŸŽฏ Class filtering
  • ๐Ÿ“ธ Letterbox preview
  • ๐ŸŽจ Augmentation effects

๐ŸŽฏ Format Support

  • ๐Ÿ“ OBB (Oriented Bounding Box)
  • ๐Ÿ“ฆ Standard BBox
  • ๐Ÿ”„ Auto format detection
  • โœจ Seamless conversion

๐Ÿ“ฆ 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 --train-ratio 0.8
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
)
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 image
  • p - Previous image
  • q - Quit
ydt viz dataset -i ./dataset

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments


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

yolodt-0.2.6.tar.gz (64.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yolodt-0.2.6-py3-none-any.whl (64.1 kB view details)

Uploaded Python 3

File details

Details for the file yolodt-0.2.6.tar.gz.

File metadata

  • Download URL: yolodt-0.2.6.tar.gz
  • Upload date:
  • Size: 64.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for yolodt-0.2.6.tar.gz
Algorithm Hash digest
SHA256 bb79f1ca0e7cd1ef632e6e7bb926a3c061af86c66916d46c3414f14ac6ee9123
MD5 701bb58acf0f0b3cb6a3c3ba9b993e56
BLAKE2b-256 f1997673bb192115dacb2ae8eec4bcfd003ca4715f1fb988eb04e78702cbdf45

See more details on using hashes here.

File details

Details for the file yolodt-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: yolodt-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 64.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for yolodt-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3776ab8bad3efa18f979a49dcb811c900556fbebaa9b2160a288777989c7108e
MD5 f7d960ed813208b16e0b89f34f075f48
BLAKE2b-256 2f07a7779a4f1cade0205e75d4cf4b439f0c2fa92896271f053a7c2ca83fc345

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page