ryouchinsa / Rectlabel-support

RectLabel is an offline image annotation tool for object detection and segmentation.
https://rectlabel.com
504 stars 73 forks source link

How can we use general_json2yolo #225

Closed AISoltani closed 11 months ago

AISoltani commented 1 year ago

Hey Guys. can anyone tell me how can i use this method?

from colab i import my data contain of 1000 photos with 1 JSON file which is their label, i address the path to my json but when i run global_json2yolo, It creates a folder with name new_dir for me that is empty. what's wrong? how can i fix? i have single json for all these 1000 images how can i convert it to use on yolov8 segment?

ryouchinsa commented 1 year ago

Thanks for writing the issue.

Looking at the global_json2yolo code, there are some flags. Converting the COCO bbox format to YOLO bbox format.

use_segments=False,
use_keypoints=False,

Converting the COCO segmentation format to YOLO segmentation format.

use_segments=True,
use_keypoints=False,

Converting the COCO keypoints format to YOLO keypoints format.

use_segments=False,
use_keypoints=True,

This code originates from Ultralytics JSON2YOLO repository. https://github.com/ultralytics/JSON2YOLO/issues/45

potSm0ker commented 1 year ago

this code creates three empty directories when i run it, not very helpful.

ryouchinsa commented 11 months ago

Thanks for writing the issue. The converted YOLO txt files are saved in new_dir/labels/coco_filename directory.

スクリーンショット 2023-09-05 5 48 13

You can customize the folder structure editing save_dir and fn.

def convert_coco_json(json_dir='../coco/annotations/', use_segments=False, use_keypoints=False, cls91to80=False):
    save_dir = make_dirs()  # output directory
    coco80 = coco91_to_coco80_class()

    # Import json
    for json_file in sorted(Path(json_dir).resolve().glob('*.json')):
        fn = Path(save_dir) / 'labels' / json_file.stem.replace('instances_', '')  # folder name
        fn.mkdir()

If you have further questions, please write an issue in the original repository. https://github.com/ultralytics/JSON2YOLO