--- language: - en tags: - anomaly-detection - industrial-inspection - computer-vision - patchcore - anomalib - mvtec-ad-2 - defect-detection - manufacturing - pytorch library_name: anomalib pipeline_tag: image-classification --- # Vial PatchCore — Industrial Anomaly Detection A PatchCore-based industrial anomaly detection model trained for the **Vial** category of the **MVTec AD 2** dataset. The model is designed to distinguish anomalous vial images from normal vial images and provides an anomaly map for visualizing regions that contribute to the detected anomaly. ## 🚀 Live Demo Try the deployed model through the interactive Gradio application: **[Industrial Vial Defect Detection — Hugging Face Space](https://huggingface.co/spaces/pranamjain/industrial-vial-defect-detection)** Upload a vial image and receive: - Normal / Defective prediction - Anomaly score - Anomaly heatmap - Visual localization of suspicious regions --- ## 🧠 Model Overview ### Architecture **PatchCore** PatchCore is an industrial anomaly detection approach that represents image patches using deep visual features and compares them against a memory bank representing normal samples. The model is trained to learn the visual characteristics of normal vial images. During inference, deviations from the learned normal representation produce higher anomaly scores. ### Model Details | Property | Value | |---|---| | Architecture | PatchCore | | Framework | PyTorch | | Library | Anomalib | | Dataset | MVTec AD 2 | | Category | Vial | | Input Resolution | 256 × 256 | | Task | Industrial Anomaly Detection | | Model File | `model.ckpt` | --- ## 📊 Evaluation The trained Vial model was evaluated on the MVTec AD 2 public test set. | Metric | Score | |---|---:| | Image AUROC | **0.7578** | | Image F1 Score | **0.5315** | | Pixel AUROC | **0.9142** | | Pixel F1 Score | **0.1197** | ### Interpretation **Image AUROC — 0.7578** The model provides useful separation between normal and anomalous vial images at the image level. **Image F1 Score — 0.5315** The F1 score reflects the balance between precision and recall under the evaluation threshold used during the original evaluation. **Pixel AUROC — 0.9142** The high pixel-level AUROC indicates that the model can effectively rank anomalous regions relative to normal regions. **Pixel F1 Score — 0.1197** The lower pixel-level F1 indicates that precise defect segmentation remains challenging, even though the anomaly map provides useful localization information. --- ## 🎯 Deployment Threshold During development, the default image-level threshold resulted in a relatively high number of false negatives for the Vial model. An additional threshold analysis was performed using the MVTec AD 2 public test set. The experimental deployment threshold selected for the interactive demo is: ```text 0.09