The folder tools/data_converters currently contains ballon2coco.py, yolo2coco.py, and labelme2coco.py - three dataset conversion tools.
ballon2coco.pyconverts theballoondataset (this small dataset is for starters only) to COCO format.
python tools/dataset_converters/balloon2coco.pyyolo2coco.pyconverts a dataset fromyolo-style.txt format to COCO format, please use it as follows:
python tools/dataset_converters/yolo2coco.py /path/to/the/root/dir/of/your_datasetInstructions:
image_diris the root directory of the yolo-style dataset you need to pass to the script, which should containimages,labels, andclasses.txt.classes.txtis the class declaration corresponding to the current dataset. One class a line. The structure of the root directory should be formatted as this example shows:
.
└── $ROOT_PATH
├── classes.txt
├── labels
│ ├── a.txt
│ ├── b.txt
│ └── ...
├── images
│ ├── a.jpg
│ ├── b.png
│ └── ...
└── ...- The script will automatically check if
train.txt,val.txt, andtest.txthave already existed underimage_dir. If these files are located, the script will organize the dataset accordingly. Otherwise, the script will convert the dataset into one file. The image paths in these files must be ABSOLUTE paths. - By default, the script will create a folder called
annotationsin theimage_dirdirectory which stores the converted JSON file. Iftrain.txt,val.txt, andtest.txtare not found, the output file isresult.json. Otherwise, the corresponding JSON file will be generated, named astrain.json,val.json, andtest.json. Theannotationsfolder may look similar to this:
.
└── $ROOT_PATH
├── annotations
│ ├── result.json
│ └── ...
├── classes.txt
├── labels
│ ├── a.txt
│ ├── b.txt
│ └── ...
├── images
│ ├── a.jpg
│ ├── b.png
│ └── ...
└── ...