Converts COCO JSON format to YOLO format.
This script provides a command-line interface for easy conversion.
Usage:
python coco2yolo.py --json_dir path/to/coco_json_files --use_segments
# For converting COCO classes from 91 to 80 categories:
python coco2yolo.py --json_dir path/to/coco_json_files --cls91to80
# For default behavior (no segmentation, 91 classes):
python coco2yolo.py --json_dir path/to/coco_json_files
Arguments:
--json_dir
: (Optional) Path to the directory containing JSON annotation files (*.json). If not provided, assumes the default location of "coco/annotations".--use_segments
: (Optional) Flag to include segmentation information in the output (for COCO only). Defaults to False.--cls91to80
: (Optional) Flag to convert COCO classes from 91 to 80 categories (for COCO only). Defaults to False.
Welcome to the COCO2YOLO repository! This toolkit is designed to help you convert datasets in JSON format, following the COCO (Common Objects in Context) standards, into YOLO (You Only Look Once) format, which is widely recognized for its efficiency in real-time object detection tasks.
This process is essential for machine learning practitioners looking to train object detection models using the Darknet framework. Our code is flexible and can be utilized across various platforms including Linux, MacOS, and Windows.
To get started with COCO2YOLO, you'll need a Python environment running version 3.8 or later. Additionally, you'll need to install all the necessary dependencies listed in our requirements.txt file. You can install these dependencies using the following pip command in your terminal:
$ pip install -r requirements.txt # Installs all the required packages
If you find our tool useful for your research or development, please consider citing it:
We welcome contributions from the community! Whether you're fixing bugs, adding new features, or improving documentation, your input is invaluable. Take a look at our Contributing Guide to get started. Also, we'd love to hear about your experience with Ultralytics products. Please consider filling out our Survey. A huge ๐ and thank you to all of our contributors!
![Ultralytics open-source contributors](https://github.com/ultralytics/assets/raw/main/im/image-contributors.png)
Ultralytics is excited to offer two different licensing options to meet your needs:
- AGPL-3.0 License: Perfect for students and hobbyists, this OSI-approved open-source license encourages collaborative learning and knowledge sharing. Please refer to the LICENSE file for detailed terms.
- Enterprise License: Ideal for commercial use, this license allows for the integration of Ultralytics software and AI models into commercial products without the open-source requirements of AGPL-3.0. For use cases that involve commercial applications, please contact us via Ultralytics Licensing.
For bug reports, feature requests, and contributions, head to GitHub Issues. For questions and discussions about this project and other Ultralytics endeavors, join us on Discord!