I am trying to use the lessen 9 multi part object detection on my own data but function
def get_y(bbox,clas): bbox = bbox.view(-1,4)/sz bb_keep = ((bbox[:,2]-bbox[:,0])>0).nonzero()[:,0] return bbox[bb_keep],clas[bb_keep]
gives an error which seems to be related to empty bbox.
Here is the code to reproduce the error
bbox = np.array([[0.5000 , 0.2009 , 0.5000, 0.6071],[0.4643 , 0.5938, 0.4643, 0.6964]])
bbox = VV(bbox)
((bbox[:,2]-bbox[:,0])>0).nonzero()[:,0]
and the error is:
IndexError Traceback (most recent call last)
in ()
----> 1 ((bbox[:,2]-bbox[:,0])>0).nonzero()[:,0]
~/anaconda3/envs/fastai/lib/python3.6/site-packages/torch/autograd/variable.py in getitem(self, key)
76 return IndexSelect.apply(self, 0, key)
77 # else fall through and raise an error in Index
—> 78 return Index.apply(self, key)
79
80 def setitem(self, key, value):
~/anaconda3/envs/fastai/lib/python3.6/site-packages/torch/autograd/_functions/tensor.py in forward(ctx, i, index)
87 result = i.index(ctx.index)
88 else:
—> 89 result = i.index(ctx.index)
90 ctx.mark_shared_storage((i, result))
91 return result
IndexError: trying to index 2 dimensions of a 0 dimensional tensor
I am wondering why get_y is fed with empty bbox ( left and right heights are same)?