Open MjdMahasneh opened 1 year ago
You've chosen to report an unexpected problem or bug. Unless you already know the root cause of it, please include details about it by filling the issue template. The following information is missing: "Your Environment";
issue description:
I have segmentation labels of some plants that are in the form of contours (extracted using image processing/morphological operations).
My target task is to train a Mask RCNN model using these labels.
Accordingly, I convert them to RLE (or even use them as polygons), and visualize them before training to make sure the conversion was fine.
The problem is that when visualizing the masks (see images attached below), I notice that holes in the mask are being treated /colored/labeled as foreground (target class) while they should have been treated as background pixels.
I tried using polygons instead, taking parent/child relations into consideration when sorting, I also tried with binary masks fed directly and noticed no difference, they all caused the same issue.
Instructions To Reproduce the 🐛 Bug:
imports and set up checks.
data prep
register data
Visualize some data
Your Environment:
Expected behavior:
the expected behavior is to convert the binary mask to the expected training/testing format while maintaining the correct labeling provided in the input labels.
This behavior is not only when using RLEs, I have extensively experienced with all possible formats, i.e., polygons (with respect to the hierarchy of polygons, parents first and child follow, and so on, as well as binary masks nd.arrays). Below is an example of the RLE vs Binary Mask provided as input for binary_mask_to_rle(binary_mask) in my get_data_dicsts() function.
Binary mask as visualized in plt.imshow(binary_mask) :
RLE as visualized in cv2_imshow(out.get_image()[:, :, ::-1])