-
Notifications
You must be signed in to change notification settings - Fork 67
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
Issue with Exporting Polygon Annotations to YOLO Format #365
Comments
I've seen this issue before. When using an AI model for predictions, it's possible that some panels may have zero points, which leads to the error you're encountering. This happens because the polygons for those panels don't contain any points, and as a result, the code tries to process them and raises an error. To resolve this, you can add a condition to check if the polygon has points. If not, you can skip those labels by using a label-studio-sdk/src/label_studio_sdk/converter/converter.py Lines 922 to 927 in 114c2b3
Here’s a quick example of what that might look like: elif "polygonlabels" in label or "polygon" in label:
if 'points' not in label:
continue
points_abs = [(x / 100, y / 100) for x, y in label["points"]]
annotations.append(
[category_id]
+ [coord for point in points_abs for coord in point]
) This should prevent the error from occurring when there are polygons without points. Let me know if that works for you! I'll make a pull request for that and will inform you! |
@rezakarbasi |
@xtrementl @makseq @nick-skriabin |
Description:
Hi there,
I’m encountering an issue when exporting polygon annotations from Label Studio to YOLO format. My task involves labeling polygons around objects (in this case, solar panels), and when I attempt to export the annotations, I receive the following error:
KeyError: 'points'
It seems that the export process is looking for a
points
key, which is expected for bounding box annotations, but the annotations I have are polygons. The converter appears to be trying to process the polygon annotations as if they were bounding boxes, leading to the error.Here is a snippet of the labeling configuration used in my task:
Also, as you may guess from the above xml, I've made initial predictions for the images before start labeling.
Expected Behavior:
I am looking to export the annotations in YOLO format, which expects bounding boxes with coordinates normalized to the image size. The polygons should be converted into bounding boxes before exporting.
Current Behavior:
When exporting, the process fails because the export function tries to access the
points
key for polygons, but this key is not defined in the format expected for YOLO.Steps to Reproduce:
<PolygonLabels>
tag.KeyError: 'points' error
.I’ve attached a screenshot showing the issue in case it helps in diagnosing the problem.
Is there a way to handle polygon annotations properly when exporting to YOLO format? Or would I need to implement a custom conversion function to transform polygons into bounding boxes?
Thanks for your help!
The text was updated successfully, but these errors were encountered: