yizt / Grad-CAM.pytorch

pytorch实现Grad-CAM和Grad-CAM++,可以可视化任意分类网络的Class Activation Map (CAM)图,包括自定义的网络;同时也实现了目标检测faster r-cnn和retinanet两个网络的CAM图;欢迎试用、关注并反馈问题...
Apache License 2.0
730 stars 167 forks source link

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

Open fairytalell opened 4 years ago

fairytalell commented 4 years ago

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

[{'instances': Instances(num_instances=0, image_height=1024, image_width=1024, fields=[pred_boxes: Boxes(tensor([], size=(0, 4), grad_fn=)), scores: tensor([], grad_fn=), 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 为空。请问有哪位遇到了同样的问题?

yizt commented 3 years ago

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

svellaichamy3 commented 2 years ago

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

fairytalell commented 2 years ago

邮件已收到!