A comprehensive Python toolkit for managing, converting, and annotating object detection datasets with support for COCO and YOLO formats.
Project description
BoxLab
A comprehensive Python toolkit for managing, converting, and annotating object detection datasets with support for COCO and YOLO formats.
Features
- Dataset Management - Load, merge, split, and analyze datasets with multi-source support
- Format Conversion - Seamlessly convert between COCO and YOLO formats
- GUI Annotator - Interactive desktop application for viewing and editing annotations
- CLI Tools - Powerful command-line interface for batch operations
- PyTorch Integration - Direct integration with PyTorch training pipelines
- Plugin System - Extensible architecture for custom format support
Installation
From PyPI (Recommended)
pip install boxlab
From Source
# Clone repository
git clone https://github.com/6ixGODD/boxlab.git
cd boxlab
# Install with Poetry (recommended)
poetry install
# Or install with pip
pip install -e .
Optional Dependencies
For PyTorch integration:
pip install torch torchvision
Quick Start
View Dataset Information
boxlab dataset info data/coco/annotations.json --format coco
Convert Between Formats
# COCO to YOLO
boxlab dataset convert input.json -if coco output -of yolo
# YOLO to COCO
boxlab dataset convert data/yolo -if yolo output -of coco
Merge Multiple Datasets
boxlab dataset merge \
-i dataset1/ann.json coco source1 \
-i dataset2/ann.json coco source2 \
-o merged_dataset
Launch GUI Annotator
boxlab annotator
Python API
from boxlab.dataset.io import load_dataset, export_dataset
# Load dataset
dataset = load_dataset("annotations.json", format="coco")
# Get statistics
stats = dataset.get_statistics()
print(f"Images: {stats['num_images']}")
print(f"Annotations: {stats['num_annotations']}")
# Export to different format
export_dataset(dataset, "output/yolo", format="yolo")
CLI Commands
Dataset Operations
# View information
boxlab dataset info <path> --format <coco|yolo>
# Convert formats
boxlab dataset convert <input> -if <format> <output> -of <format>
# Merge datasets
boxlab dataset merge -i <path> <format> [name] -o <output>
# Visualize dataset
boxlab dataset visualize <path> --format <format> -o <output>
Annotator
# Launch GUI application
boxlab annotator
PyTorch Integration
from boxlab.dataset.io import load_dataset
from boxlab.dataset.torchadapter import build_torchdataset
from torch.utils.data import DataLoader
# Load and prepare dataset
dataset = load_dataset("train.json", format="coco")
# Create PyTorch dataset with augmentation
torch_dataset = build_torchdataset(
dataset,
image_size=640,
augment=True,
normalize=True,
return_format="xyxy"
)
# Create DataLoader
train_loader = DataLoader(
torch_dataset,
batch_size=16,
shuffle=True,
collate_fn=torch_dataset.collate
)
# Training loop
for images, targets in train_loader:
# Your training code here
pass
Custom Plugin Development
Custom Loader
from boxlab.dataset.plugins import LoaderPlugin
from boxlab.dataset import Dataset
class CustomLoader(LoaderPlugin):
@property
def name(self) -> str:
return "custom_format"
@property
def description(self) -> str:
return "Custom format loader"
def load(self, path, **kwargs):
dataset = Dataset(name="custom")
# Your loading logic here
return dataset
# Register and use
from boxlab.dataset.plugins.registry import register_loader
register_loader("custom_format", CustomLoader)
Documentation
Full documentation is available at: https://6ixgodd.github.io/boxlab
Examples
Convert with Custom Split Ratio
boxlab dataset convert annotations.json \
-if coco \
output/yolo \
-of yolo \
--train-ratio 0.7 \
--val-ratio 0.2 \
--test-ratio 0.1 \
--seed 42
Merge with Source Tracking
boxlab dataset merge \
-i manual_annotations.json coco manual \
-i automatic_annotations.json coco automatic \
-o combined_dataset \
--preserve-sources
Visualize with Heatmap
boxlab dataset visualize data/yolo \
--format yolo \
-o visualizations \
--samples 10 \
--show-heatmap \
--show-source-dist
Requirements
- Python 3.10 or higher
- NumPy
- Pillow
- Matplotlib
- PyYAML
- Pandas
Optional
- PyTorch (for training integration)
- torchvision (for training integration)
Project Structure
boxlab/
├── boxlab/
│ ├── dataset/ # Core dataset management
│ │ ├── plugins/ # Format plugins (COCO, YOLO)
│ │ ├── io.py # I/O operations
│ │ ├── types.py # Data structures
│ │ └── torchadapter.py # PyTorch integration
│ ├── annotator/ # GUI application
│ ├── cli/ # Command-line interface
│ └── exceptions.py # Error handling
├── docs/ # Documentation
├── tests/ # Test suite
└── pyproject.toml # Project configuration
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development Setup
# Clone repository
git clone https://github.com/6ixGODD/boxlab.git
cd boxlab
# Install with development and test dependencies
poetry install --all-extras
# Run tests
poetry run pytest
# Run linting
poetry run ruff check .
# Build documentation
poetry run mkdocs serve
Guidelines
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Documentation: https://6ixgodd.github.io/boxlab
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Changelog
See CHANGELOG.md for version history and release notes.
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 boxlab-0.1.3.tar.gz.
File metadata
- Download URL: boxlab-0.1.3.tar.gz
- Upload date:
- Size: 96.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfe42e671d995b5b0c0338d7eb1defa89de65b00e8ccfc31ac9eeac8652acec6
|
|
| MD5 |
b17bfe1d1774a0ed37b1faa359f5bb70
|
|
| BLAKE2b-256 |
8c3d27ced11352816d67934eb2ae85adab5861c532dbe61d9b5f60a6c935fbef
|
Provenance
The following attestation bundles were made for boxlab-0.1.3.tar.gz:
Publisher:
publish.yml on 6ixGODD/boxlab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
boxlab-0.1.3.tar.gz -
Subject digest:
dfe42e671d995b5b0c0338d7eb1defa89de65b00e8ccfc31ac9eeac8652acec6 - Sigstore transparency entry: 705032119
- Sigstore integration time:
-
Permalink:
6ixGODD/boxlab@5788ad8c82e21db501201a584b4a1991d05f385a -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/6ixGODD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5788ad8c82e21db501201a584b4a1991d05f385a -
Trigger Event:
release
-
Statement type:
File details
Details for the file boxlab-0.1.3-py3-none-any.whl.
File metadata
- Download URL: boxlab-0.1.3-py3-none-any.whl
- Upload date:
- Size: 114.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c0ef0b5487f20dc1c764a92f8e2e4b90ac62a1373f21d765b316b3eaf39e5a3
|
|
| MD5 |
2060d8ae62df76fd29dfcda82b5cb6f6
|
|
| BLAKE2b-256 |
e42fd853e26196a3e8e3a203d9ac72fb93398888b8b302f16ff285b0a26b6255
|
Provenance
The following attestation bundles were made for boxlab-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on 6ixGODD/boxlab
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
boxlab-0.1.3-py3-none-any.whl -
Subject digest:
5c0ef0b5487f20dc1c764a92f8e2e4b90ac62a1373f21d765b316b3eaf39e5a3 - Sigstore transparency entry: 705032125
- Sigstore integration time:
-
Permalink:
6ixGODD/boxlab@5788ad8c82e21db501201a584b4a1991d05f385a -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/6ixGODD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5788ad8c82e21db501201a584b4a1991d05f385a -
Trigger Event:
release
-
Statement type: