AnomaVision

AnomaVision banner

Simple visual anomaly detection from normal images.

PyPI version PyPI downloads Python 3.10 to 3.12 PyTorch 2.0 or newer ONNX export ready TensorRT supported OpenVINO supported CI status MIT license KV260 DPU support

AnomaVision is a computer vision project for finding defects and unusual patterns in images.

It supports three anomaly detection methods:

You only need normal (good) images to train the anomaly detector.

Open the AnomaVision live demo

New here? Start with the five-minute quickstart.

What can AnomaVision do?

Quick start

1. Install

Option A — From Source (development)

git clone https://github.com/DeepKnowledge1/AnomaVision.git
cd AnomaVision
uv venv --python 3.11 .venv
source .venv/bin/activate        # Windows: .venv\\Scripts\\Activate.ps1
uv sync --extra cpu              # CPU
uv sync --extra cu121            # CUDA 12.1

Option B — From PyPI (production / quick start)

uv pip install "anomavision[cpu]"
uv pip install "anomavision[cu121]"

For other environments, see Installation.

2. Prepare your images

Use a simple MVTec-style folder structure:

dataset/
└── bottle/
    ├── ground_truth/
    ├── test/
    │   ├── broken_large/
    │   ├── broken_small/
    │   ├── contamination/
    │   └── good/
    └── train/
        └── good/

Training uses the good images. Test images can contain defects.

3. Choose an algorithm

The existing configuration format works unchanged:

algorithm: padim

Switch to EfficientAD by changing one value:

algorithm: efficientad

You can also use the native model selector:

model:
  name: efficientad

The CLI commands remain the same.

4. Train

anomavision train --config config.yml

For a quick EfficientAD configuration, see examples/efficientad_cpu.yml.

5. Detect

anomavision detect --config config.yml --model model.pt --img_path ./test_images

6. Export

anomavision export --config config.yml --model model.pt --format onnx

7. Evaluate

anomavision eval --config config.yml --model model.pt --class_name bottle

For EfficientAD-specific options and limitations, see EfficientAD.

KV260 support

AnomaVision also supports a Vitis AI workflow for PaDiM and PatchCore on the AMD/Xilinx Kria KV260.

The workflow is:

PyTorch → INT8 quantization → XModel → KV260 DPU compilation

Both PaDiM and PatchCore currently compile with 1 DPU subgraph in the KV260 compiler.

The complete setup and commands are in the KV260 XModel Guide.

XModel compilation has been validated in the Vitis AI environment. Final on-device KV260 validation requires the physical hardware.

Production Autopilot

Production Autopilot is the easiest way to move from two trained models to one deployable choice. It compares PaDiM and ultra-light PatchCore on the same labeled test split, calibrates a separate threshold for each, profiles median and P95 latency on your hardware, checks localization health, and packages the selected artifact with a self-contained HTML dashboard.

Train both candidate models first, then run the complete labeled split on CPU:

anomavision autopilot `
  --config config.yml `
  --padim_model ./distributions/padim/bottle/anomav_exp/model.pt `
  --patchcore_model ./distributions/patchcore/bottle/anomav_exp/model.pt `
  --efficientad_model ./distributions/efficientad/bottle/anomav_exp/model.onnx `
  --device cpu `
  --validation_split 1.0 `
  --target_latency_ms 50 `
  --output_dir ./production_package

Open production_package/production_autopilot_report.html to see the selected model, AUROC, calibrated threshold, localization diagnostics, memory, median latency, P95 latency, and deployment recommendation. See docs/production_deployment.md for details.

Documentation

Topic Guide
Quick start docs/quickstart.md
Installation docs/installation.md
CLI and configuration docs/cli.md, docs/config.md
EfficientAD docs/efficientad.md
Python API docs/api.md
KV260 / XModel docs/kv260_xmodel.md
Production deployment docs/production_deployment.md
Benchmarks docs/benchmark.md
Troubleshooting docs/troubleshooting.md
Examples examples/README.md
Contributing docs/contributing.md

Python example

import torch
import anomavision
from torch.utils.data import DataLoader

train_set = anomavision.AnodetDataset("./dataset/bottle/train/good")
train_loader = DataLoader(train_set, batch_size=1, shuffle=False)

model = anomavision.EfficientAD(device=torch.device("cpu"))
model.fit(train_loader, epochs=1)

batch = next(iter(train_loader))[0]
scores, maps = model.predict(batch)

License

AnomaVision is released under the MIT License. See LICENSE.

Questions and contributions

Found a problem or have an idea? Feel free to open an issue or contribute to the project.