dmlc / gluon-cv

Gluon CV Toolkit
http://gluon-cv.mxnet.io
Apache License 2.0
5.79k stars 1.21k forks source link

plot_mask() method failing when expand_mask() returns mask with just one object. #1754

Closed sunny2309 closed 1 year ago

sunny2309 commented 1 year ago

Hello MXNet Team,

I was recently trying Image segmentation (instance segmentation) using Pre-trained models available through BluonCV.

I used a simple image with just a panda (https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/Giant_Panda_2004-03-2.jpg/1200px-Giant_Panda_2004-03-2.jpg) in it.

I used "mask_rcnn_resnet101_v1d_coco" model for Instance segmentation. It works fine and detects one object which is pandas.

After that, I used expand_mask() method from viz utils to expand masks. It works fine.

But when I call plot_mask() method with an output of expand_mask() which has only one object (panda) in our case, it fails with an array indexing error.

IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

The method works fine when the image has more than one object detected. It fails only when it has just one object detected.

I simply repeated the same mask twice by using the mxnet stack() method and then the repeated mask worked fine with plot_mask() method.

panda_masks_mod = mxnet.nd.stack(mxnet.nd.array(panda_masks_mod), mxnet.nd.array(panda_masks_mod), axis=1)

Regards, Sunny

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.