File tree Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Original file line number Diff line number Diff line change @@ -124,26 +124,21 @@ target_layers = [model.layer4[-1]]
124
124
input_tensor = # Create an input tensor image for your model..
125
125
# Note: input_tensor can be a batch tensor with several images!
126
126
127
-
128
- # We have to specify the target we want to generate
129
- # the Class Activation Maps for.
127
+ # We have to specify the target we want to generate the CAM for.
130
128
targets = [ClassifierOutputTarget(281 )]
131
129
132
130
# Construct the CAM object once, and then re-use it on many images.
133
131
with GradCAM(model = model, target_layers = target_layers) as cam:
134
-
135
132
# You can also pass aug_smooth=True and eigen_smooth=True, to apply smoothing.
136
133
grayscale_cam = cam(input_tensor = input_tensor, targets = targets)
137
-
138
134
# In this example grayscale_cam has only one image in the batch:
139
135
grayscale_cam = grayscale_cam[0 , :]
140
136
visualization = show_cam_on_image(rgb_img, grayscale_cam, use_rgb = True )
141
-
142
137
# You can also get the model outputs without having to redo inference
143
138
model_outputs = cam.outputs
144
139
```
145
140
146
- cam.py has a more detailed usage example.
141
+ [ cam.py] ( https://github.com/jacobgil/pytorch-grad-cam/blob/master/cam.py ) has a more detailed usage example.
147
142
148
143
----------
149
144
You can’t perform that action at this time.
0 commit comments