Grad-CAM.pytorch icon indicating copy to clipboard operation
Grad-CAM.pytorch copied to clipboard

IndexError: index 0 is out of bounds for dimension 0 with size 0

Open fairytalell opened this issue 4 years ago • 3 comments

我使用detectron2运行了heatmap.py,但是遇到了一下问题。

[{'instances': Instances(num_instances=0, image_height=1024, image_width=1024, fields=[pred_boxes: Boxes(tensor([], size=(0, 4), grad_fn=<ViewBackward>)), scores: tensor([], grad_fn=<IndexBackward>), pred_classes: tensor([], dtype=torch.int64), indices: tensor([], dtype=torch.int64)])}] Traceback (most recent call last): File "/home/dxy/ll/obj_competition/detectron2框架/heatmap.py", line 160, in mask, box, class_id = grad_cam(inputs) # cam mask File "/home/dxy/ll/obj_competition/detectron2框架/grad_cam.py", line 52, in call score = output[0]['instances'].scores[index] IndexError: index 0 is out of bounds for dimension 0 with size 0

通过debug,发现是grad_cam.py中output = self.net.inference([inputs]) 的输出为空 ,准确的说是roi 为空。请问有哪位遇到了同样的问题?

fairytalell avatar Aug 25 '20 03:08 fairytalell

@fairytalell 感谢您的反馈,麻烦发一个测试的图像和命令

yizt avatar Dec 09 '20 01:12 yizt

To me it looks like there was no instance detected and hence the empty indices and scores. Would suggest to try with some other image

svellaichamy3 avatar Jan 03 '22 23:01 svellaichamy3

邮件已收到!

fairytalell avatar Jan 03 '22 23:01 fairytalell