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

Convert binary mask to polygon #381

Closed
IssamLaradji opened this issue Jan 24, 2019 · 6 comments
Closed

Convert binary mask to polygon #381

IssamLaradji opened this issue Jan 24, 2019 · 6 comments

Comments

@IssamLaradji
Copy link

❓ Questions and Help

Is there a function that allows me to convert binary masks to polygons? this would help in training the model on new datasets that come with polygons like COCO.

Thanks!

@fmassa
Copy link
Contributor

fmassa commented Jan 24, 2019

Hi,

I don't think it would be that easy to get a reasonable to convert binary masks to polygon.
It might be simpler to try out using support for binary masks as discussed in #256

They seem to have managed to make it work with a few changes to #150

I'm closing this issue as I think it's in this case better to have straight support for binary masks, but let me know if you think otherwise.

@fmassa fmassa closed this as completed Jan 24, 2019
@IssamLaradji
Copy link
Author

IssamLaradji commented Jan 24, 2019

Thanks for the reply.
Aren't polygons and RLE less expensive to operate on than binary masks (unless it's sparse binary mask)? I think the pycocotools evaluation expects polygons/rle to compute the AP scores, right?

@IssamLaradji
Copy link
Author

Lines 132-151 in https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/maskrcnn_benchmark/data/datasets/evaluation/coco/coco_eval.py show that the binary masks are converted to RLE for evaluation. It seems that the pycocotools has much better support for rle than polygons as the encode and decode functions seamlessly convert the binary mask to rle format and vice versa.

@fmassa
Copy link
Contributor

fmassa commented Jan 24, 2019

@IssamLaradji the problem is that performing any operations on RLE is very complicated, and the easiest approach is to simply convert to a binary mask, apply the transformation and convert back to RLE.

Thus, speed-wise I don't think it would be relevant to support RLE except if we spend some significant efforts writing methods that operate directly on RLE.

@IssamLaradji
Copy link
Author

@fmassa makes sense!

@txytju
Copy link

txytju commented Feb 6, 2019

Thanks for the reply.
Aren't polygons and RLE less expensive to operate on than binary masks (unless it's sparse binary mask)? I think the pycocotools evaluation expects polygons/rle to compute the AP scores, right?

@IssamLaradji In my case, instance masks may have holes, so you can not use polygons and binary mask is the only way. And binary mask do use more GPU memory.

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

3 participants