Comments (3)
Thank you!
code: cam_extractor = CAM(model, target_layer=model.backbone.shared_module_bh.model_sh_fr.layer4[-1].conv3, fc_layer=model.classifier)
can work. The network structure should not add ' ' .
from torch-cam.
Hello @ReIDkj 👋
Yes there is! Here is the explanation:
- you can specify the target layer using a string argument or the module itself
- when using the string version, the underneath mechanism uses the key of the state_dict which replaces index brackets
[0]
by a dot.0
(bare in mind that -1 won't work then
So you can either use the module itself (recommended):
cam_extractor = CAM(model, model.backbone.shared_module_bh.model_sh_fr.layer4[-1])
or use the string argument (below I supposed that the last item was at index 3):
cam_extractor = CAM(model, 'model.backbone.shared_module_bh.model_sh_fr.layer4.3')
Hope this helps, let me know if some aspects are unclear :)
Cheers ✌️
from torch-cam.
Happy to help! I'll close the issue then, feel free to reopen if some details are unclear :)
from torch-cam.
Related Issues (20)
- VGG16 can't assist with plain CAM? HOT 2
- IS-CAM formula error? HOT 4
- Error when clearing hooks HOT 1
- self._normalize() got NAN... HOT 7
- What is class_idx in __call__() ?? HOT 6
- What are the requirements of the model by using these visual code? HOT 10
- [demo] Automate deployment to HF Spaces
- Upcoming support for new CAM methods
- Release tracker - v0.5.0
- More NaNs HOT 7
- didn't find remove_hooks() in cam_extractor HOT 2
- RuntimeError: 'cannot register a hook on a tensor that doesn't require gradient' HOT 7
- Remove hooks once we're done with CAM extractors
- use torch-cam/scripts/cam_example.py throw a exception: HOT 5
- Does torch-cam still support 3D resnet model? HOT 3
- SmoothGradCAMpp returning GRAD CAM with NANs for some images, not all HOT 3
- How to get CAM for custom 3D model? HOT 19
- RuntimeError: cannot register a hook on a tensor that doesn't require gradient HOT 1
- No difference between GradCAM and XGradCAM HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from torch-cam.