Metadata-Version: 2.4
Name: vaas
Version: 0.2.0
Summary: VAAS (Vision-Attention Anomaly Scoring) is a dual-module vision framework for image anomaly detection and localisation.
Author: Opeyemi Bamigbade, Mark Scanlon, John Sheppard
Project-URL: Homepage, https://github.com/OBA-Research/VAAS
Project-URL: Repository, https://github.com/OBA-Research/VAAS
Project-URL: Documentation, https://github.com/OBA-Research/VAAS#readme
Project-URL: Issues, https://github.com/OBA-Research/VAAS/issues
Project-URL: HuggingFace, https://huggingface.co/OBA-Research/vaas
Keywords: anomaly detection,computer vision,vision transformers,deep learning,image forensics,representation learning
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Image Processing
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
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: transformers>=4.40
Requires-Dist: numpy
Requires-Dist: pillow
Requires-Dist: tqdm
Requires-Dist: scipy
Requires-Dist: opencv-python-headless
Requires-Dist: matplotlib>=3.10.8
Dynamic: license-file

# VAAS — Vision-Attention Anomaly Scoring

VAAS is a research-driven, inference-first dual-module vision framework for image anomaly detection and localisation.

It integrates global attention-based reasoning with patch-level consistency analysis to produce:

- A continuous hybrid anomaly score (`S_H`)
- Dense spatial anomaly maps
- Interpretable attention overlays

The output is spatially grounded, explainable, and suitable for research and prototyping workflows.

> This package provides the **runtime inference pipeline only**.  
> Pretrained model weights are hosted separately on Hugging Face.

[Research Paper](https://arxiv.org/pdf/2512.15512) |
[GitHub](https://github.com/OBA-Research/VAAS) |
[Hugging Face Models](https://huggingface.co/OBA-Research/vaas)

---

## Installation

```bash
pip install vaas
```

### Optional dependency: PyTorch

VAAS uses **lazy loading** for PyTorch.

- Importing `vaas` does **not** require PyTorch  
- PyTorch is required **only when running inference**  

If PyTorch is not installed, VAAS will raise a clear runtime error when inference is invoked.

Install PyTorch (CPU, CUDA, or ROCm) from:  
https://pytorch.org/get-started/locally/

---

## Quick Start

```python
from vaas.inference.pipeline import VAASPipeline
from PIL import Image

pipeline = VAASPipeline.from_pretrained(
    repo_id="OBA-Research/vaas",
    device="cpu",
    alpha=0.5,
    model_variant="v2-base-df2023"  # v2-medium-df2023 and v2-large-df2023 are also available
)

image = Image.open("image.jpg").convert("RGB")
result = pipeline(image)

print(result["S_H"])
```

---

### Output format

```python
{
    "S_F": float,
    "S_P": float,
    "S_H": float,
    "anomaly_map": ndarray  # shape (224, 224)
}
```

---

## Visualisation

Generate qualitative visual explanations combining:

- Patch-level anomaly heatmaps  
- Global attention overlays  
- A hybrid anomaly score gauge  

```python
pipeline.visualize(
    image="image.jpg",
    save_path="vaas_visualization.png",
    mode="all",
    threshold=0.5,
)
```

---

## Model Variants

VAAS models are versioned by architecture, scale, and dataset.

### Current (v2)

- v2-base-df2023  
- v2-medium-df2023  
- v2-large-df2023  

### Legacy (v1)

- v1-base-df2023  
- v1-medium-df2023  
- v1-large-df2023  

Each variant is stored as a versioned branch on Hugging Face.

See:
- https://github.com/OBA-Research/VAAS  
- https://huggingface.co/OBA-Research/vaas  

---

## Reproducibility

Each published model variant contains structured metadata:

- Architecture version  
- Dataset  
- Dataset fraction  
- Runtime defaults  
- Backbone configuration  

This ensures reproducible loading and transparent model lineage.

---

## Intended Use

VAAS is intended for:

- Image anomaly detection  
- Visual integrity assessment  
- Explainable inspection of irregular regions  
- Research on attention-based anomaly scoring  
- Digital forensics research  
- Prototyping anomaly-aware vision systems  

Supports CPU-only inference and GPU acceleration.

---

## Limitations

- Trained on a single dataset  
- Does not classify anomaly types  
- Performance may degrade on out-of-distribution imagery  

VAAS should not be used as a standalone decision-making system in high-stakes applications.

---

## Citation

If you use VAAS in your research, please cite both the software and the associated paper.

### Software Citation

```bibtex
@software{vaas,
  title        = {VAAS: Vision-Attention Anomaly Scoring},
  author       = {Bamigbade, Opeyemi and Scanlon, Mark and Sheppard, John},
  year         = {2025},
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.18064355},
  url          = {https://doi.org/10.5281/zenodo.18064355}
}
```

### Paper Citation

```bibtex
@article{BAMIGBADE2026302063,
title = {VAAS: Vision-Attention Anomaly Scoring for image manipulation detection in digital forensics},
journal = {Forensic Science International: Digital Investigation},
volume = {56},
pages = {302063},
year = {2026},
note = {DFRWS EU 2026 - Selected Papers from the 13th Annual Digital Forensics Research Conference Europe},
issn = {2666-2817},
doi = {https://doi.org/10.1016/j.fsidi.2026.302063},
url = {https://www.sciencedirect.com/science/article/pii/S266628172600020X},
author = {Opeyemi Bamigbade and Mark Scanlon and John Sheppard},
keywords = {Digital forensics, Image manipulation detection, Tamper localisation, Explainable AI, Vision transformers, Segmentation, Attention mechanisms, Anomaly scoring},
abstract = {Recent advances in AI-driven image generation have introduced new challenges for verifying the authenticity of digital evidence in forensic investigations. Modern generative models can produce visually consistent forgeries that evade traditional detectors based on pixel or compression artefacts. Most existing approaches also lack an explicit measure of anomaly intensity, which limits their ability to quantify the severity of manipulation. This paper introduces Vision-Attention Anomaly Scoring (VAAS), a novel dual-module framework that integrates global attention-based anomaly estimation using Vision Transformers (ViT) with patch-level self-consistency scoring derived from segmentation embeddings. The hybrid formulation provides a continuous and interpretable anomaly score that reflects both the location and degree of manipulation. Evaluations on the DF2023 and CASIA v2.0 datasets demonstrate that vaas achieve competitive F1 and IoU performance, while enhancing visual explainability through attention-guided anomaly maps. The framework bridges quantitative detection with human-understandable reasoning, supporting transparent and reliable image integrity assessment. The source code for all experiments and corresponding materials for reproducing the results are available open source.}
}
```

---

## Contributing

We welcome contributions that improve the usability, robustness, and extensibility of VAAS.

See:
https://github.com/OBA-Research/VAAS/blob/main/CONTRIBUTING.md

---

## License

MIT License

---

## Maintainers

OBA-Research

- https://github.com/OBA-Research  
- https://huggingface.co/OBA-Research  
