Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Segmentation mask generated contains strings and letters at count keyword #471

Closed
akshitac8 opened this issue Feb 20, 2019 · 10 comments
Closed

Comments

@akshitac8
Copy link

At evaluation time, The segmentation json file generated contains buffered strings and letters at count keyword.
Example:

{'size': [800, 800], 'counts': b'coa;<1E_h0b0M0O2O000O10000000000000001OO1000000000000000000000000000O1000000000000000000000000001O0000001N1000001O00001N101O0O1O2O2K]b^6'}

@akshitac8
Copy link
Author

I followed the code given at #150 But then I got

if not isinstance(segms[0], (list, Polygons)):
IndexError: list index out of range

@fmassa
Copy link
Contributor

fmassa commented Feb 21, 2019

Hi,

I suppose you managed to fix the issue?
You were checking the rle encoding of the mask, instead of the polygons. Those are generally the encodings for crowd categories

@Jinksi
Copy link

Jinksi commented Apr 3, 2019

On this topic, how do I extract polygon data after eval?
segm.json contains counts but no polygon.
Am I missing something?

@shaayaansayed
Copy link

+1, does segm.json not store the polygon/mask prediction?

@shaayaansayed
Copy link

@Jinksi you can use this to decode RLE string to mask:
https://github.com/cocodataset/cocoapi/blob/master/PythonAPI/pycocotools/mask.py#L87

pass in the dict stored in the segmentation key

@Jinksi
Copy link

Jinksi commented Apr 5, 2019

@shaayaansayed Good one, thanks.
I combined this with @jsbroks imantics to convert the decoded mask to a segmentation polygon:

from imantics import Mask
def maskToPolygon(mask):
    polygons = Mask(mask).polygons()
    return polygons.segmentation

It could be good to add this to segm.json by default, but it adds to filesize.

@jsbroks
Copy link

jsbroks commented Apr 5, 2019

Another way to do this:

from imantics import Polygons
def maskToPolygon(mask):
    return Polygons.from_mask(mask).segmentation

both do the same thing, just though I would share.

@Jinksi If you would like RLE support added to the library, post a feature request under the issues

@AmberHen
Copy link

Is your problem solved? I have the same problem.

@wangg12
Copy link
Contributor

wangg12 commented May 16, 2019

Binary mask to polygons can not guarantee correctness by naively finding contours.

For example, a donut-like mask: binary mask --> polygons(contours) --> binary mask(decode), the hole in the mask will disappear.

Thus I would recommend not to convert any of binary mask or RLE back to polygons.

@AmberHen
Copy link

Binary mask to polygons can not guarantee correctness by naively finding contours.

For example, a donut-like mask: binary mask --> polygons(contours) --> binary mask(decode), the hole in the mask will disappear.

Thus I would recommend not to convert any of binary mask or RLE back to polygons.

你好 我在inference里输出来的counts和上边一样 我应该怎么把这些轮廓线画到原图上 这样直观地看到分割的效果。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants