multimodallearning / pytorch-mask-rcnn

Other
2.01k stars 557 forks source link

IndexError: too many indices for tensor of dimension 1 #67

Open InstantWindy opened 5 years ago

InstantWindy commented 5 years ago

Hi! when I run coco.py,it appears the error"IndexError: too many indices for tensor of dimension 1 ",I tried to output "gt_class_ids "value and found that its value is positive. Thanks. image

qiuhaining commented 5 years ago

I guess ,when detecting nothing, the mistake occurs

pengshiqi commented 5 years ago

I have the same problem as yours....

I print the variables to debug, and find that

the value for gt_class_ids is tensor([ 1, 1, 1, 1, 1, 1, 1, 1, 1], dtype=torch.int32, device='cuda:0'),

and value for torch.nonzero(gt_class_ids < 0) is tensor([], dtype=torch.int64, device='cuda:0')

Do you have any idea about how to avoid such situation?

pengshiqi commented 5 years ago

I got it!

Change

if torch.nonzero(gt_class_ids < 0).size():

to

if torch.nonzero(gt_class_ids < 0).size() != (0,):

solves this problem.

pengshiqi commented 5 years ago

I reviewed the other issues, and found that this bug has been discussed in detail in #24 ...

Miracle2333 commented 5 years ago

https://github.com/multimodallearning/pytorch-mask-rcnn/issues/33#issuecomment-419589620 this will solve the problem!!!!