$ show luow23/INP-Former
This repository implements the INP-Former model for anomaly detection in industrial inspection tasks. The system extracts Intrinsic Normal Prototypes (INPs) directly from test images using a DINOv2 vision transformer encoder, followed by an INP extractor and decoder to reconstruct normal regions. Reconstruction errors serve as anomaly scores. The repository provides training scripts for various settings (single-class, multi-class, few-shot, zero-shot, super-multi-class), a Gradio-based zero-shot application for interactive inference, ONNX conversion and inference tools, and a competition submission kit. It achieves state-of-the-art performance on standard benchmarks like MVTec-AD, VisA, and Real-IAD. The architecture is modular, separating the core model, dataset handling, utilities, and training logic, though training scripts show some duplication across different settings.
The LLM identified 1 files worth highlighting for reuse:
Implements novel Prototype_Attention and Aggregation_Attention mechanisms for the INP-Former model. These attention modules are designed to extract intrinsic normal prototypes from image features and aggregate information for reconstruction. They are self-contained, depend only on PyTorch, and demonstrate non-obvious skill in designing task-specific attention mechanisms. The component could be extracted and reused in other vision transformer-based tasks requiring prototype or aggregation-based attention with minimal modification.