-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Is there a way to save a Dataset natively, without polygon conversions? #373
Comments
Hello there, thank you for opening an Issue ! 🙏🏻 The team was notified and they will get back to you asap. |
Hi, @thomasf1 👋🏻 Sounds interesting. Have you perhaps already thought about the structure of such a dataset? Would each mask be stored as a separate black-and-white photo? How would you store information about the class to which an object with a given mask belongs? |
Well, there is already a standard/solution for coco that´s somehow not being used by roboflow: RLE (_frString) Also, not supporting masks causes other issues: When converting to Polygons, cutouts in masks seem often to be converted as a separate polygon. Example: A person having this arms on his hips. The triangle shape inside the arms isn´t part of the person, but surrounded by it. The way supervisions translates that into polygons is as follows:
(not sure if that qualifies as a BUG or is somehow intended behaviour?) |
@SkalskiP There is some code here that should get you far: https://github.com/waspinator/pycococreator/blob/master/pycococreatortools/pycococreatortools.py Also, in binary_mask_to_polygon, they seem to add some padding to avoid a problem supervision (and the roboflow app smart polygon) has: Creating polygons that reach to the image edges. Unfortunately, most polygons leave a 1+ px gap from the edge of the image when the masked subject goes beyond the edge of the image. |
In an Ideal world, both roboflow.com and supervision would use both masks and polygons and decide intelligently which one to use. For instance segmentation:
Polygons for everything else (maybe configureable) |
@SkalskiP What do you think? |
@thomasf1 agree! Expanding COCO annotations format support is the easiest way to unlock that capability. |
Would you need any help with it? |
@thomasf1 I opened an issue specifically for this hole preservation matter. I also built an exporter that deals with almost everything that you said above, You can find it here. |
@MihaiDavid05 Great :) One thing I could not quite work out from the ReadMe:
So, the way it works is |
@thomasf1 Yes, that's true, from Image/PNG format to Coco Masks (rle or polygons) annotations. It supports instance segmentation, therefore multiple classes and multiple instances of the same class in an image. I will update the readme! |
@MihaiDavid05 Out of curiosity, what tool did you use to generate the masks? We´re currently using hasty.ai which only allows a png masks for "Semantic Segmentation (png)". I guess using the image mask format for instance segmentation would be quite difficult... |
@thomasf1 Hi, I did not understand your question. Which generated masks are you talking about? |
@MihaiDavid05 Sorry, I meant which tool do you use to annotate your data and in turn export that as mask images... |
@thomasf1, oh, I see. Currently, I'm only using already annotated base datasets, so I'm not using any tool to annotate raw images :) I might look into that! |
We updated a script to convert the RLE mask with holes to the YOLO segmentation format. |
Hi, @ryouchinsa! 👋🏻 Does the YOLO format support masks with holes? |
Hi, @SkalskiP, 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. |
Thanks for reviewing our script. Donut images and YOLO segmentation text files to confirm that YOLO can train polygon masks with holes. |
Thanks @ryouchinsa. Having a look currently and it seems to work great :) |
Hi, @ryouchinsa 👋🏻 Thanks a lot for that! 🙏🏻 Making that doable with Supervision is definitely on our roadmap. We simply do not have enough capacity to take care of it now. If any of you would like to help us out an contribute, I would be really grateful. |
@SkalskiP @ryouchinsa I´ve tested the code and incorporated it into supervision. Working on a PR. |
Added the PR (excuse the sample image): #630 |
Hi @SkalskiP, I am sorry for late reply. I was working on the PR for ultralytics/JSON2YOLO. Hi @thomasf1, thanks for implementing my code onto supervision. I will read and check with my dataset. |
I am trying to implement features which are implemented on JSON2YOLO. Does supervision correspond to multiple polygons in the COCO format?
COCO file with multiple polygons.
The script which converts COCO to YOLO using supervision.
|
We just opened a new issue #1114 where we proposed adding RLE support to Supervision datasets. To keep it clean and prevent duplications, I'm closing this issue. Also, if any of you would be willing to help us out with implementation, let us know! 🙏🏻 |
@ryouchinsa we do not support disjointed masks for now, but we are actually working on the PR that may add this #1086 |
Search before asking
Question
Is there a way to save a Dataset natively, without polygon conversions? Would be great If there would be a way to save the dataset with the masks as a zip, all save formats (coco, yolo, voc) do some processing. Ideally there would be a way to natively save a dataset (maybe as a ZIP file).
My usecase is experimenting to get the polygon conversion when saving as yolo after a run just right and writing some custom code for it, so it would be helpful to have the "raw" state with the masks saved somewhere.
Additional
I might just have overlooked some obvious way of saving the dataset... Otherwise it is a feature request I guess.
The text was updated successfully, but these errors were encountered: