Mask_rcnn: minimize_mask in utils.py returns wrong values

Created on 27 Mar 2018  路  11Comments  路  Source: matterport/Mask_RCNN

The mini mask is converted to all zeros(False) on the scipy imresize function when the mask contains only 1's.(ie., if the bounding box rectangle doesn't contain even one background pixel).

m = scipy.misc.imresize(m.astype(float), mini_shape, interp='bilinear')
mini_mask[:, :, i] = np.where(m >= 255, 1, 0)

Most helpful comment

Please try the latest update as of 15 minutes ago. There was a separate thread that identified a bug in skimage.transform.resize. I don't know if it's related, but it happened around the same time so maybe it is.

Also, I just ran the latest code on colab, and I do see masks in the train_shapes notebook. Please let me know if this is still an issue for you.

All 11 comments

@AravindhKuppusamy good finding! But will it be possible that there is no bg pixel in bounding box? In this case, the mask is a rectangle which is the bounding box, right?

I've seen someone proposed a fix in one of the issues, but cannot find a reference to it. Simply replace the line with the following:
m = scipy.misc.imresize(m.astype(float)*255, mini_shape, interp='bilinear', mode='F')
mini_mask[:, :, i] = np.where(m >= 128, 1, 0)

You will probably need to change the them in expand_mask as well

Just pushed a fix for this issue. I'm closing it, but please let me know if you still encounter an edge case that I might've missed.

@waleedka: i think it has some bug in somewhere because i used it and got stop program during training. I reported in the other thread

I am still facing the same problem even with skimage transform resize function. Still getting 0s if the mask covers entire bounding box!

Okay, reopening this then. I can't reproduce the problem on my end, so can someone send me a stack trace that shows the error?

Now, none of the mini-masks contain any class pixels other than background after the push. You can just try running inspect_data.ipynb file. In the part "add augmentation and mask resizing", you wont see any mask associated with class.

I have exactly the same issue, I will post here if I find the reason

Please try the latest update as of 15 minutes ago. There was a separate thread that identified a bug in skimage.transform.resize. I don't know if it's related, but it happened around the same time so maybe it is.

Also, I just ran the latest code on colab, and I do see masks in the train_shapes notebook. Please let me know if this is still an issue for you.

@waleedka I think it has to do with the need for preserve_range=True in the skimage.transform.resize call. From https://github.com/scikit-image/scikit-image/issues/2702

PS: I am on

>>> skimage.__version__
'0.13.1'

I think we addressed two issues here. The original at the top, about rectangular masks being zeros, which was fixed (see my first comment above). Then there was a side effect mentioned later and it was fixed as well in a later commit.

So my understanding is that this issue is fixed. If there is still a problem, it's likely to be a different one than the ones addressed here, and I would prefer to track it in a separate issue. So I'm closing this and will monitor other issues in case there are still edge cases we missed.

Was this page helpful?
0 / 5 - 0 ratings