attention visualization in defect detection
**Attention Visualization** in defect detection is the **visualization of which spatial regions a neural network focuses on when making classification decisions** — using attention maps, Grad-CAM, or self-attention weights to show the model's "gaze" pattern on defect images.
**Key Visualization Methods**
- **Grad-CAM**: Gradient-weighted class activation maps highlight important regions using gradient information.
- **Self-Attention**: Transformer self-attention weights directly show which image patches attend to each other.
- **Attention Rollout**: Aggregates attention across transformer layers for a global view.
- **Guided Backpropagation**: Combines Grad-CAM with guided gradients for fine-grained visualization.
**Why It Matters**
- **Validation**: Verify that the model is looking at the actual defect, not background artifacts.
- **Failure Analysis**: When the model mis-classifies, attention maps show where it was looking — guiding debugging.
- **Engineer Trust**: Showing that the model focuses on the right areas builds engineer confidence in the AI system.
**Attention Visualization** is **seeing through the model's eyes** — revealing which parts of a defect image the neural network considers most important.