File size: 2,888 Bytes
e977549
729198e
 
 
 
 
 
 
 
 
 
 
 
 
 
e977549
729198e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
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