-
-
Notifications
You must be signed in to change notification settings - Fork 235
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
Convert the COCO RLE format to YOLOv5/v8 segmentation format. #38
Comments
Hi @ryouchinsa, I noticed you are approximating the contour in a different way than this answer here - cocodataset/cocoapi#476 (comment) Why are you using this:
instead of this, which produces significantly more polygon vertices/coordinates
I'm not saying your approach is wrong. I'm just curious if you chose a faster (but less accurate) method for your application, rather than a slower but more accurate method, or whether I'm misunderstanding something. Thanks. |
Thanks for the detailed feedback. If we combine findContours() and approxPolyDP(), we can decrease the number of polygon points from 500 points to 50 points, for example. |
Thanks for the detailed feedback. We chose to use a combination of findContours() and approxPolyDP() to reduce the number of polygon points, optimizing for a decrease from 500 points to around 50. This approach balances accuracy with efficiency, ensuring a manageable number of points while retaining the essential shape of the mask. If preserving the mask shape as closely as possible during training is a priority, it's not necessary to use approxPolyDP(). |
Using the script general_json2yolo.py, you can convert the RLE mask with holes to the YOLO segmentation format. The RLE mask is converted to a parent polygon and a child polygon using
The RLE mask. The converted YOLO segmentation format. To run the script, put the COCO JSON file coco_train.json into Edit use_segments and use_keypoints in the script.
To convert the COCO bbox format to YOLO bbox format.
To convert the COCO segmentation format to YOLO segmentation format.
To convert the COCO keypoints format to YOLO keypoints format.
This script originates from Ultralytics JSON2YOLO repository. |
@ryouchinsa thanks for sharing the updated script and examples of the RLE mask and the converted YOLO segmentation format. Your efforts to enhance the functionality of the script are much appreciated. It's great to see the improvements you've made and how they translate into the YOLO segmentation format. Good job! |
We updated the general_json2yolo.py script so that the RLE mask with holes are converted to YOLO segmentation format. We believe that this script would be beneficial for your company and users. |
@ryouchinsa thank you for the update and for considering our input. We appreciate your effort in enhancing the script to accommodate RLE masks with holes. We will review the script and provide feedback as soon as possible. Keep up the great work! |
Thanks for reviewing our script. Donut images and YOLO segmentation text files to confirm that YOLO can train polygon masks with holes. |
@ryouchinsa thank you for sharing the donut images and YOLO segmentation text files. We'll take a look and confirm that the YOLO model can effectively train polygon masks with holes using this dataset. Your contribution is valuable, and we appreciate your efforts in enhancing the YOLO functionality. |
Hi @glenn-jocher, I submitted the PR about this update. Please let us know if there are any problems in the PR. |
@ryouchinsa thanks for submitting the PR. I will review it and get back to you if there are any issues. Appreciate your contribution! |
Hi @ryouchinsa , my question is also similar with others. But I have labeled image like below: { I couldn't find any sources to convert its mask to yolo format |
Hi @Harry-KIT, |
Hi @ryouchinsa, Than you very much |
Hi @ryouchinsa , |
Hi @4o3F, thanks for your detailed feedback. You mean that converting RLE masks with "iscrowd": 1 to YOLO format might decrease the segmentation accuracy, correct? But, another user told us that RLE masks with "iscrowd": 1 are necessary to convert from COCO to YOLO format. "I am trying to convert the COCO1.0 annotation files generated in CVAT to Yolo format. The COCO json file created consists of segmentation masks in RLE format therefore 'iscrowd' variable is True across all annotations." So, We added skip_iscrowd_1 flag to the Set skip_iscrowd_1=True. Set skip_iscrowd_1=False. |
Hi @ryouchinsa, thanks for bringing this to our attention! 👍 Indeed, handling RLE masks with For datasets where Each approach has its use case, depending on the goal of your model. If incorrect merging is a concern in your context, I recommend experimenting with the flag to see which setting fits your needs best. Your feedback and further observations on this would be highly appreciated! |
Thanks! This indeed fixed the problem |
Hi @4o3F, I’m thrilled to hear that! 🎉 Your feedback has been incredibly helpful in refining our approach to handling |
Hi @glenn-jocher,
When did you add this to the JSON2YOLO repo ? |
Hi, thanks for your useful script.
We added rle2polygon() to general_json2yolo.py so that you can convert the COCO RLE format to YOLOv5/v8 segmentation format. Please let us know your opinion.
https://github.com/ryouchinsa/Rectlabel-support/blob/master/general_json2yolo.py
The text was updated successfully, but these errors were encountered: