Skip to content

Commit 49bb68a

Browse files
committed
Readme
1 parent f7be02d commit 49bb68a

File tree

1 file changed

+43
-27
lines changed

1 file changed

+43
-27
lines changed

README.md

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,53 @@ The `targets` parameter passed to the CAM method can then use `ClassifierOutputT
169169
targets = [ClassifierOutputTarget(281)]
170170
```
171171

172-
However more advanced cases, you might want another behaviour.
172+
However for more advanced cases, you might want a different behaviour.
173173
Check [here](https://github.com/jacobgil/pytorch-grad-cam/blob/master/pytorch_grad_cam/utils/model_targets.py) for more examples.
174174

175175
----------
176176

177+
# Tutorials
178+
Here you can find detailed examples of how to use this for various custom use cases like object detection:
179+
180+
These point to the new documentation jupter-book for fast rendering.
181+
The jupyter notebooks themselves can be found under the tutorials folder in the git repository.
182+
183+
- [Notebook tutorial: XAI Recipes for the HuggingFace 🤗 Image Classification Models](<https://jacobgil.github.io/pytorch-gradcam-book/HuggingFace.html>)
184+
185+
- [Notebook tutorial: Deep Feature Factorizations for better model explainability](<https://jacobgil.github.io/pytorch-gradcam-book/Deep%20Feature%20Factorizations.html>)
186+
187+
- [Notebook tutorial: Class Activation Maps for Object Detection with Faster-RCNN](<https://jacobgil.github.io/pytorch-gradcam-book/Class%20Activation%20Maps%20for%20Object%20Detection%20With%20Faster%20RCNN.html>)
188+
189+
- [Notebook tutorial: Class Activation Maps for YOLO5](<https://jacobgil.github.io/pytorch-gradcam-book/EigenCAM%20for%20YOLO5.html>)
190+
191+
- [Notebook tutorial: Class Activation Maps for Semantic Segmentation](<https://jacobgil.github.io/pytorch-gradcam-book/Class%20Activation%20Maps%20for%20Semantic%20Segmentation.html>)
192+
193+
- [Notebook tutorial: Adapting pixel attribution methods for embedding outputs from models](<https://jacobgil.github.io/pytorch-gradcam-book/Pixel%20Attribution%20for%20embeddings.html>)
194+
195+
- [Notebook tutorial: May the best explanation win. CAM Metrics and Tuning](<https://jacobgil.github.io/pytorch-gradcam-book/CAM%20Metrics%20And%20Tuning%20Tutorial.html>)
196+
197+
- [How it works with Vision/SwinT transformers](tutorials/vision_transformers.md)
198+
199+
200+
----------
201+
202+
# Guided backpropagation
203+
204+
```python
205+
from pytorch_grad_cam import GuidedBackpropReLUModel
206+
from pytorch_grad_cam.utils.image import (
207+
show_cam_on_image, deprocess_image, preprocess_image
208+
)
209+
gb_model = GuidedBackpropReLUModel(model=model, device=model.device())
210+
gb = gb_model(input_tensor, target_category=None)
211+
212+
cam_mask = cv2.merge([grayscale_cam, grayscale_cam, grayscale_cam])
213+
cam_gb = deprocess_image(cam_mask * gb)
214+
result = deprocess_image(gb)
215+
```
216+
217+
----------
218+
177219
# Metrics and evaluating the explanations
178220

179221
```python
@@ -200,32 +242,6 @@ cam_metric = ROADCombined(percentiles=[20, 40, 60, 80])
200242
scores = cam_metric(input_tensor, grayscale_cams, targets, model)
201243
```
202244

203-
----------
204-
205-
# Tutorials
206-
Here you can find detailed examples of how to use this for various custom use cases like object detection:
207-
208-
These point to the new documentation jupter-book for fast rendering.
209-
The jupyter notebooks themselves can be found under the tutorials folder in the git repository.
210-
211-
- [Notebook tutorial: XAI Recipes for the HuggingFace 🤗 Image Classification Models](<https://jacobgil.github.io/pytorch-gradcam-book/HuggingFace.html>)
212-
213-
- [Notebook tutorial: Deep Feature Factorizations for better model explainability](<https://jacobgil.github.io/pytorch-gradcam-book/Deep%20Feature%20Factorizations.html>)
214-
215-
- [Notebook tutorial: Class Activation Maps for Object Detection with Faster-RCNN](<https://jacobgil.github.io/pytorch-gradcam-book/Class%20Activation%20Maps%20for%20Object%20Detection%20With%20Faster%20RCNN.html>)
216-
217-
- [Notebook tutorial: Class Activation Maps for YOLO5](<https://jacobgil.github.io/pytorch-gradcam-book/EigenCAM%20for%20YOLO5.html>)
218-
219-
- [Notebook tutorial: Class Activation Maps for Semantic Segmentation](<https://jacobgil.github.io/pytorch-gradcam-book/Class%20Activation%20Maps%20for%20Semantic%20Segmentation.html>)
220-
221-
- [Notebook tutorial: Adapting pixel attribution methods for embedding outputs from models](<https://jacobgil.github.io/pytorch-gradcam-book/Pixel%20Attribution%20for%20embeddings.html>)
222-
223-
- [Notebook tutorial: May the best explanation win. CAM Metrics and Tuning](<https://jacobgil.github.io/pytorch-gradcam-book/CAM%20Metrics%20And%20Tuning%20Tutorial.html>)
224-
225-
- [How it works with Vision/SwinT transformers](tutorials/vision_transformers.md)
226-
227-
228-
----------
229245

230246
# Smoothing to get nice looking CAMs
231247

0 commit comments

Comments
 (0)