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.06k stars 1.52k forks source link

Which models are usable using the repo as library? #283

Closed RocaPiedra closed 2 years ago

RocaPiedra commented 2 years ago

Hi,

I'm using your work as a library to integrate visualization methods with the Carla Simulator for my master's thesis (thanks a lot for such an amazing repo!!), so far I've been able to use alexnet and ResNet succesfully. I would like to implement as many methods with as many models but I don't have a lot of time and I would like to know which architectures I could use without needing to tweak anything, right now I just do this:

cam_method = MethodCAM(model=self.model, target_layers=self.target_layers, use_cuda=True) grayscale_cam = cam_method(input_tensor=input_tensor)

I'm doing the preprocessing as they explain in the PyTorch documentation for ResNet and alexnet but I don't know much about the other architectures that you cite in the Choosing your target layer section, are all of those models ready to use with the library?

Also, I'm using the methods you showcase in the readme's section Using from code as a library: from pytorch_grad_cam import GradCAM, ScoreCAM, GradCAMPlusPlus, AblationCAM, XGradCAM, EigenCAM, FullGrad Would it be possible to use the rest of methods (LayerCAM, EigenGradCAM and GradCamElementWise) in the repo with the library too?

Thanks in advance!

jacobgil commented 2 years ago

Hi,

Vision Transformers are a bit more tricky because of the reshape_transform required, but there are examples.