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.0.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

COCO_to_YOLO-1.0.2-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: coco_to_yolo-1.0.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.3

File hashes

Hashes for coco_to_yolo-1.0.2.tar.gz
Algorithm Hash digest
SHA256 e0095248808e0a7f2fe3cb8a8a763d043fd548bc1bdefacd7fb8f609aa1ac5d3
MD5 ebe281f113725d143a59e31f052e3b7a
BLAKE2b-256 eccd2adf535a8313127b29462d9686cf1d4dbf6439a154e01320ffba3957d111

See more details on using hashes here.

File details

Details for the file COCO_to_YOLO-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for COCO_to_YOLO-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 731c0906d7a05d1315e616bb7c996c786024795dde7be012b5e963ecfb7637e0
MD5 723d3b5c9736e55cbdf554507e775079
BLAKE2b-256 3fd9124b72c953be0c176302611623f7444a36b61a3e6a6e559742868b883816

See more details on using hashes here.

Supported by

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