Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How can we use general_json2yolo #225

Closed
AISoltani opened this issue May 27, 2023 · 3 comments
Closed

How can we use general_json2yolo #225

AISoltani opened this issue May 27, 2023 · 3 comments

Comments

@AISoltani
Copy link

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
Copy link
Owner

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.
ultralytics/JSON2YOLO#45

@potSm0ker
Copy link

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

@ryouchinsa
Copy link
Owner

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants