AnomaVision
Production-oriented visual anomaly detection from normal images.
AnomaVision supports PaDiM and lightweight PatchCore, image-level scores, pixel-level maps, and deployment exports.
Try it first: live demo · five-minute CPU quickstart · runnable examples · reproducible benchmark
Why use it?
- Train with normal images only; anomaly labels are not required for training.
- Use PaDiM for the default fast baseline or PatchCore for a compact nearest-neighbor memory bank.
- Run inference through PyTorch, ONNX Runtime, OpenVINO, or native TensorRT.
- Export FP16 or calibrated INT8 TensorRT engines for NVIDIA production deployments.
Benchmark results and reproduction details are documented in docs/benchmark.md. Treat benchmark numbers as workload-specific, and reproduce them on your own hardware before making production claims.
Quickstart
1. Install
pip install uv
uv pip install "anomavision[cpu]"
For NVIDIA GPUs, choose the matching extra such as anomavision[cu121]. Source installation and environment setup are described in docs/installation.md. For the shortest CPU path, use the copy-ready examples/quickstart_cpu.yml configuration and follow docs/quickstart.md.
2. Prepare data
Use an MVTec-style directory. Training uses only the good images:
dataset/
└── bottle/
├── train/good/
└── test/
├── good/
└── scratch/
3. Train
Before running the command, open config.yml and set dataset_path to the folder that contains your class folder, for example ./dataset. Keep class_name: bottle if your data is stored under ./dataset/bottle/.
anomavision train --config config.yml
The default configuration trains PaDiM. To use the ultra-light PatchCore path, change these values in config.yml:
algorithm: patchcore
layer_indices: [0]
coreset_ratio: 0.02
max_memory_patches: 2048
patch_grid: 14
The model and compact deployment artifact are saved under model_data_path.
4. Detect and evaluate
anomavision detect --config config.yml --img_path ./dataset/bottle/test
anomavision eval --config config.yml
5. Export
# Portable ONNX export
anomavision export --config config.yml --format onnx
# Native TensorRT FP16 export
anomavision export --config config.yml --format tensorrt \
--device cuda --tensorrt-precision fp16
# Native TensorRT calibrated INT8 export
anomavision export --config config.yml --format tensorrt \
--device cuda --tensorrt-precision int8 \
--calib-dir ./dataset/bottle/train/good --calib-samples 100
Every command provides help:
anomavision --help
anomavision train --help
anomavision export --help
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 \
--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. The package also contains deployment_manifest.json, localization_report.md, and the selected model artifact. See docs/production_deployment.md for GPU, TensorRT, INT8, and packaging details.
Visual overview
The same pipeline supports compact edge inference and spatial anomaly localization. In each result strip, the panels show the input image, the detected boundary, and the anomaly heatmap from left to right.
PaDiM: distribution-based heatmap
PaDiM models the feature distribution of normal images. Its heatmap is typically smoother and emphasizes regions that differ from that learned distribution.
Ultra-light PatchCore: nearest-patch heatmap
PatchCore compares image patches with a compact normal-feature memory bank. Its heatmap can show more local texture and sharper nearest-patch differences while using bounded memory for production inference.
Choosing a model
| Model | Best starting point | Memory use | Production note |
|---|---|---|---|
| PaDiM | Fast, simple baseline | Low | Recommended first experiment |
| Lightweight PatchCore | Lower-memory nearest-patch baseline | Very low by default | Use coreset_ratio, max_memory_patches, and patch_grid to control latency |
Documentation
| Topic | Guide |
|---|---|
| Installation | docs/installation.md |
| Five-minute workflow | docs/quickstart.md |
| CLI and configuration | docs/cli.md, docs/config.md |
| Python API | docs/api.md |
| PatchCore and TensorRT deployment | docs/production_deployment.md |
| Runnable CPU, PatchCore, and TensorRT examples | examples/README.md |
| Benchmark methodology | docs/benchmark.md |
| Troubleshooting | docs/troubleshooting.md |
| Contributing | docs/contributing.md |
Python API
import torch
from torch.utils.data import DataLoader
import anomavision
train_set = anomavision.AnodetDataset("./dataset/bottle/train/good")
train_loader = DataLoader(train_set, batch_size=16, shuffle=False)
model = anomavision.Padim(backbone="resnet18", device=torch.device("cpu"))
model.fit(train_loader)
batch = next(iter(train_loader))
if isinstance(batch, (tuple, list)):
batch = batch[0]
scores, maps = model.predict(batch)
Community and adoption
The most useful path to adoption is a small, reproducible example rather than more README text: publish one benchmark script, one production export example, a model card with hardware and preprocessing details, and a short comparison against Anomalib. Invite users to reproduce the result, report failures, and contribute adapters for their own datasets. See docs/production_deployment.md for the project’s recommended release checklist.
License
AnomaVision is released under the MIT License. See LICENSE.
Metadata
Release files for anomavision 3.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| anomavision-3.5.0.tar.gz | 8.0 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| anomavision-3.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.2 MB
Release files / anomavision-3.5.0.tar.gz
| Download URL | anomavision-3.5.0.tar.gz |
|---|---|
| Size | 8.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ab5f0f0dcae926b3405baa077d053687389839ad8b48445ade7ef3380b62e95
|
|
BLAKE2b-256 checksum How to use checksums |
2a2154023912149d3109146b73a16bd330a892af8232ee625afb5a2649645076
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.
Transparency logRelease files / anomavision-3.5.0-py3-none-any.whl
| Download URL | anomavision-3.5.0-py3-none-any.whl |
|---|---|
| Size | 129.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
669fbfffe3b8fe53247383db68c887e55d38026e6a296855d2eb67ebdb33e997
|
|
BLAKE2b-256 checksum How to use checksums |
22d2e9165dafbc19ee475ee2ed0090e839f955ed12205ee3ccea0c214aba2034
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 23, 2026.
Transparency log