Updated Models Checkpoints
Browse files- README.md +167 -3
- checkpoints/model_bottle_64.pt +3 -0
- checkpoints/model_cable_64.pt +3 -0
- checkpoints/model_capsule_64.pt +3 -0
- checkpoints/model_carpet_64.pt +3 -0
- checkpoints/model_grid_64.pt +3 -0
- checkpoints/model_hazelnut_64.pt +3 -0
- checkpoints/model_leather_64.pt +3 -0
- checkpoints/model_metal_nut_64.pt +3 -0
- checkpoints/model_pill_64.pt +3 -0
- checkpoints/model_screw_64.pt +3 -0
- checkpoints/model_tile_64.pt +3 -0
- checkpoints/model_toothbrush_64.pt +3 -0
- checkpoints/model_transistor_64.pt +3 -0
- checkpoints/model_wood_64.pt +3 -0
- checkpoints/model_zipper_64.pt +3 -0
README.md
CHANGED
|
@@ -1,3 +1,167 @@
|
|
| 1 |
-
-
|
| 2 |
-
|
| 3 |
-
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# VAE-GAN Checkpoints for MVTec Anomaly Detection
|
| 2 |
+
|
| 3 |
+
This repository contains pre-trained VAE-GAN model checkpoints for visual anomaly detection on the MVTec AD dataset.
|
| 4 |
+
|
| 5 |
+
## Overview
|
| 6 |
+
|
| 7 |
+
The models were trained in a one-class anomaly detection setting using only normal training images. During inference, each input image is reconstructed by the VAE-GAN model, and anomaly scores are computed from the reconstruction error between the input and reconstructed image.
|
| 8 |
+
|
| 9 |
+
These checkpoints are useful for:
|
| 10 |
+
|
| 11 |
+
- Reconstruction-based anomaly detection
|
| 12 |
+
- Threshold selection experiments
|
| 13 |
+
- Multi-point threshold evaluation
|
| 14 |
+
- Anomaly localization
|
| 15 |
+
- Explainable anomaly detection
|
| 16 |
+
- Baseline comparison with AE, VAE, PatchCore, PaDiM, and other methods
|
| 17 |
+
|
| 18 |
+
## Dataset
|
| 19 |
+
|
| 20 |
+
The checkpoints are trained on MVTec AD object and texture categories.
|
| 21 |
+
|
| 22 |
+
Reference:
|
| 23 |
+
|
| 24 |
+
```bibtex
|
| 25 |
+
@article{bergmann2021mvtec,
|
| 26 |
+
title={The MVTec Anomaly Detection Dataset: A Comprehensive Real-World Dataset for Unsupervised Anomaly Detection},
|
| 27 |
+
author={Bergmann, Paul and Batzner, Kilian and Fauser, Michael and Sattlegger, David and Steger, Carsten},
|
| 28 |
+
journal={International Journal of Computer Vision},
|
| 29 |
+
year={2021}
|
| 30 |
+
}
|
| 31 |
+
```
|
| 32 |
+
|
| 33 |
+
## Available Checkpoints
|
| 34 |
+
|
| 35 |
+
| Category | Checkpoint |
|
| 36 |
+
|-----------|-----------|
|
| 37 |
+
| Bottle | model_bottle_64.pt |
|
| 38 |
+
| Cable | model_cable_64.pt |
|
| 39 |
+
| Capsule | model_capsule_64.pt |
|
| 40 |
+
| Carpet | model_carpet_64.pt |
|
| 41 |
+
| Grid | model_grid_64.pt |
|
| 42 |
+
| Hazelnut | model_hazelnut_64.pt |
|
| 43 |
+
| Leather | model_leather_64.pt |
|
| 44 |
+
| Metal Nut | model_metal_nut_64.pt |
|
| 45 |
+
| Pill | model_pill_64.pt |
|
| 46 |
+
| Screw | model_screw_64.pt |
|
| 47 |
+
| Tile | model_tile_64.pt |
|
| 48 |
+
| Toothbrush | model_toothbrush_64.pt |
|
| 49 |
+
| Transistor | model_transistor_64.pt |
|
| 50 |
+
| Wood | model_wood_64.pt |
|
| 51 |
+
| Zipper | model_zipper_64.pt |
|
| 52 |
+
|
| 53 |
+
## Model Details
|
| 54 |
+
|
| 55 |
+
| Property | Value |
|
| 56 |
+
|-----------|-----------|
|
| 57 |
+
| Model | VAE-GAN |
|
| 58 |
+
| Training Setting | One-Class Learning |
|
| 59 |
+
| Training Data | Normal Samples Only |
|
| 60 |
+
| Input Size | 128 × 128 × 3 |
|
| 61 |
+
| Latent Dimension | 64 |
|
| 62 |
+
| Framework | PyTorch |
|
| 63 |
+
|
| 64 |
+
## Checkpoint Structure
|
| 65 |
+
|
| 66 |
+
Each checkpoint contains:
|
| 67 |
+
|
| 68 |
+
```python
|
| 69 |
+
{
|
| 70 |
+
"encoder_state_dict": ...,
|
| 71 |
+
"decoder_state_dict": ...,
|
| 72 |
+
"discriminator_state_dict": ...
|
| 73 |
+
}
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
## Loading a Checkpoint
|
| 77 |
+
|
| 78 |
+
```python
|
| 79 |
+
import torch
|
| 80 |
+
|
| 81 |
+
checkpoint = torch.load(
|
| 82 |
+
"model_bottle_64.pt",
|
| 83 |
+
map_location="cpu",
|
| 84 |
+
weights_only=False
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
encoder.load_state_dict(checkpoint["encoder_state_dict"])
|
| 88 |
+
decoder.load_state_dict(checkpoint["decoder_state_dict"])
|
| 89 |
+
discriminator.load_state_dict(checkpoint["discriminator_state_dict"])
|
| 90 |
+
|
| 91 |
+
encoder.eval()
|
| 92 |
+
decoder.eval()
|
| 93 |
+
discriminator.eval()
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
## Example Anomaly Score
|
| 97 |
+
|
| 98 |
+
```python
|
| 99 |
+
with torch.no_grad():
|
| 100 |
+
mu, logvar = encoder(image)
|
| 101 |
+
z = reparameterize(mu, logvar)
|
| 102 |
+
reconstruction = decoder(z)
|
| 103 |
+
|
| 104 |
+
anomaly_map = torch.abs(image - reconstruction).mean(dim=1)
|
| 105 |
+
anomaly_score = anomaly_map.mean().item()
|
| 106 |
+
```
|
| 107 |
+
|
| 108 |
+
## Device Support
|
| 109 |
+
|
| 110 |
+
The checkpoints can be loaded on:
|
| 111 |
+
|
| 112 |
+
- CPU
|
| 113 |
+
- NVIDIA CUDA GPUs
|
| 114 |
+
- Apple Silicon (MPS)
|
| 115 |
+
|
| 116 |
+
```python
|
| 117 |
+
import torch
|
| 118 |
+
|
| 119 |
+
if torch.cuda.is_available():
|
| 120 |
+
device = "cuda"
|
| 121 |
+
elif torch.backends.mps.is_available():
|
| 122 |
+
device = "mps"
|
| 123 |
+
else:
|
| 124 |
+
device = "cpu"
|
| 125 |
+
```
|
| 126 |
+
|
| 127 |
+
## Intended Use
|
| 128 |
+
|
| 129 |
+
This repository is intended for research on:
|
| 130 |
+
|
| 131 |
+
- Visual Anomaly Detection
|
| 132 |
+
- Reconstruction-Based Anomaly Scoring
|
| 133 |
+
- Threshold Calibration
|
| 134 |
+
- Multi-Point Thresholding
|
| 135 |
+
- Explainable Anomaly Detection
|
| 136 |
+
- Industrial Inspection Systems
|
| 137 |
+
|
| 138 |
+
## Limitations
|
| 139 |
+
|
| 140 |
+
- Models are trained on resized 128×128 images.
|
| 141 |
+
- Performance depends on preprocessing, anomaly score design, and threshold selection.
|
| 142 |
+
- These checkpoints are intended for research purposes and should be validated before deployment in industrial or safety-critical environments.
|
| 143 |
+
|
| 144 |
+
## Citation
|
| 145 |
+
|
| 146 |
+
```bibtex
|
| 147 |
+
@misc{rao2026vaeganmvtec,
|
| 148 |
+
title={VAE-GAN Checkpoints for MVTec Anomaly Detection},
|
| 149 |
+
author={Rao, Rashid},
|
| 150 |
+
year={2026},
|
| 151 |
+
publisher={Hugging Face},
|
| 152 |
+
url={https://huggingface.co/rashidrao/AnomalyDetection}
|
| 153 |
+
}
|
| 154 |
+
```
|
| 155 |
+
|
| 156 |
+
## Author
|
| 157 |
+
|
| 158 |
+
Rashid Rao
|
| 159 |
+
Industrial PhD Researcher
|
| 160 |
+
University of Turin, Italy
|
| 161 |
+
|
| 162 |
+
Research Areas:
|
| 163 |
+
|
| 164 |
+
- Explainable AI (XAI)
|
| 165 |
+
- Visual Anomaly Detection
|
| 166 |
+
- Trustworthy AI
|
| 167 |
+
- Industrial AI Systems
|
checkpoints/model_bottle_64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9e7e4f788c7a4adfa9ab69d32121e5bb24c70dd81fe8e2e0c35fa3f00733ce90
|
| 3 |
+
size 243981714
|
checkpoints/model_cable_64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c926d9e723c50f8bd128b5c5985ce9348ba3115c27c392312f01f215a09d758a
|
| 3 |
+
size 243984142
|
checkpoints/model_capsule_64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6de1abe968776b819d7960d3ac7269237e31b05a850fa9f68d248f4ad2480f27
|
| 3 |
+
size 243981782
|
checkpoints/model_carpet_64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:96534c58540fe2df4e9d9b29a02e447bafef3b6e04af32f6f063a0379cdc8a84
|
| 3 |
+
size 243974162
|
checkpoints/model_grid_64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:77d81e5ac0c555830f7b64f521835bd757c4750c7485e108ae48d62d745b9927
|
| 3 |
+
size 243975882
|
checkpoints/model_hazelnut_64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:454c1e6eed8e1db67ffb661abdc505bd52159284158f3d9a6d0bb77b8b9c52fe
|
| 3 |
+
size 243981850
|
checkpoints/model_leather_64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ffe660e2b757e317455c2f8dec1ab2350fa61c628a75976bddd7c6173c06f89d
|
| 3 |
+
size 243983702
|
checkpoints/model_metal_nut_64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ed4ca546d20fb798b777a4f70242edeab7182018fcfbf1feadb0ba662f26c817
|
| 3 |
+
size 243982174
|
checkpoints/model_pill_64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:920d916b7fcdb726e658f7b297c788d84c9881c54c6b20c33da580859aaf8e51
|
| 3 |
+
size 243974922
|
checkpoints/model_screw_64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b18a892ea06ea0f199ce5b6a06a697a06b94c4fcb9dcaa9651d4d1be108c2777
|
| 3 |
+
size 243982606
|
checkpoints/model_tile_64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:26f4ac0c2feb6c385368ef18b7399bb71ef813476d3d1297a0b4b9fafe235fa6
|
| 3 |
+
size 243979402
|
checkpoints/model_toothbrush_64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f62f898daa40983db6953f3a206385b427afde0fa068bea28753833ce4eafc8f
|
| 3 |
+
size 243975266
|
checkpoints/model_transistor_64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:33d2b687364ad425198bbe6129bdf8713a8c780e20c82e21ade26a877581d0f4
|
| 3 |
+
size 243982114
|
checkpoints/model_wood_64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:15c05f7abbaf91310d43ffea1ae6ca1ed8c6631123426e99ff5ea0c6ccad96c8
|
| 3 |
+
size 243983114
|
checkpoints/model_zipper_64.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:dc2464f10125594b15302c906add22a5410c66b6eb178748b633b769b1e79b70
|
| 3 |
+
size 243982994
|