ultralytics / JSON2YOLO

Convert JSON annotations into YOLO format.
https://docs.ultralytics.com
GNU Affero General Public License v3.0
862 stars 232 forks source link

Code is running but the results are not are not saved #54

Open Aryanjb opened 1 year ago

Aryanjb commented 1 year ago

Thanks for your code, I'm trying to convert the keypooints.json file to Yolo format using your code in colab. The code runs fine and creating a new folder with images, labels but yolo format labels are not saved. Can you please let me know what is the issue. Thanks

ryouchinsa commented 1 year ago

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.

SadeghPouriyanZadeh commented 1 year ago

same here. it makes a new directory named "new_dir" and only create the directory structures in it. the problem is in this line: https://github.com/ultralytics/JSON2YOLO/blob/c38a43f342428849c75c103c6d060012a83b5392/general_json2yolo.py#L306

fn is a PathPosix and so f. but the problem is that at last the fn directory is the result of fn / f.

SadeghPouriyanZadeh commented 1 year ago

What about the images directory in the created directory called new_dir? There is no code to copy the source images to destination directory!

glenn-jocher commented 1 year ago

Thank you for pointing that out. The script currently handles the conversion of annotation files only. To copy the source images to the destination directory, simply use a file copy command to ensure both the image and label files are present in the new_dir directory.

ryouchinsa commented 11 months ago

Hi @SadeghPouriyanZadeh, please copy images by yourself. Do you have any other problems for annotations?

Mary14-design commented 7 months ago

I trien to convert the instances_train2017.json following the instructions but it returns nothing, empty directory new_dir/labels

glenn-jocher commented 7 months ago

@Mary14-design hi there! It sounds like there might be an issue with how the script is locating the JSON file or parsing its contents. Could you double-check the path to instances_train2017.json is correct and accessible in your script? Make sure the path exactly matches the directory structure where your JSON file is stored.

Additionally, verify that your JSON file is properly formatted and not empty. If the file and path are correct, try adding some print statements in the script to see if it's reading the file and entering the conversion loop.

If you're still facing issues, please provide more details such as the command you used to run the script, and we’ll be glad to assist further! 😊

ryouchinsa commented 7 months ago

Hi @Mary14-design, thanks for writing the issue.

スクリーンショット 2024-04-07 0 37 32