faster_rcnn_pytorch icon indicating copy to clipboard operation
faster_rcnn_pytorch copied to clipboard

the given numpy array has zero-sized dimensions.

Open luhc15 opened this issue 8 years ago • 2 comments

File "/home/luhongchao/anaconda2/lib/python2.7/site-packages/torch/nn/modules/module.py", line 224, in call result = self.forward(*input, **kwargs) File "/home/luhongchao/pytorch/faster_rcnn_pytorch/faster_rcnn/faster_rcnn.py", line 71, in forward cfg_key, self._feat_stride, self.anchor_scales) File "/home/luhongchao/pytorch/faster_rcnn_pytorch/faster_rcnn/faster_rcnn.py", line 123, in proposal_layer x = network.np_to_variable(x, is_cuda=True) File "/home/luhongchao/pytorch/faster_rcnn_pytorch/faster_rcnn/network.py", line 86, in np_to_variable v = Variable(torch.from_numpy(x).type(dtype)) RuntimeError: the given numpy array has zero-sized dimensions. Zero-sized dimensions are not supported in PyTorch

Is there anyone got this problem ? how should I solve this

luhc15 avatar Sep 20 '17 07:09 luhc15

I have encountered the same problem and I guess it's because your annotation or other stuff are empty. The pytorch can't handle e.g. 01010 tensor while numpy.ndarray does.

ymchen7 avatar Nov 16 '17 06:11 ymchen7

I found the in the datasets/pascal_voc.py has bugs, if your annotation has ymin or xmin is 0, the loaded annotation would be 65535 which is out of range of width and height, make sure the loaded data to be positive! From my experiment, modified the datasets/pascal_voc.py line near line ~220 change the code by this.

x1 = max(float(bbox.find('xmin').text) - 1, 0)
y1 = max(float(bbox.find('ymin').text) - 1, 0)
x2 = max(float(bbox.find('xmax').text) - 1, 0)
y2 = max(float(bbox.find('ymax').text) - 1, 0)

which solved this issue. 👍

mtroym avatar Aug 05 '18 15:08 mtroym