open-mmlab / mmdetection

OpenMMLab Detection Toolbox and Benchmark
https://mmdetection.readthedocs.io
Apache License 2.0
29.56k stars 9.46k forks source link

Details about BitmapMasks & PolygonMasks #7292

Closed levan92 closed 2 years ago

levan92 commented 2 years ago

Hi! I'm implementing a custom pipeline that will require me to modify the gt_masks. I have some implementation questions that I'll need some advice for.

In order to append to the existing set of masks, is the best way to convert the current gt_masks to ndarray, concatenate the new masks, then reinstantiate a new BitmapMasks object with the resulting matrix?

hhaAndroid commented 2 years ago

@levan92 Do you want to define a new data processing pipeline or just modify gt_mask? To speed up training, we recommend PolygonMasks.

levan92 commented 2 years ago

Thanks for your prompt reply! I am implementing a new augmentation pipeline, in which I will need to add new masks and modify the gt_masks, before returning the results in __call__

To speed up training, we recommend PolygonMasks.

From what I understand, LoadAnnotations converts it to BitmapMasks by default right? Since poly2mask of LoadAnnotation is True by default.

Edit: Okay, I noticed that in common/mstrain-poly_3x_coco_instance.py, poly2mask is flagged to False. However, in my custom augmentation pipeline, I require to do certain mask operations in bitmap/ndarray format. Would you recommend to convert it back to PolygonMasks using extra conversion steps similar to this or would you say I'm better off leaving it in Bitmap format?

ZwwWayne commented 2 years ago

Thanks for your prompt reply! I am implementing a new augmentation pipeline, in which I will need to add new masks and modify the gt_masks, before returning the results in __call__

To speed up training, we recommend PolygonMasks.

From what I understand, LoadAnnotations converts it to BitmapMasks by default right? Since poly2mask of LoadAnnotation is True by default.

Edit: Okay, I noticed that in common/mstrain-poly_3x_coco_instance.py, poly2mask is flagged to False. However, in my custom augmentation pipeline, I require to do certain mask operations in bitmap/ndarray format. Would you recommend to convert it back to PolygonMasks using extra conversion steps similar to this or would you say I'm better off leaving it in Bitmap format?

The config is just an example, it uses polymask because sometimes it is faster. You can simply set poly2mask to True and process the bitmap masks in your pipeline.