pytorch-grad-cam
pytorch-grad-cam copied to clipboard
the example in README need to update
this link :https://jacobgil.github.io/pytorch-gradcam-book/Class%20Activation%20Maps%20for%20Semantic%20Segmentation.html
i found now the code can automatic use the same device of model:
class BaseCAM:
def __init__(self,
model: torch.nn.Module,
target_layers: List[torch.nn.Module],
reshape_transform: Callable = None,
compute_input_gradient: bool = False,
uses_gradients: bool = True,
tta_transforms: Optional[tta.Compose] = None) -> None:
self.model = model.eval()
self.target_layers = target_layers
# Use the same device as the model.
self.device = next(self.model.parameters()).device
xxx