JSON2YOLO icon indicating copy to clipboard operation
JSON2YOLO copied to clipboard

TypeError: string indices must be integers

Open potSm0ker opened this issue 2 years ago • 5 comments

Trying to run script labelbox_Json2yolo.py. I am getting error line 22, in convert im_path = img['Labeled Data'] TypeError: string indices must be integers

It creates a directory with the name of my json file and two sub directories - images and labels. Then i get the error. all i did was change the bottom line to the path of my json file.

potSm0ker avatar Aug 21 '23 17:08 potSm0ker

these scripts dont work, ive been trying for hours.

potSm0ker avatar Aug 21 '23 21:08 potSm0ker

so how have you solved your problem? i want to convert my coco.json file to yolov8 format for segmentation.

HawkingRadiation42 avatar Sep 22 '23 10:09 HawkingRadiation42

I understand your frustration, and I'm here to help. To address the "string indices must be integers" error, this typically occurs when trying to access a dictionary key using a string when the value is expected to be an integer. In the provided error, it seems that you are attempting to access a key in a dictionary using a string, but the key actually requires an integer index. You'll need to review the specific code at line 22 and ensure that you are accessing the dictionary correctly.

Regarding your requirement to convert a COCO JSON file to YOLOv8 format for segmentation, the Ultralytics YOLO repositories offer tools like coco2yolo.py which can be used for this purpose. However, it's worth noting that direct segmentation support in YOLOv8 is currently under development in the latest YOLOv5. If you're looking for segmentation capabilities, I would recommend exploring YOLOv5 or other segmentation-specific tools.

Feel free to ask for further clarification or assistance with any specific issues you encounter during this process.

glenn-jocher avatar Nov 09 '23 18:11 glenn-jocher

any updates on this?

freds-dev avatar Nov 15 '23 13:11 freds-dev

@freds-dev i can understand your frustration, and I assure you I am committed to helping you resolve the issue. To address the "string indices must be integers" error you encountered, please ensure that you are accessing the dictionary correctly at the specific line mentioned in the error. If you need further assistance with this, please provide more details about the code segment causing the error, and I will be glad to offer additional guidance.

Regarding the COCO JSON to YOLOv8 format conversion for segmentation, as of now, direct segmentation support is under active development in the latest YOLOv5. While YOLOv8 is an advancement of YOLOv5, I recommend exploring YOLOv5 or other specialized tools for your segmentation requirements. If you'd like further assistance with any specific aspect of this process, feel free to ask, and I'd be happy to help.

glenn-jocher avatar Nov 16 '23 17:11 glenn-jocher