Skip to main content

Simple command line tool to convert COCO datasets to ultralytics YOLO format.

Project description

coco-to-yolo

Simple command line tool to convert COCO object detection datasets to YOLO format.

Usage

  1. Install via pip pip install coco-to-yolo
  2. Convert COCO dataset to ultralytics YOLO format using coco_to_yolo <<coco_dir>> <<output_dir>>

By default the script assumes the coco dataset to be structured as follows:

<<coco_dir>>
├── annotations
│   └── annotations.json     # Exactly ONE annotation file in COCO json format
└── images                   # Arbitary number of images (matching the file names 
    ├── image1.jpeg          # in the annotations json file)
    ├── image2.jpeg         
    └── ...

Split generation

By default the script will split 10% of the data into a test split and not generate a validation split. The ratio of splitted test and validation data can be adapted by specifying the --test_ratio and --val_ratio arguments, e.g.

Example usage

coco_to_yolo /home/COCO_ds /home/COCO_ds --test_ratio 0.15 --val_ratio 0.1

will convert the dataset in the /home/COCO_ds to the format required by YOLO, split 15% of the data for the testing, 10% for validation, and store the resulting dataset in /home/COCO_ds

Contributions

Feel free to suggest extensions and point out mistakes by creating an issue or sending me a pull request.

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

coco_to_yolo-1.1.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

coco_to_yolo-1.1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file coco_to_yolo-1.1.0.tar.gz.

File metadata

  • Download URL: coco_to_yolo-1.1.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for coco_to_yolo-1.1.0.tar.gz
Algorithm Hash digest
SHA256 4dc81bd98f6eb3ec1b9bce6f724aa68168ea151bf7a7c28a6de9bfad2b8ea970
MD5 42da70943828fe47f5e089b8e2983bef
BLAKE2b-256 ed92736944db09766465c6b2f7223de309f38707a55568a0d2045aea10253a26

See more details on using hashes here.

File details

Details for the file coco_to_yolo-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: coco_to_yolo-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for coco_to_yolo-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77318b0999b2b50c0475ca0c665c88b7ce6a3320192552dbac9c0f468336f7b3
MD5 90a735348ff8865079d2d79d208807e4
BLAKE2b-256 090d0371f6a2db4a4618306c6a64593aa31769c8f5d4c62414e58529a6962c42

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