Generated GradCAM is not as expected #6747
Unanswered
MJGroeneveld
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi @MJGroeneveld, thanks for your interest here. Hope it helps, thanks! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
I use GradCAM from monai.visualize and implemented it into my pytorch lightning architecture. However, I get something different than that I was expecting:
I would expect that the high activation areas (indicated by hot colors) corresponding to the regions that are most relevant for predicting. However, it is now blue instead of red.
This is a part of my code where I generate the heatmaps.
` class ClassifierChest(pl.LightningModule):
def init(self, *args):
super().init()
def test_step(self, batch, batch_idx):
X, y_class, _, image_names = batch
X, y_class = X.float().to(device), y_class.to(device)
y_hat_class = self.model(X).squeeze(1)
y_prob = torch.sigmoid(y_hat_class)
test_loss = F.binary_cross_entropy_with_logits(y_hat_class, y_class.float())
and the model:
`import pytorch_lightning as pl
import torchvision
import torch.nn as nn
import torch
from monai.networks.nets import DenseNet121
class DenseNet(pl.LightningModule):
def init(self):
super().init()
self.model = DenseNet121(spatial_dims=2, in_channels=3, out_channels=1, pretrained=True)
def forward(self, x):
x = self.model(x)
return x `
Beta Was this translation helpful? Give feedback.
All reactions