Forked from rooneysh/Labelme2YOLO
Help converting LabelMe Annotation Tool JSON format to YOLO text file format. If you've already marked your segmentation dataset by LabelMe, it's easy to use this tool to help converting to YOLO format dataset.
- export data as yolo polygon annotation (for YOLOv5 v7.0 segmentation)
pip install labelme2yolo
--json_dir LabelMe JSON files folder path.
--val_size (Optional) Validation dataset size, for example 0.2 means 20% for validation.
--test_size (Optional) Test dataset size, for example 0.2 means 20% for Test.
--json_name (Optional) Convert single LabelMe JSON file.
Put all LabelMe JSON files under labelme_json_dir, and run this python command.
labelme2yolo --json_dir /path/to/labelme_json_dir/ --val_size 0.15 --test_size 0.15
Script would generate YOLO format dataset labels and images under different folders, for example,
/path/to/labelme_json_dir/YOLODataset/labels/train/
/path/to/labelme_json_dir/YOLODataset/labels/test/
/path/to/labelme_json_dir/YOLODataset/labels/val/
/path/to/labelme_json_dir/YOLODataset/images/train/
/path/to/labelme_json_dir/YOLODataset/images/test/
/path/to/labelme_json_dir/YOLODataset/images/val/
/path/to/labelme_json_dir/YOLODataset/dataset.yaml
If you already split train dataset and validation dataset for LabelMe by yourself, please put these folder under labelme_json_dir, for example,
/path/to/labelme_json_dir/train/
/path/to/labelme_json_dir/val/
Put all LabelMe JSON files under labelme_json_dir. Script would read train and validation dataset by folder. Run this python command.
labelme2yolo --json_dir /path/to/labelme_json_dir/
Script would generate YOLO format dataset labels and images under different folders, for example,
/path/to/labelme_json_dir/YOLODataset/labels/train/
/path/to/labelme_json_dir/YOLODataset/labels/val/
/path/to/labelme_json_dir/YOLODataset/images/train/
/path/to/labelme_json_dir/YOLODataset/images/val/
/path/to/labelme_json_dir/YOLODataset/dataset.yaml
Put LabelMe JSON file under labelme_json_dir. , and run this python command.
labelme2yolo --json_dir /path/to/labelme_json_dir/ --json_name 2.json
Script would generate YOLO format text label and image under labelme_json_dir, for example,
/path/to/labelme_json_dir/2.text
/path/to/labelme_json_dir/2.png
labelme2yolo
is distributed under the terms of the MIT license.