Metadata-Version: 2.5
Name: anomavision
Version: 3.6.2
Summary: Advanced Anomaly Detection Environment - Production Ready
Author-email: Deep Knowledge <Deepp.Knowledge@gmail.com>
License: MIT
License-File: LICENSE
Keywords: PaDim,anomaly,anomaly-detection,computer-vision,vision
Requires-Python: <3.13,>=3.10
Requires-Dist: easydict==1.13
Requires-Dist: fastapi>=0.127.0
Requires-Dist: gradio>=6.3.0
Requires-Dist: matplotlib==3.8.3
Requires-Dist: numpy==1.26.4
Requires-Dist: onnx>=1.15.0
Requires-Dist: onnxruntime>=1.16.0
Requires-Dist: onnxscript>=0.6.2
Requires-Dist: opencv-python>=4.6.0
Requires-Dist: openvino-dev>=2024.0
Requires-Dist: pydantic>=2.12.5
Requires-Dist: pytest>=8.0.2
Requires-Dist: python-multipart==0.0.20
Requires-Dist: scikit-image==0.22.0
Requires-Dist: scikit-learn<1.4,>=1.2
Requires-Dist: streamlit>=1.52.2
Requires-Dist: tqdm>=4.67.1
Requires-Dist: uvicorn>=0.30.0
Provides-Extra: cpu
Requires-Dist: torch>=2.4.0; extra == 'cpu'
Requires-Dist: torchaudio>=2.4.0; extra == 'cpu'
Requires-Dist: torchvision>=0.19.0; extra == 'cpu'
Provides-Extra: cu118
Requires-Dist: torch>=2.4.0; extra == 'cu118'
Requires-Dist: torchaudio>=2.4.0; extra == 'cu118'
Requires-Dist: torchvision>=0.19.0; extra == 'cu118'
Provides-Extra: cu121
Requires-Dist: torch>=2.4.0; extra == 'cu121'
Requires-Dist: torchaudio>=2.4.0; extra == 'cu121'
Requires-Dist: torchvision>=0.19.0; extra == 'cu121'
Provides-Extra: cu124
Requires-Dist: torch>=2.4.0; extra == 'cu124'
Requires-Dist: torchaudio>=2.4.0; extra == 'cu124'
Requires-Dist: torchvision>=0.19.0; extra == 'cu124'
Provides-Extra: dev
Requires-Dist: black==24.2.0; extra == 'dev'
Requires-Dist: flake8==7.0.0; extra == 'dev'
Requires-Dist: pre-commit==3.6.2; extra == 'dev'
Requires-Dist: pytest==8.0.2; extra == 'dev'
Description-Content-Type: text/markdown

# AnomaVision

<p align="center">
  <img src="docs/images/banner.png" width="100%" alt="AnomaVision banner"/>
</p>

<p align="center"><strong>Simple visual anomaly detection from normal images.</strong></p>

AnomaVision is a production-oriented computer vision toolkit for detecting **defects and unusual patterns** from normal images.

Supported methods:
- **PaDiM**
- **PatchCore**
- **EfficientAD**

It supports training, evaluation, threshold calibration, ONNX/OpenVINO/TensorRT export where supported, KV260/XModel deployment, **production data-drift monitoring**, and **non-invasive deployment validation**.

## 🚀 Quick start

### 📦 Install

```bash
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
```

### 🧠 Train

```bash
anomavision train --config config.yml
```

### 🔍 Detect

```bash
anomavision detect --config config.yml --img_path ./dataset/bottle/test
```

### 📤 Export

```bash
anomavision export --config config.yml --format onnx
```

---

## 🛡️ Deployment validation

Validate exported models before deployment without changing the anomaly-detection algorithm.

It checks **model integrity, inference, performance, backend compatibility, and output consistency** against a reference model.

```powershell
anomavision validate `
  --model model.onnx `
  --reference-model model.pt `
  --config config.yml
  ```

## 🛡️ Deployment validation

Before moving an exported model into production, AnomaVision can validate the deployment artifact without changing the underlying anomaly-detection algorithm.

It checks model integrity, inference, performance, supported backend availability, and—when a reference model is supplied—output consistency.

### Quick example

```powershell
anomavision validate `
  --model distributions\\padim\\bottle\\anomav_exp\\model.onnx `
  --config config.yml `
  --runs 20
```

Typical output includes:

```text
AnomaVision Deployment Validation
────────────────────────────────────
Model: distributions\padim\bottle\anomav_exp\model.onnx
✓ File Exists
✓ Onnx Valid
✓ Onnxruntime Inference
✓ Static Input Shape
Latency: 11.020 ms
FPS:     90.75
....
```

Supported deployment artifacts include PyTorch, TorchScript, ONNX, TensorRT, OpenVINO, Hailo HEF, and Vitis AI/KV260 XModel.

**Note:** backend availability means the required runtime components are installed. It does not by itself prove that a specific model has been tested on physical target hardware.

See the [Deployment Validation guide](docs/deployment_validation.md) for all options, consistency validation, JSON output, backend details, and recommended production usage.

## 📡 Production data drift

Production data-drift monitoring helps detect changes in the data seen by an anomaly detector after deployment.

It compares production representations against a trusted **normal reference population** using a rolling window. It can report metrics such as **PSI, mean shift, standard-deviation shift, cosine shift, and drift score**, with the result available through a dashboard and JSON status file.

The monitor is an **observer only**: it does not change anomaly scores or localization. Drift is an early-warning signal that should be investigated for causes such as lighting, camera position, preprocessing, or product changes.

### Quick example

```powershell
anomavision detect `
  --config config.yml `
  --model model.onnx `
  --enable-drift-monitoring `
  --drift-reference .\\drift\\reference_embeddings.npy
```

See the [Production Data Drift guide](docs/anomaly_detection_production_data_drift.md) for reference generation, metrics, dashboard, configuration, and troubleshooting.

---

## 📊 Benchmarks

AnomaVision includes a reproducible benchmark workflow for comparing anomaly-detection performance and runtime characteristics.

The benchmark reports **Image AUROC, Pixel AUROC, latency, P95 latency, FPS, model/artifact size, and memory usage**. The current comparison script uses a shared evaluation contract so results can be reproduced consistently.

### Quick example

Run a single class:

```powershell
python scripts\\benchmarks\\compare_with_anomalib.py `
  --dataset_path D:\\01-DATA `
  --class_name bottle `
  --algorithms padim `
  --device cpu
```

Run all available MVTec classes:

```powershell
python scripts/benchmarks/compare_with_anomalib.py `
  --dataset_path D:/01-DATA/VisA_pytorch `
  --all_classes `
  --algorithms padim `
  --device cpu
```

With `--all_classes`, the script automatically discovers supported MVTec class directories present under the dataset path and runs the same AnomaVision-vs-Anomalib comparison for each available class. `--class_name` and `--all_classes` are mutually exclusive. Results are written separately under `benchmark_results/<algorithm>/<class_name>/`.

Historical benchmark results are available for **MVTec AD and VisA**, including per-class results and visual comparisons. These results are retained for reference; the corrected benchmark should be rerun before making current performance claims.

See the [Benchmark guide](docs/benchmark.md) for the methodology, commands, metrics, and detailed results.

---

## ⚡ KV260 support

AnomaVision supports a **Vitis AI workflow for PaDiM and PatchCore on the AMD/Xilinx Kria KV260**. XModel compilation has been validated in the Vitis AI environment; final on-device validation requires the physical hardware.

## 📚 Documentation

| Topic | Guide |
|---|---|
| Quick start | [docs/quickstart.md](docs/quickstart.md) |
| Installation | [docs/installation.md](docs/installation.md) |
| CLI / configuration | [docs/cli.md](docs/cli.md), [docs/config.md](docs/config.md) |
| Python API | [docs/api.md](docs/api.md) |
| **Deployment validation** | [docs/deployment_validation.md](docs/deployment_validation.md) |
| **Production data drift** | [docs/anomaly_detection_production_data_drift.md](docs/anomaly_detection_production_data_drift.md) |
| KV260 / XModel | [docs/kv260_xmodel.md](docs/kv260_xmodel.md) |
| Production deployment | [docs/production_deployment.md](docs/production_deployment.md) |
| Benchmarks | [docs/benchmark.md](docs/benchmark.md) |
| Troubleshooting | [docs/troubleshooting.md](docs/troubleshooting.md) |

## 📄 License

AnomaVision is released under the **MIT License**. See [LICENSE](LICENSE).
