Skip to content
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

Support for EncodedRLE in COCO Dataset #1165

Open
gatordevin opened this issue Dec 29, 2022 · 1 comment
Open

Support for EncodedRLE in COCO Dataset #1165

gatordevin opened this issue Dec 29, 2022 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@gatordevin
Copy link

🚀 Feature

Current problem
I have a COCO Dataset that is storing segmentation data in the following format.

"annotations": [
      {
         "segmentation": {
            "size": [
               512,
               512
            ],
            "counts": "X]h45f?4M202O1N3N1O01N101O1Oe@HP?7n@No>d0N1O1O2N1N2O1O1N2N1N3M2M3lA^Nh=d1UBbNf=a1XBbNd=`1[BaNd=`1[BaNd=`1[BbNc=n1O1O1O1O1O1O001O1O1O1O10O01O001O1O001O1O1O^MmBY2R=;O1O10XMPC`2o<9O1O1O1O101N1O100O10O0100O01O1N2M2O2O1O100O100O010O1O10O0100O1O1H8K5N2O1N3O101PNWBe1k=WN_BQ1GXO[>JhA4L05NY>JmA1J33MT?1nSe1"
         },
         "area": 11312,
         "iscrowd": 1,
         "image_id": 2,
         "bbox": [
            304,
            351,
            101,
            112
         ],
         "keypoints": [],
         "num_keypoints": 0,
         "category_id": 2,
         "id": 0
      }, ...

It is clear from this that the count value is being stored as an encoded RLE rather than a normal RLE, as ice vision seems to be assuming.

Best Solution
I think the best solution to this problem is to add a check in the COCODatasetParser that determines whether the data being passed in is in the encoded RLE format or just normal RLE format. I understand right now that iscrowd is used to determine whether it is RLE information or just polygon information. I also think this approach is slightly hacky because plenty of COCODatasets arent necessarily storing crowd segmentation data but still use RLE due to the data size advantages. It would be great if this could be detected automatically which I think is pretty reasonable.

For Polygons you can check wether segmentation is a dict of information or just an array. If it is just an array then that means it is stored as polygon data.

For RLE data you can check if it is a dict and if the count's value contains a list of ints then you know it is standard RLE.

For Encoded RLE Data you can check if the information in counts is a String and if it is then you can just immediately provide the Encoded RLE.

Alternative Solutions

  1. I can most likely modify this before going into icevision by decoding the dataset and using just normal RLEs but that seems like a roundabout way.
  2. I can also change to simply using polygons rather than RLE.
    Both of these solutions require modifying my existing dataset rather than just adding support.
@gatordevin gatordevin added enhancement New feature or request help wanted Extra attention is needed labels Dec 29, 2022
@gatordevin
Copy link
Author

I wrote a pull request for this issue.
#1166
It may also be worth the effort to write some COCOParser test cases for the various formats COCODatasets can take on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant