CoolFace
Modelpublic

rashidrao/AD_MVTec

sourceHugging Facemitupdated 4mo agoView on Hugging Face
0likes
Model Card

VAE-GAN Checkpoints for MVTec Anomaly Detection

This repository contains pre-trained VAE-GAN model checkpoints for visual anomaly detection on the MVTec AD dataset.

Overview

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.

These checkpoints are useful for:

  • —Reconstruction-based anomaly detection
  • —Threshold selection experiments
  • —Multi-point threshold evaluation
  • —Anomaly localization
  • —Explainable anomaly detection
  • —Baseline comparison with AE, VAE, PatchCore, PaDiM, and other methods

Dataset

The checkpoints are trained on MVTec AD object and texture categories.

Reference:

bibtex
@article{bergmann2021mvtec,
  title={The MVTec Anomaly Detection Dataset: A Comprehensive Real-World Dataset for Unsupervised Anomaly Detection},
  author={Bergmann, Paul and Batzner, Kilian and Fauser, Michael and Sattlegger, David and Steger, Carsten},
  journal={International Journal of Computer Vision},
  year={2021}
}

Available Checkpoints

CategoryCheckpoint
Bottlemodelbottle64.pt
Cablemodelcable64.pt
Capsulemodelcapsule64.pt
Carpetmodelcarpet64.pt
Gridmodelgrid64.pt
Hazelnutmodelhazelnut64.pt
Leathermodelleather64.pt
Metal Nutmodelmetalnut_64.pt
Pillmodelpill64.pt
Screwmodelscrew64.pt
Tilemodeltile64.pt
Toothbrushmodeltoothbrush64.pt
Transistormodeltransistor64.pt
Woodmodelwood64.pt
Zippermodelzipper64.pt

Model Details

PropertyValue
ModelVAE-GAN
Training SettingOne-Class Learning
Training DataNormal Samples Only
Input Size128 × 128 × 3
Latent Dimension64
FrameworkPyTorch

Checkpoint Structure

Each checkpoint contains:

python
{
    "encoder_state_dict": ...,
    "decoder_state_dict": ...,
    "discriminator_state_dict": ...
}

Loading a Checkpoint

python
import torch

checkpoint = torch.load(
    "model_bottle_64.pt",
    map_location="cpu",
    weights_only=False
)

encoder.load_state_dict(checkpoint["encoder_state_dict"])
decoder.load_state_dict(checkpoint["decoder_state_dict"])
discriminator.load_state_dict(checkpoint["discriminator_state_dict"])

encoder.eval()
decoder.eval()
discriminator.eval()

Example Anomaly Score

python
with torch.no_grad():
    mu, logvar = encoder(image)
    z = reparameterize(mu, logvar)
    reconstruction = decoder(z)

anomaly_map = torch.abs(image - reconstruction).mean(dim=1)
anomaly_score = anomaly_map.mean().item()

Device Support

The checkpoints can be loaded on:

  • —CPU
  • —NVIDIA CUDA GPUs
  • —Apple Silicon (MPS)
python
import torch

if torch.cuda.is_available():
    device = "cuda"
elif torch.backends.mps.is_available():
    device = "mps"
else:
    device = "cpu"

Intended Use

This repository is intended for research on:

  • —Visual Anomaly Detection
  • —Reconstruction-Based Anomaly Scoring
  • —Threshold Calibration
  • —Multi-Point Thresholding
  • —Explainable Anomaly Detection
  • —Industrial Inspection Systems

Limitations

  • —Models are trained on resized 128×128 images.
  • —Performance depends on preprocessing, anomaly score design, and threshold selection.
  • —These checkpoints are intended for research purposes and should be validated before deployment in industrial or safety-critical environments.

Citation

bibtex
@misc{rao2026vaeganmvtec,
  title={VAE-GAN Checkpoints for MVTec Anomaly Detection},
  author={Rao, Rashid},
  year={2026},
  publisher={Hugging Face},
  url={https://huggingface.co/rashidrao/AnomalyDetection}
}

Author

Rashid Rao Industrial PhD Researcher University of Turin, Italy

Research Areas:

  • —Explainable AI (XAI)
  • —Visual Anomaly Detection
  • —Trustworthy AI
  • —Industrial AI Systems