Metadata-Version: 2.4
Name: anomavision
Version: 3.1.0
Summary: Advanced Anomaly Detection Environment - Deep learning library for state-of-the-art anomaly detection algorithms
License: MIT
License-File: LICENSE
Keywords: anomaly,vision,computer-vision,anomaly-detection,PaDim
Author: Deep Knowledge
Author-email: Deepp.Knowledge@gmail.com
Requires-Python: >=3.10,<3.13
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Provides-Extra: cpu
Provides-Extra: cu118
Provides-Extra: cu121
Provides-Extra: cu124
Provides-Extra: full
Requires-Dist: easydict (==1.13)
Requires-Dist: fastapi (>=0.127.0,<0.128.0)
Requires-Dist: matplotlib (==3.8.3)
Requires-Dist: numpy (==1.26.4)
Requires-Dist: onnx (>=1.15.0,<2.0.0)
Requires-Dist: onnxruntime (>=1.16.0,<1.18) ; extra == "cpu" or extra == "full"
Requires-Dist: onnxruntime-gpu (>=1.16.0) ; extra == "cu118" or extra == "cu121" or extra == "cu124" or extra == "full"
Requires-Dist: opencv-python (>=4.6.0,<5.0.0)
Requires-Dist: openvino-dev (>=2024.0)
Requires-Dist: pydantic (>=2.12.5,<3.0.0)
Requires-Dist: python-multipart (==0.0.20)
Requires-Dist: ruamel-yaml (>=0.18.16,<0.19.0)
Requires-Dist: scikit-image (==0.22.0)
Requires-Dist: scikit-learn (>=1.2,<1.4)
Requires-Dist: streamlit (>=1.52.2,<2.0.0)
Requires-Dist: torch (>=2.4.0) ; extra == "cpu" or extra == "cu118" or extra == "cu121" or extra == "cu124" or extra == "full"
Requires-Dist: torchaudio (>=2.4.0) ; extra == "cpu" or extra == "cu118" or extra == "cu121" or extra == "cu124" or extra == "full"
Requires-Dist: torchvision (>=0.19.0) ; extra == "cpu" or extra == "cu118" or extra == "cu121" or extra == "cu124" or extra == "full"
Requires-Dist: tqdm (>=4.67.1,<5.0.0)
Requires-Dist: uvicorn (>=0.30.0,<0.31.0)
Project-URL: Documentation, https://github.com/DeepKnowledge1/AnomaVision/wiki
Project-URL: Homepage, https://github.com/DeepKnowledge1
Project-URL: Repository, https://github.com/DeepKnowledge1/AnomaVision
Description-Content-Type: text/markdown

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

# AnomaVision: Edge-Ready Visual Anomaly Detection

<!-- Row 1: Language + Frameworks -->
[![Python 3.9–3.12](https://img.shields.io/badge/python-3.9–3.12-blue.svg)](https://www.python.org/)
[![PyTorch 2.0+](https://img.shields.io/badge/pytorch-2.0+-red.svg)](https://pytorch.org)
[![ONNX Ready](https://img.shields.io/badge/ONNX-Export%20Ready-orange.svg)](https://onnx.ai/)
[![OpenVINO Ready](https://img.shields.io/badge/OpenVINO-Ready-blue.svg)](https://docs.openvino.ai/)
[![TorchScript](https://img.shields.io/badge/Export-TorchScript-red.svg)](https://pytorch.org/docs/stable/jit.html)
[![TensorRT](https://img.shields.io/badge/Deploy-TensorRT-green.svg)](https://developer.nvidia.com/tensorrt)
[![Quantization](https://img.shields.io/badge/Optimized-Quantization-purple.svg)](https://onnxruntime.ai/docs/performance/quantization.html)

<!-- Row 2: Distribution + License -->
[![PyPI Version](https://img.shields.io/pypi/v/anomavision?label=PyPI%20version)](https://pypi.org/project/anomavision/)
[![PyPI Downloads](https://img.shields.io/pypi/dm/anomavision?label=PyPI%20downloads&color=blue)](https://pypi.org/project/anomavision/)
[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](LICENSE)


**Lightweight, fast, and production-ready anomaly detection powered by PaDiM.**
*Deploy anywhere: edge devices, servers, or the cloud.*

---

## Overview

AnomaVision delivers state-of-the-art visual anomaly detection optimized for real-world deployment. Built for speed and efficiency, it outperforms existing solutions while maintaining a small footprint perfect for edge devices.

### Key Features

- 🎯 **Superior Performance** — Higher AUROC across MVTec AD and Visa datasets
- ⚡ **3× Faster Inference** — Optimized for both CPU and GPU deployment
- 📦 **Smaller Models** — 30MB models with lower memory footprint
- 🌐 **Multi-Backend Export** — PyTorch, ONNX, TorchScript, OpenVINO, TensorRT, INT8 Quantization
- 🖥️ **Production Ready** — Python API, CLI tools, C++ runtime, and REST API
- 🎨 **Rich Visualizations** — Heatmaps, bounding boxes, and ROC curves
- 🎮 **Interactive Demo** — Streamlit web interface for instant testing

---

## Why Choose AnomaVision?

<h3 style="color:red;">Performance Advantages Over Anomalib</h3>

**CPU Inference:**

| Metric | AnomaVision | Anomalib | Improvement |
|:--|--:|--:|--:|
| Training Time (s) | **8.38** | 13.07 | **-35.9%** |
| Inference FPS | **43.41** | 13.03 | **+233%** |
| ms / image | **23.0** | 76.7 | **-70%** |

**GPU Inference (CUDA):**

| Metric | AnomaVision | Anomalib | Improvement |
|:--|--:|--:|--:|
| Training Time (s) | **8.38** | 13.07 | **-35.9%** |
| Inference FPS | **547.46** | 355.72 | **+53.9%** |
| ms / image | **1.83** | 2.81 | **-35.0%** |

**Accuracy:**

- **MVTec AD:** Image AUROC 0.85 vs 0.81 | Pixel AUROC 0.96 vs 0.94
- **Visa:** Image AUROC 0.81 vs 0.78 | Pixel AUROC 0.96 vs 0.95

💡 [Download Full Performance Analysis (PDF)](docs/AnomaVision_vs_Anomalib.pdf) | [Detailed Benchmarks](docs/benchmark.md)

---

## Quick Start

### Installation

**Using Poetry (Recommended):**
```bash
git clone https://github.com/DeepKnowledge1/AnomaVision.git
cd AnomaVision
poetry install
poetry shell
```

**Using pip:**
```bash
pip install AnomaVision
```

📖 [Detailed Installation Guide](docs/installation.md)

### Basic Usage

**Training:**
```bash
python train.py --config config.yml
# Outputs: padim_model.pt, padim_model.pth, config.yml
```

**Detection:**
```bash
python detect.py --config config.yml
```

**Evaluation:**
```bash
python eval.py --config config.yml
```

**Export:**
```bash
python export.py --config export_config.yml
```

📖 [Complete Quick Start Guide](docs/quickstart.md)

---

## Interactive Demo

<div align="left">
  <img src="docs/images/streamlit.png" alt="AnomaVision Streamlit Demo" width="50%">
  <p><em>Real-time anomaly detection with explainable heatmaps</em></p>
</div>

Experience AnomaVision through our intuitive web interface:

- ⚡ Real-time anomaly detection
- 🎯 Explainable AI with visual heatmaps
- 📊 Interactive threshold controls
- 🔍 Batch processing support
- 💾 Export results as JSON
- 🎮 No coding required

### Launch the Demo

```bash
# Start FastAPI backend
uvicorn apps.api.fastapi_app:app --host 0.0.0.0 --port 8000

# Launch Streamlit demo (new terminal)
streamlit run apps/ui/streamlit_app.py -- --port 8000
```

Open `http://localhost:8501` in your browser.

📖 [Streamlit Demo Guide](docs/streamlit_demo.md)

---

## Deployment Options

| Method | Best For | Key Benefits |
|:-------|:---------|:-------------|
| 🎨 **Streamlit Demo** | Testing, demonstrations | Zero-code UI, instant feedback |
| 📌 **FastAPI Backend** | Production APIs | REST endpoints, scalable |
| 🖥️ **C++ Runtime** | Edge devices | No Python dependency, ultra-fast |
| 💻 **Python CLI** | Batch processing | Scriptable, configurable |
| 📦 **PyPI Package** | Custom integration | Import as library |

### REST API Example

```python
import requests

with open("test_image.jpg", "rb") as f:
    response = requests.post(
        "http://localhost:8000/predict",
        files={"file": f},
        params={"include_visualizations": True}
    )
    result = response.json()
    print(f"Anomaly Score: {result['anomaly_score']}")
    print(f"Is Anomaly: {result['is_anomaly']}")
```

📖 [FastAPI Setup Guide](docs/fastapi_backend.md)

### C++ Inference

Deploy without Python using our ONNX Runtime + OpenCV implementation:

- 🖼️ Complete pipeline from preprocessing to visualization
- 📦 Modular architecture
- 🌐 Perfect for edge devices

📖 [C++ Inference Guide](docs/cpp/README.md)

---

## Use Cases

- 🏭 **Manufacturing QC** — Real-time defect detection on production lines
- 🔬 **Medical Imaging** — Anomaly identification in X-rays, MRIs, microscopy
- 🏗️ **Infrastructure** — Crack and corrosion detection
- 📱 **PCB Inspection** — Soldering defects and component issues
- 🌾 **Agriculture** — Plant disease and crop monitoring
- 🚗 **Automotive** — Paint defects and assembly quality

---

## Documentation

- 📖 [Installation](docs/installation.md)
- 🚀 [Quick Start](docs/quickstart.md)
- 🎨 [Streamlit Demo](docs/streamlit_demo.md)
- 📌 [FastAPI Backend](docs/fastapi_backend.md)
- 💻 [CLI Reference](docs/cli.md)
- 📚 [API Reference](docs/api.md)
- ⚙️ [Configuration](docs/config.md)
- 📊 [Benchmarks](docs/benchmark.md)
- 🔧 [Troubleshooting](docs/troubleshooting.md)
- 🤝 [Contributing](docs/contributing.md)

---

## Community & Support

- 💬 [GitHub Discussions](https://github.com/DeepKnowledge1/AnomaVision/discussions)
- 🐛 [Issue Tracker](https://github.com/DeepKnowledge1/AnomaVision/issues)
- 📧 [Email Support](mailto:deepp.knowledge@gmail.com)

---

## Citation

```bibtex
@software{anomavision2025,
  title={AnomaVision: Edge-Ready Visual Anomaly Detection},
  author={DeepKnowledge Contributors},
  year={2025},
  url={https://github.com/DeepKnowledge1/AnomaVision},
}
```

---

## Acknowledgments

Built on the foundation of [Anodet](https://github.com/OpenAOI/anodet). We thank the original authors for their contributions to open-source anomaly detection research.

---

## License

Released under the [MIT License](LICENSE).

---

**Ready to get started?** Follow our [Quick Start Guide](docs/quickstart.md) and build your first anomaly detection pipeline in 5 minutes!

