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

TypeError: string indices must be integers #55

Open potSm0ker opened 1 year ago

potSm0ker commented 1 year ago

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 commented 1 year ago

these scripts dont work, ive been trying for hours.

HawkingRadiation42 commented 1 year ago

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

glenn-jocher commented 1 year ago

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.

freds-dev commented 12 months ago

any updates on this?

glenn-jocher commented 12 months ago

@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.