Skip to content

Brokttv/COCO-CONVERTER

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

COCO-CONVERTER

Converting Data to COCO Dataset-like Format

This project provides a Python script to convert datasets (organized as folders or CSV files) into the COCO annotation format, with YOLO-based object detection for generating bounding box annotations, and finally creates a PyTorch Dataset ready to train.

Expected workflow:


Features

  • Convert a folder-structured dataset (images organized in class-named subfolders) into COCO format JSON.
  • Convert CSV-based datasets (with image paths and labels) into COCO format JSON.
  • Automatically run YOLOv5 detection on images to generate bounding box annotations.
  • Combine YOLO detections with dataset info to produce complete COCO-style annotations.
  • Provide a PyTorch Dataset class (CocoDataset) to load and use the generated COCO dataset easily.

Requirements

  • Python 3.7+
  • PyTorch
  • torchvision
  • pandas
  • PIL (Pillow)
  • YOLOv5 weights (e.g., yolov5s.pt)

Download YOLOv5 Weights

To run YOLOv5 detection, you need the yolov5s.pt weights file. Download it using this command:

 wget https://github.com/ultralytics/yolov5/releases/download/v6.0/yolov5s.pt

Setup

Install the required Python packages using:

pip install -r requirements.txt

Usage

Run the conversion script from the command line:

python coco_converter/full_script.py --data_dir PATH_TO_DATA --output OUTPUT_JSON

About

A CLI that converts CSV files and folders with image data to a JSON file with COCO annotations and builds a custom dataset off of it ready to train for object detection tasks.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages