jacobgil / pytorch-grad-cam

Advanced AI Explainability for computer vision. Support for CNNs, Vision Transformers, Classification, Object detection, Segmentation, Image similarity and more.
https://jacobgil.github.io/pytorch-gradcam-book
MIT License
10.66k stars 1.56k forks source link

How to use Grad-cam in my own trained VIT model? #229

Closed SunJJ1996 closed 2 years ago

SunJJ1996 commented 2 years ago

I can get the output when using model = torch.hub.load('facebookresearch/deit:main', 'deit_tiny_patch16_224', pretrained=True)

Then, I trained deit using https://github.com/facebookresearch/deit in my own classification dataset. The checkpoint is in this location : "Output/best_checkpoint.pth"

So how can I load this model and obtain the grad-cam result? Thank you if you can give me the answer.

jacobgil commented 2 years ago

Hi, Please follow the example here: https://github.com/jacobgil/pytorch-grad-cam/tree/master/usage_examples

And re-open in case there are more questions.