Skip to main content

Convert object detection datasets (COCO, YOLO, Pascal VOC, etc.) to HuggingFace format

Project description

Hubify

Test & Lint CLI Smoke Test

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

pip install hubify-dataset

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 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

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

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)
  • --format: Dataset format: 'auto' (default), 'coco', 'yolo', or 'yolo-obb' (optional)
  • --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 to HF_TOKEN env var or huggingface-cli login)

Authentication for Hub Push

When using --push-to-hub, the tool looks for your HuggingFace token in this order:

  1. --token YOUR_TOKEN (CLI argument)
  2. HF_TOKEN environment variable
  3. 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

hubify_dataset-0.1.4.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

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

hubify_dataset-0.1.4-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file hubify_dataset-0.1.4.tar.gz.

File metadata

  • Download URL: hubify_dataset-0.1.4.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

Hashes for hubify_dataset-0.1.4.tar.gz
Algorithm Hash digest
SHA256 034b1460f631eaedf8d13b92d9fa7983bb1a0c893c3f9be92275604c4ca97a0f
MD5 902afa700ee89f2483d6b92dea9f5caa
BLAKE2b-256 b37762179c20e8d418043a0c31fc44b5cf63eaee8b955df358763f8ff66af662

See more details on using hashes here.

Provenance

The following attestation bundles were made for hubify_dataset-0.1.4.tar.gz:

Publisher: workflow.yml on benjamintli/hubify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hubify_dataset-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: hubify_dataset-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for hubify_dataset-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c86b83dde83cf6021a78a9532621901f4ae6862dc153d7c2ebbf6fac0574cff5
MD5 20364a3f46b80677a7320d5d2ad03afb
BLAKE2b-256 1ba546ad0a08f42ae9adb3db25a692fd805eeb4c099726029ce0300bbf9df89e

See more details on using hashes here.

Provenance

The following attestation bundles were made for hubify_dataset-0.1.4-py3-none-any.whl:

Publisher: workflow.yml on benjamintli/hubify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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