ultralytics / JSON2YOLO

Convert JSON annotations into YOLO format.

Home Page:https://docs.ultralytics.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

An output directory should be added

monkeycc opened this issue · comments

An output directory should be added

Thanks for writing the issue.
We check it works using this script global_json2yolo.py.

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,

To convert the COCO segmentation format to YOLO segmentation format.

if __name__ == '__main__':
    source = 'COCO'

    if source == 'COCO':
        convert_coco_json('../datasets/coco/annotations',  # directory with *.json
                          use_segments=True,
                          use_keypoints=False,
                          cls91to80=False)

This is the folder structure when we run the script.

スクリーンショット 2023-10-25 20 51 05

Please let us know your opinion.

Thank you for sharing your insights and the use of the global_json2yolo.py script. It's great to see the different flags and options for converting COCO format to YOLO format.

Regarding your request for an output directory, it seems that the script currently does not have an explicit option to specify an output directory. If you need to save the converted YOLO files to a specific directory, you can modify the script to include this functionality. You can achieve this by adding a parameter to the convert_coco_json function to specify the output directory, then adjust the code to save the YOLO files to that directory.

Feel free to let me know if you need further assistance or guidance on how to implement this. We're always here to help.