Welcome to the JSON2YOLO repository! This toolkit is designed to help you convert datasets in JSON format, particularly those following the COCO (Common Objects in Context) standards, into the YOLO format. The YOLO format is widely recognized for its efficiency in real-time object detection tasks.
This conversion process is essential for machine learning practitioners looking to train object detection models using frameworks compatible with the YOLO format, such as Ultralytics YOLO. Our code is flexible and designed to run across various platforms including Linux, macOS, and Windows.
To get started with JSON2YOLO, you'll need a Python environment running version 3.8 or later. Additionally, you'll need to install all the necessary dependencies listed in the 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
To convert your COCO JSON dataset to YOLO format, run the convert.py
script from your terminal. You need to specify the path to the directory containing your COCO JSON annotation files and the directory where you want to save the resulting YOLO label files.
# Example usage: Convert COCO annotations to YOLO format
python convert.py --json_dir path/to/coco/annotations --save_dir path/to/yolo/labels
--json_dir
: Path to the directory containing COCO JSON annotation files (e.g.,instances_train2017.json
).--save_dir
: Path to the directory where the converted YOLO label files (.txt
) will be saved.
This script will process the JSON files, extract bounding box information, and convert it into the YOLO format, saving one .txt
file per image in the specified save directory. For more details on dataset formats, refer to our documentation.
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 offers two licensing options to accommodate diverse needs:
- AGPL-3.0 License: Ideal for students and enthusiasts, this OSI-approved open-source license promotes collaboration and knowledge sharing. See the LICENSE file for details.
- Enterprise License: Designed for commercial use, this license permits seamless integration of Ultralytics software and AI models into commercial products and services, bypassing the open-source requirements of AGPL-3.0. For commercial inquiries, please contact us through Ultralytics Licensing.
For bug reports, feature requests, and contributions, please visit GitHub Issues. For broader questions and discussions about this project and other Ultralytics initiatives, join our vibrant community on Discord!