-
-
Notifications
You must be signed in to change notification settings - Fork 16.3k
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
How to convert segment json data labeled by labelme to yolo format? #12841
Comments
@fewshotstudy hello! 😊 Converting label formats is a common task. While we don't have a direct feature in YOLOv5 for converting LabelMe JSON to YOLO format, the general process involves parsing the JSON file to extract bounding box coordinates and then saving them in the YOLO format. Here's a simplified code outline to get you started: import json
def convert_labelme_to_yolo(json_path, output_path):
with open(json_path) as f:
data = json.load(f)
# Assuming one object per file for simplicity
width, height = data['imageWidth'], data['imageHeight']
for shape in data['shapes']:
label = shape['label']
points = shape['points'] # Assuming rectangle: top-left and bottom-right
x1, y1 = points[0]
x2, y2 = points[1]
# Convert to YOLO format
x_center = (x1 + x2) / 2 / width
y_center = (y1 + y2) / 2 / height
w = abs(x2 - x1) / width
h = abs(y2 - y1) / height
# Save to file
with open(output_path, 'a') as f:
f.write(f'{label} {x_center} {y_center} {w} {h}\n')
# Example usage
convert_labelme_to_yolo('path/to/your/labelme.json', 'path/to/output.txt') Please adjust the code to your specific needs, especially if you have multiple objects per image or other shape types. Happy coding! 🚀 |
Thank you.Sir! |
Fantastic news, @fewshotstudy! 😊 Great to hear you've achieved what you set out to do. If you have more questions or need further assistance down the road, feel free to reach out. Happy developing with YOLOv5! 🚀 |
👋 Hello there! We wanted to give you a friendly reminder that this issue has not had any recent activity and may be closed soon, but don't worry - you can always reopen it if needed. If you still have any questions or concerns, please feel free to let us know how we can help. For additional resources and information, please see the links below:
Feel free to inform us of any other issues you discover or feature requests that come to mind in the future. Pull Requests (PRs) are also always welcomed! Thank you for your contributions to YOLO 🚀 and Vision AI ⭐ |
Search before asking
Question
How to convert segment json data labeled by labelme to yolo format?
Can you share some details code?
Additional
No response
The text was updated successfully, but these errors were encountered: