{"repo":"frgfm/torch-cam","free":true,"listed":false,"github":"https://github.com/frgfm/torch-cam","clone":"git clone https://github.com/frgfm/torch-cam.git","description":"Class activation maps for your PyTorch models (CAM, Grad-CAM, Grad-CAM++, Smooth Grad-CAM++, Score-CAM, SS-CAM, IS-CAM, XGrad-CAM, Layer-CAM, Finer-CAM, LeGrad, RefineCAM)","language":"Python","stars":2305,"topics":["pytorch","python","deep-learning","cnn","activation-maps","gradcam-plus-plus","gradcam","saliency-map","interpretability","interpretable-deep-learning"],"license":"Apache-2.0","category":"machine-learning","readme_excerpt":"TorchCAM: class activation explorer English 简体中文 Simple way to leverage the class-specific activation of convolutional layers in PyTorch. Debugging one surprising classifier result? Use the predicted-versus-expected agent workflow, give a compatible agent the portable skill, or start from llms.txt . Source: image from woopets (activation maps created with a pretrained Resnet-18 ) Quick Tour Setting your CAM TorchCAM leverages PyTorch hooking mechanisms to seamlessly retrieve all required information to produce the class activation without additional efforts from the user. Each CAM object acts as a wrapper around your model. You can find the exhaustive list of supported CAM methods in the documentation, then use it as follows: Please note that by default, the layer at which the CAM is retrieved is set to the last non-reduced convolutional layer. If you wish to investigate a specific layer, use the target layer argument in the constructor. Retrieving the class activation map Once your CAM extractor is set, you only need to use your model to infer on your data as usual. If any additional information is required, the extractor will get it for you automatically. Here class idx (the first argument) is the index in the model's output logits of the class you want to explain — out.squeeze(0).argmax().item() picks the top prediction, but you can pass any class index. The extractor returns one activation map per target layer. If you want to visualize your heatmap, you only need to cast ","default_branch":null,"files":null,"tree":[],"storefront":"/r/frgfm","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/frgfm/torch-cam/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}