Mask_RCNN icon indicating copy to clipboard operation
Mask_RCNN copied to clipboard

Error when training on custom dataset

Open JiayingLi opened this issue 6 years ago • 7 comments

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?

JiayingLi avatar Aug 08 '18 20:08 JiayingLi

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.

JiayingLi avatar Aug 09 '18 21:08 JiayingLi

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.

kevinisbest avatar Oct 11 '18 06:10 kevinisbest

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

abegehr avatar Oct 22 '18 20:10 abegehr

@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.

JiayingLi avatar Oct 23 '18 14:10 JiayingLi

@JiayingLi I still have problems with the balloon sample file. Is there any other possibility?

mkz0128 avatar Jun 27 '21 13:06 mkz0128

@kevinisbest @abegehr Can you fix it?

mkz0128 avatar Jun 27 '21 13:06 mkz0128

@mkz0128 @JiayingLi @kevinisbest Try to set DETECTION_MIN_CONFIDENCE value like this. class PredictionConfig(Config): NAME = "Recognizable name" NUM_CLASSES = 1 + 1 DETECTION_MIN_CONFIDENCE = 0.85

Zemenend avatar May 23 '22 08:05 Zemenend