Convert object detection datasets (COCO, YOLO, Pascal VOC, etc.) to HuggingFace format
Project description
Hubify
Convert object detection datasets to HuggingFace format and upload to the Hub.
Currently supported formats:
- COCO format annotations
- YOLO format annotations
- YOLO OBB format annotations
Coming soon: Pascal VOC, Labelme, and more!
Motivations for this tool
HuggingFace has become the defacto open source community to upload datasets and models. It's primarily about LLMs and language models, but there's nothing about HuggingFace's dataset hosting that's specific to language modeling.
This tool is meant to be a way to consolidate the different formats from the object detection domain (COCO, Pascal VOC, etc) into what HuggingFace suggests for their Image Datasets, and upload it to HuggingFace Hub.
Installation
# Install with uv (recommended)
uv pip install -e .
# Or with pip
pip install -e .
Usage
After installation, you can use the hubify command:
# Auto-detect annotations in train/validation/test directories
hubify --data-dir /path/to/images --format coco
# Manually specify annotation files
hubify --data-dir /path/to/images \
--train-annotations /path/to/instances_train2017.json \
--validation-annotations /path/to/instances_val2017.json
# Generate sample visualizations
hubify --data-dir /path/to/images --visualize
# Push to HuggingFace Hub
hubify --data-dir /path/to/images \
--train-annotations /path/to/instances_train2017.json \
--push-to-hub username/my-dataset
Or for yolo:
hubify --data-dir ~/Downloads/DOTAv1.5 --format yolo-obb --push-to-hub benjamintli/dota-v1.5
hubify --data-dir ~/Downloads/DOTAv1.5 --format yolo --push-to-hub benjamintli/dota-v1.5
Or run directly with Python (from the virtual environment):
source .venv/bin/activate
python -m src.main --data-dir /path/to/images
Expected Directory Structure
- For coco:
data-dir/
├── train/
│ ├── instances*.json (auto-detected)
│ └── *.jpg (images)
├── validation/
│ ├── instances*.json (auto-detected)
│ └── *.jpg (images)
└── test/ (optional)
├── instances*.json
└── *.jpg
Output
The tool generates metadata.jsonl files in each split directory:
data-dir/
├── train/
│ └── metadata.jsonl
└── validation/
└── metadata.jsonl
Each line in metadata.jsonl contains:
{
"file_name": "image.jpg",
"objects": {
"bbox": [[x, y, width, height], ...],
"category": [0, 1, ...]
}
}
Options
--data-dir: Root directory containing train/validation/test subdirectories (required)--train-annotations: Path to training annotations JSON (optional)--validation-annotations: Path to validation annotations JSON (optional)--test-annotations: Path to test annotations JSON (optional)--visualize: Generate sample visualization images with bounding boxes--push-to-hub: Push dataset to HuggingFace Hub (format:username/dataset-name)--token: HuggingFace API token (optional, defaults toHF_TOKENenv var orhuggingface-cli login)
Authentication for Hub Push
When using --push-to-hub, the tool looks for your HuggingFace token in this order:
--token YOUR_TOKEN(CLI argument)HF_TOKENenvironment variable- Token from
huggingface-cli login
If no token is found, you'll get a helpful error message with instructions.
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 hubify_dataset-0.1.1.tar.gz.
File metadata
- Download URL: hubify_dataset-0.1.1.tar.gz
- Upload date:
- Size: 15.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96e6d82c954ee1b36191c7220ddc2b9c44151511ebeb01ecc8e6d22704634e3e
|
|
| MD5 |
1e8a3adba8df609a2759e9505d4a93e4
|
|
| BLAKE2b-256 |
94aa93c82a0c85bdb7c6e60ede814d9ff5b24531899d57f09c776ba6493cef87
|
Provenance
The following attestation bundles were made for hubify_dataset-0.1.1.tar.gz:
Publisher:
workflow.yml on benjamintli/hubify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hubify_dataset-0.1.1.tar.gz -
Subject digest:
96e6d82c954ee1b36191c7220ddc2b9c44151511ebeb01ecc8e6d22704634e3e - Sigstore transparency entry: 830063522
- Sigstore integration time:
-
Permalink:
benjamintli/hubify@fbc753d97defd75770ec4d92a44fc8ba9a17197b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/benjamintli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@fbc753d97defd75770ec4d92a44fc8ba9a17197b -
Trigger Event:
release
-
Statement type:
File details
Details for the file hubify_dataset-0.1.1-py3-none-any.whl.
File metadata
- Download URL: hubify_dataset-0.1.1-py3-none-any.whl
- Upload date:
- Size: 17.4 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 |
75b9f6ba70f19fed27dceb92191748c9ea682197d05cb2d733edbe2952aeda35
|
|
| MD5 |
c8300a435a7d67cc258bda7ba850e2f0
|
|
| BLAKE2b-256 |
13d26e5bbac9d21d7f8a1fbbe11b7115c1c4a962806a07c559a930f07f150050
|
Provenance
The following attestation bundles were made for hubify_dataset-0.1.1-py3-none-any.whl:
Publisher:
workflow.yml on benjamintli/hubify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hubify_dataset-0.1.1-py3-none-any.whl -
Subject digest:
75b9f6ba70f19fed27dceb92191748c9ea682197d05cb2d733edbe2952aeda35 - Sigstore transparency entry: 830063554
- Sigstore integration time:
-
Permalink:
benjamintli/hubify@fbc753d97defd75770ec4d92a44fc8ba9a17197b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/benjamintli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@fbc753d97defd75770ec4d92a44fc8ba9a17197b -
Trigger Event:
release
-
Statement type: