Simple visual anomaly detection from normal images.
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.
New here? Start with the five-minute quickstart.
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
uv pip install "anomavision[cpu]"
uv pip install "anomavision[cu121]"
For other environments, see Installation.
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.
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.
anomavision train --config config.yml
For a quick EfficientAD configuration, see examples/efficientad_cpu.yml.
anomavision detect --config config.yml --model model.pt --img_path ./test_images
anomavision export --config config.yml --model model.pt --format onnx
anomavision eval --config config.yml --model model.pt --class_name bottle
For EfficientAD-specific options and limitations, see EfficientAD.
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 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.
| 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 |
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)
AnomaVision is released under the MIT License. See LICENSE.
Found a problem or have an idea? Feel free to open an issue or contribute to the project.