$ show guojiajeremy/Dinomaly
This repository implements Dinomaly, a reconstruction-based unsupervised anomaly detection method for industrial inspection datasets. It uses vision transformers (primarily DINOv2) as feature extractors with a noisy bottleneck and linear attention mechanism. The code supports both class-separated and unified training across MVTec-AD, VisA, and Real-IAD datasets. Key components include dataset loaders, custom optimizers, training utilities, and evaluation metrics. While the research code achieves state-of-the-art results, it contains hardcoded paths, version-specific dependencies, and dataset-specific logic that limit immediate reproducibility.
The LLM identified 3 files worth highlighting for reuse:
Provides standardized dataset classes (MVTecDataset, RealIADDataset, VisADataset) for anomaly detection benchmarks. Handles loading, transformations, and data augmentation with a consistent interface. Minimal coupling allows adaptation to other similar datasets by modifying root paths and class labels.
Contains core training utilities: global cosine loss with progressive masking (key to Dinomaly), EvaluationMetrics class computing AUROC/AUPRO/F1, and WarmCosineScheduler. These modular components are decoupled from training loops and reusable in other self-supervised or anomaly detection projects with minimal adaptation.
Implements StableAdamW optimizer, a variant of AdamW designed for training stability in vision transformer training. Self-contained with only PyTorch dependencies, demonstrating non-obvious skill in adaptive gradient methods. Extractable as a standalone component for any PyTorch project requiring stable optimization.