Using activation maps (CAM) with model different from resnet + general CAM question

Hi, I have two questions:

1:
Using CAMs just with settings from the book and for example a resnet34 works well.
When using the same “resnet34” structure from timm library in combination with the “timm_learner”, CAMs work too.

With another structure, for example ‘seresnet152d_320’ CAMs are note working with the “timm_learner”.

I think that the dimensions of “act” cause the error, in the working example it was:

act.shape: torch.Size([512, 7, 7])

What could I do, to use the heatmaps for seresnet (or other architectures) here too?

2:
If I want to use CAMs for an image/images of 512x512 pixels, do I then just edit “extent” in the code below to the numbers/the image dimensions as I did below with my example image or are there other things to keep in mind too? (cell with cat image from chapter 18_CAM taken)

Cell I with my example image:

1 Like