ultralytics / JSON2YOLO

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

How to convert files annotated with linestrip in labelme to yolo #68

Open DJohn1211 opened 11 months ago

DJohn1211 commented 11 months ago

In normal circumstances, when we use rectangular boxes to label, we will obtain x1y1 and x2y2, convert the corresponding coordinates to cx cy w h. If I use linestrip to obtain the coordinate xy, how should I convert it to the corresponding coordinate. The corresponding image is as follows. label json

glenn-jocher commented 11 months ago

@DJohn1211 you can convert linestrip annotations from Labelme to YOLO format by calculating the bounding box coordinates from the linestrip points. The Ultralytics documentation at https://docs.ultralytics.com provides detailed instructions for this conversion. Let me know if you need further assistance!

DJohn1211 commented 11 months ago

Hi!I am very excited to receive your reply, but I still don't quite understand what you said about calculating the coordinates of the bounding box based on the underlined points. I couldn't find any relevant content in the website you provided. If you could give me an example of converting x1y1 x2y2 … xnyn to yolo, or could you please provide me with a file? I would greatly appreciate it. Finally, I look forward to your reply.

glenn-jocher commented 11 months ago

@DJohn1211 certainly! You can calculate the bounding box coordinates (x, y, width, height) from the linestrip points by finding the minimum and maximum x and y coordinates, and then computing the center and dimensions of the bounding box. Unfortunately, I'm not able to provide you with a specific file, but you can refer to the Ultralytics documentation for general conversion guidance. Let me know if you have further questions!

DJohn1211 commented 11 months ago

Thank you for taking the time to reply to my comment. I calculated using the bounding rectangle of the file labeled with linestrip as you said, and the result was very good. However, I have a little doubt. Can YOLOv8 recognize this line as I labeled it, and what should my xy label conversion be like? 1 label_viz

glenn-jocher commented 11 months ago

@DJohn1211 YOLOv8 should be able to recognize the line labels as you have annotated them. For the xy label conversion, you can use the center (cx, cy) and dimensions (width, height) of the bounding box calculated from the linestrip points. This should enable YOLOv8 to properly detect the line. Let me know if you have further inquiries or need assistance with anything else!

DJohn1211 commented 11 months ago

thank you!!!

glenn-jocher commented 11 months ago

@DJohn1211 you're welcome! If you have any more questions in the future, feel free to ask. Good luck with your project! 😊

hariouat commented 5 months ago

Hello, Please how to train yolov8 with Linestrip annotation? it's is like keypoint detection? thanks in advance

pderrenger commented 5 months ago

Hello! Training YOLOv8 with Linestrip annotations involves treating the linestrips as objects with bounding boxes. It's not exactly like keypoint detection, which typically involves predicting specific points. For Linestrip, you would define the bounding box around the entire strip. Ensure your annotations are converted to the YOLO format (center x, center y, width, height) as discussed earlier. If you need more specific guidance on setting up your training configuration, feel free to ask. Good luck!

hariouat commented 5 months ago

Hello! Training YOLOv8 with Linestrip annotations involves treating the linestrips as objects with bounding boxes. It's not exactly like keypoint detection, which typically involves predicting specific points. For Linestrip, you would define the bounding box around the entire strip. Ensure your annotations are converted to the YOLO format (center x, center y, width, height) as discussed earlier. If you need more specific guidance on setting up your training configuration, feel free to ask. Good luck!

Thank you for your reply.

What I did was convert the line strip into two points by taking the first point and the second point to train YOLOv8. Is this also correct? I also ensured that the two points are normalized. Thank you for your feedback.

pderrenger commented 5 months ago

Hello! Using just the first and last points of the linestrip to define a bounding box is a valid approach, especially if the line is relatively straight. Normalizing these points, as you've done, is crucial for maintaining consistency with the YOLO format. Keep in mind, however, that this method might not capture the full essence of more complex or curved linestrips. If your linestrips are generally straight, your method should work well. If you encounter more complex shapes, consider using the bounding box encompassing all points for better accuracy. Let me know if you need further assistance! 😊

DJohn1211 commented 2 months ago

您好,请问如何使用 Linestrip 注释训练 yolov8?这就像关键点检测?提前致谢

Hello, Please how to train yolov8 with Linestrip annotation? it's is like keypoint detection? thanks in advance

Hi,I think you can use labelme or labelme with sam (segment anything model). And then, you can convert absolute coordinates to relative coordinates. YOLOv8 could be trained with these coordinates.

glenn-jocher commented 2 months ago

@DJohn1211 hello, to train YOLOv8 with Linestrip annotations, convert the linestrip to bounding boxes and use the YOLO format (center x, center y, width, height). This approach differs from keypoint detection. Ensure your annotations are correctly formatted and normalized. If you need further assistance, feel free to ask.

DJohn1211 commented 2 months ago

thanks,man!!!

glenn-jocher commented 2 months ago

You're welcome! If you have any more questions or need further assistance, feel free to ask.