yizt / Grad-CAM.pytorch

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running retinanet demo example

ghada-soliman opened this issue · comments

Hello,

I have the following issue when running any of the demo example on retinanet.
May you please advise in this

self.anchor_idxs tensor([], dtype=torch.int64) tensor([], dtype=torch.int64)
Traceback (most recent call last):
File "detection/demo_retinanet.py", line 185, in
main(arguments)
File "detection/demo_retinanet.py", line 147, in main
mask, box, class_id = grad_cam(inputs) # cam mask
File "/content/Grad-CAM.pytorch/detection/grad_cam_retinanet.py", line 61, in call
output = self.net.predict([inputs])
File "/content/detectron2_repo/detectron2/modeling/meta_arch/retinanet.py", line 531, in predict
results = self.inference(box_cls, box_delta, anchors, images.image_sizes)
File "/content/detectron2_repo/detectron2/modeling/meta_arch/retinanet.py", line 422, in inference
anchors, pred_logits_per_image, deltas_per_image, image_size
File "/content/detectron2_repo/detectron2/modeling/meta_arch/retinanet.py", line 477, in inference_single_image
predicted_boxes = self.box2box_transform.apply_deltas(box_reg_i, anchors_i.tensor)
File "/content/detectron2_repo/detectron2/modeling/box_regression.py", line 101, in apply_deltas
pred_ctr_x = dx * widths[:, None] + ctr_x[:, None]
RuntimeError: The size of tensor a (25) must match the size of tensor b (0) at non-singleton dimension 1

Thanks.

@ghada-soliman 麻烦发一下测试的图像

I used the same test images within the folder of GitHub repository. An example is: "--input ./examples/pic1.jpg"

I used the same test images within the folder of GitHub repository. An example is: "--input ./examples/pic1.jpg"

@ghada-soliman 估计不同版本的问题,可否发下您的python,pytorch,detectron2的版本,我测试一下

lower down the confidence. It worked for me.
Also remove predict function in grad-cam, instead of self.net.predict([inputs]) use self.net([inputs]). It will work. My detectron version is 2-0.3 and torch is 1.7.