kazuto1011 / grad-cam-pytorch

PyTorch re-implementation of Grad-CAM (+ vanilla/guided backpropagation, deconvnet, and occlusion sensitivity maps)
MIT License
783 stars 174 forks source link

How to use InceptionV3 and densenet161? #25

Closed tuji-sjp closed 4 years ago

tuji-sjp commented 4 years ago

I find the "target_layer_names" of these two models, but when I run the modified code, I get the following error:

RuntimeError: size mismatch, m1: [1 x 277248], m2: [768 x 1000] at /opt/conda/conda-bld/pytorch_1535490206202/work/aten/src/THC/generic/THCTensorMathBlas.cu:249

How do I solve it? Please help me, thank you very much!

kazuto1011 commented 4 years ago

I cannot guess what caused the error because:

About another repository? https://github.com/jacobgil/pytorch-grad-cam/blob/master/grad-cam.py#L76

tuji-sjp commented 4 years ago

Oh, this is indeed the code of another repository, I made a mistake, so sorry. And "target_layer_names" is yours "target_layer".

kazuto1011 commented 4 years ago

In this repository, you can get various maps as follows:

$ python main.py demo1 --arch "inception_v3" --target-layer "Mixed_7c" -i "samples/cat_dog.png"
$ python main.py demo1 --arch "densenet161" --target-layer "features" -i "samples/cat_dog.png"

Please note that:

tuji-sjp commented 4 years ago

Hello, I fused the logits of the three models. Maybe you know how does this ensemble model gets its GradCAM?