Mask_rcnn: Error when training on custom dataset

Created on 8 Aug 2018  路  4Comments  路  Source: matterport/Mask_RCNN

This error happens when I tried to use the pre-trained model to perform inference mode on my custom dataset.

Traceback (most recent call last):
  File "inference.py", line 181, in <module>
    r["rois"], r["class_ids"], r["scores"], r['masks'])
  File "/home/jil20/anaconda2/envs/py36/lib/python3.6/site-packages/mask_rcnn-2.1-py3.6.egg/mrcnn/utils.py", line 739, in compute_ap
  File "/home/jil20/anaconda2/envs/py36/lib/python3.6/site-packages/mask_rcnn-2.1-py3.6.egg/mrcnn/utils.py", line 691, in compute_matches
  File "/home/jil20/anaconda2/envs/py36/lib/python3.6/site-packages/mask_rcnn-2.1-py3.6.egg/mrcnn/utils.py", line 107, in compute_overlaps_masks
  File "/home/jil20/anaconda2/envs/py36/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 257, in reshape
    return _wrapfunc(a, 'reshape', newshape, order=order)
  File "/home/jil20/anaconda2/envs/py36/lib/python3.6/site-packages/numpy/core/fromnumeric.py", line 52, in _wrapfunc
    return getattr(obj, method)(*args, **kwds)
ValueError: cannot reshape array of size 0 into shape (0)

Anyone knows how to solve this?

Most helpful comment

@abegehr That simply just means the prediction is an empty list. The solution is to improve your model to predict something on the image.
@kevinisbest For your case, just simply remove the all False images in predicting. If your model predicts nothing in an image with labels, again you need to tune your model to improve the accuracy.

All 4 comments

I have looked into the output and find out that the predicted result of the model.detect() function is an empty list. Does anyone know why would that happen?

I am using a similar structure as the example in train_shapes.ipynb. The shapes sample works well.
Thanks for this good implementation here.

Hi @JiayingLi , did you solve the problem?
In my case, there are two class: object A + background.
The training data contains some all False images (background images) and some label images.
After prediction, if it predicted no instances to display, the mask shape will be (w, h, 0) and got the same error.

hey I have the same problem. how can we fix this?

@abegehr That simply just means the prediction is an empty list. The solution is to improve your model to predict something on the image.
@kevinisbest For your case, just simply remove the all False images in predicting. If your model predicts nothing in an image with labels, again you need to tune your model to improve the accuracy.

Was this page helpful?
0 / 5 - 0 ratings