Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

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

Open
Aryanjb opened this issue Aug 19, 2023 · 8 comments
Open

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

Aryanjb opened this issue Aug 19, 2023 · 8 comments

Comments

@Aryanjb
Copy link

Aryanjb commented Aug 19, 2023

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

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

SadeghPouriyanZadeh commented Nov 1, 2023

same here. it makes a new directory named "new_dir" and only create the directory structures in it. the problem is in this line:

with open((fn / f).with_suffix('.txt'), 'a') as file:

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

@SadeghPouriyanZadeh
Copy link

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

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

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

@Mary14-design
Copy link

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

@glenn-jocher
Copy link
Member

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

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

  • Using this script global_json2yolo.py.
  • The folder structure is below.
  • Run the script python general_json2yolo.py from the JSON2YOLO folder.
  • You can obtain the converted YOLO text files in the train2017 folder.

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

@ultralytics ultralytics deleted a comment from pderrenger Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants