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

Running retinanet demo example

Open ghada-soliman opened this issue 3 years ago • 4 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 avatar Jan 03 '21 07:01 ghada-soliman

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

yizt avatar Jan 04 '21 10:01 yizt

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

ghada-soliman avatar Jan 05 '21 15:01 ghada-soliman

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

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

yizt avatar Jan 06 '21 09:01 yizt

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.

ravising-h avatar Jan 24 '21 18:01 ravising-h