| name | torchcam-debug-prediction |
| description | Debug one surprising 2D image-classification prediction in an existing PyTorch repository with TorchCAM. Use when an owner asks for predicted-versus-expected CAM evidence, a saved explanation bundle, GradCAM on a CNN, or LeGrad on a supported Vision Transformer. Reuse the repository's trusted model loader, checkpoint, class mapping, and preprocessing instead of inventing replacements. |
| compatibility | Requires local Python execution, PyTorch, Pillow, and torchcam>=0.5.0. |
| metadata | {"author":"frgfm","version":"1.0"} |
Debug one prediction with TorchCAM
Produce reproducible visual evidence for one surprising classifier prediction. CAMs show class-associated activation, not why the model decided, causal influence, correctness, or localization quality.
1. Discover the repository's inference path
Find and reuse the code that already defines:
- the model architecture and trusted checkpoint loader;
- evaluation preprocessing, including resize, crop, normalization, and color conversion;
- the ordered class-name mapping;
- the original image before normalization.
Search the repository before writing code. Prefer its test or inference entry point over reconstructing the model. Load only checkpoints already trusted by the owner; TorchCAM does not load checkpoints or preprocessing.
Confirm the model returns one logits tensor shaped (1, num_classes). If it returns a tuple or dictionary, wrap it in a small nn.Module that selects the logits tensor without changing inference.