ultralytics / JSON2YOLO

Convert JSON annotations into YOLO format.

Home Page:https://docs.ultralytics.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to convert files annotated with linestrip in labelme to yolo

DJohn1211 opened this issue · comments

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

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

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.

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

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

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

thank you!!!

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

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

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!

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.

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! 😊