Update README.md
Browse files
README.md
CHANGED
|
@@ -29,10 +29,12 @@ tags:
|
|
| 29 |
|
| 30 |
VAAS (Vision-Attention Anomaly Scoring) is a dual-module vision framework for **image anomaly detection and localization**.
|
| 31 |
It combines **global attention-based reasoning** with **patch-level self-consistency analysis** to produce a **continuous, interpretable anomaly score** alongside dense spatial anomaly maps.
|
| 32 |
-
|
| 33 |
Rather than making binary decisions, VAAS estimates **where anomalies occur** and **how strongly they deviate from learned visual regularities**, enabling explainable image analysis and integrity assessment.
|
| 34 |
|
| 35 |
-
##
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
- [Arxiv version](https://arxiv.org/abs/2512.15512)
|
| 38 |
- [Conference version](https://arxiv.org/abs/2512.15512)
|
|
@@ -58,27 +60,13 @@ These components are combined via a hybrid scoring mechanism:
|
|
| 58 |
|
| 59 |
`S_H` provides a continuous measure of anomaly intensity rather than a binary decision.
|
| 60 |
|
| 61 |
-
---
|
| 62 |
-
## Intended Use
|
| 63 |
-
|
| 64 |
-
This model can be used for:
|
| 65 |
-
|
| 66 |
-
* Image anomaly detection
|
| 67 |
-
* Visual integrity assessment
|
| 68 |
-
* Explainable inspection of irregular regions
|
| 69 |
-
* Research on attention-based anomaly scoring
|
| 70 |
-
* Prototyping anomaly-aware vision systems
|
| 71 |
-
|
| 72 |
-
It supports **CPU-only inference** and **GPU-accelerated inference**.
|
| 73 |
-
GPU usage is recommended for faster processing but is not required.
|
| 74 |
-
|
| 75 |
---
|
| 76 |
|
| 77 |
## Installation
|
| 78 |
|
| 79 |
VAAS is distributed as a **lightweight inference library** and can be installed instantly.
|
| 80 |
|
| 81 |
-
PyTorch is **only required when
|
| 82 |
This allows users to inspect, install, and integrate VAAS without heavy dependencies.
|
| 83 |
|
| 84 |
*This model was produced using `vaas==0.1.7`, but newer versions of VAAS may also be compatible for inference.*
|
|
@@ -92,7 +80,7 @@ Follow the official PyTorch installation guide for your platform:
|
|
| 92 |
|
| 93 |
[https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/)
|
| 94 |
|
| 95 |
-
**Quick installation**
|
| 96 |
```sh
|
| 97 |
pip install torch torchvision
|
| 98 |
```
|
|
@@ -109,9 +97,16 @@ VAAS will automatically detect PyTorch at runtime and raise a clear error if it
|
|
| 109 |
|
| 110 |
## Usage
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
|
|
|
| 113 |
|
| 114 |
-
|
| 115 |
|
| 116 |
```python
|
| 117 |
from vaas.inference.pipeline import VAASPipeline
|
|
@@ -122,7 +117,7 @@ from io import BytesIO
|
|
| 122 |
pipeline = VAASPipeline.from_pretrained(
|
| 123 |
"OBA-Research/vaas-v1-df2023",
|
| 124 |
device="cpu",
|
| 125 |
-
alpha=0.5
|
| 126 |
)
|
| 127 |
|
| 128 |
# # Option A: Using a local image
|
|
@@ -132,54 +127,75 @@ pipeline = VAASPipeline.from_pretrained(
|
|
| 132 |
# Option B: Using an online image
|
| 133 |
url = "https://raw.githubusercontent.com/OBA-Research/VAAS/main/examples/images/COCO_DF_C110B00000_00539519.jpg"
|
| 134 |
image = Image.open(BytesIO(requests.get(url).content)).convert("RGB")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
result = pipeline(image)
|
| 136 |
|
| 137 |
print(result)
|
| 138 |
anomaly_map = result["anomaly_map"]
|
| 139 |
-
|
| 140 |
```
|
| 141 |
|
| 142 |
-
#### Output
|
| 143 |
|
| 144 |
```python
|
| 145 |
{
|
| 146 |
-
"S_F": float,
|
| 147 |
-
"S_P": float,
|
| 148 |
-
"S_H": float,
|
| 149 |
-
"anomaly_map":
|
| 150 |
}
|
| 151 |
```
|
| 152 |
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
VAAS can also generate a qualitative visualization combining:
|
| 156 |
|
| 157 |
-
|
| 158 |
-
* Global attention maps (Fx)
|
| 159 |
-
* Final hybrid anomaly score (S_H)
|
| 160 |
|
| 161 |
-
|
|
|
|
|
|
|
| 162 |
|
| 163 |
-
|
| 164 |
-
image=image,
|
| 165 |
-
save_path="vaas_visualization.png",
|
| 166 |
-
mode="all", # options: "all", "px", "binary", "fx"
|
| 167 |
-
threshold=0.5,
|
| 168 |
-
)
|
| 169 |
-
```
|
| 170 |
|
| 171 |
-
|
| 172 |
|
| 173 |
-
|
| 174 |
-
* Patch-level anomaly overlays
|
| 175 |
-
* Global attention overlays
|
| 176 |
-
* A gauge-style visualization of the hybrid anomaly score
|
| 177 |
|
| 178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-

|
| 183 |
|
| 184 |
---
|
| 185 |
|
|
|
|
| 29 |
|
| 30 |
VAAS (Vision-Attention Anomaly Scoring) is a dual-module vision framework for **image anomaly detection and localization**.
|
| 31 |
It combines **global attention-based reasoning** with **patch-level self-consistency analysis** to produce a **continuous, interpretable anomaly score** alongside dense spatial anomaly maps.
|
|
|
|
| 32 |
Rather than making binary decisions, VAAS estimates **where anomalies occur** and **how strongly they deviate from learned visual regularities**, enabling explainable image analysis and integrity assessment.
|
| 33 |
|
| 34 |
+
## Examples of detection and scoring
|
| 35 |
+

|
| 36 |
+
|
| 37 |
+
## Read Research Paper
|
| 38 |
|
| 39 |
- [Arxiv version](https://arxiv.org/abs/2512.15512)
|
| 40 |
- [Conference version](https://arxiv.org/abs/2512.15512)
|
|
|
|
| 60 |
|
| 61 |
`S_H` provides a continuous measure of anomaly intensity rather than a binary decision.
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
---
|
| 64 |
|
| 65 |
## Installation
|
| 66 |
|
| 67 |
VAAS is distributed as a **lightweight inference library** and can be installed instantly.
|
| 68 |
|
| 69 |
+
PyTorch is **only required when executing inference or loading pretrained VAAS models**.
|
| 70 |
This allows users to inspect, install, and integrate VAAS without heavy dependencies.
|
| 71 |
|
| 72 |
*This model was produced using `vaas==0.1.7`, but newer versions of VAAS may also be compatible for inference.*
|
|
|
|
| 80 |
|
| 81 |
[https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/)
|
| 82 |
|
| 83 |
+
**Quick installation (CPU)**
|
| 84 |
```sh
|
| 85 |
pip install torch torchvision
|
| 86 |
```
|
|
|
|
| 97 |
|
| 98 |
## Usage
|
| 99 |
|
| 100 |
+
---
|
| 101 |
+
|
| 102 |
+
**Try VAAS instantly in Colab (no setup required):**
|
| 103 |
+
👉 [Open the interactive Colab demo](https://colab.research.google.com/drive/1aGQc_ZpPhDOEf7G4_-p03_Fmtdg_QcGd?usp=sharing)
|
| 104 |
+
|
| 105 |
+
---
|
| 106 |
|
| 107 |
+
### 1. Quick start: run VAAS and get a visual result
|
| 108 |
|
| 109 |
+
The fastest way to verify VAAS is working is to generate a visualization from a single image.
|
| 110 |
|
| 111 |
```python
|
| 112 |
from vaas.inference.pipeline import VAASPipeline
|
|
|
|
| 117 |
pipeline = VAASPipeline.from_pretrained(
|
| 118 |
"OBA-Research/vaas-v1-df2023",
|
| 119 |
device="cpu",
|
| 120 |
+
alpha=0.5,
|
| 121 |
)
|
| 122 |
|
| 123 |
# # Option A: Using a local image
|
|
|
|
| 127 |
# Option B: Using an online image
|
| 128 |
url = "https://raw.githubusercontent.com/OBA-Research/VAAS/main/examples/images/COCO_DF_C110B00000_00539519.jpg"
|
| 129 |
image = Image.open(BytesIO(requests.get(url).content)).convert("RGB")
|
| 130 |
+
|
| 131 |
+
pipeline.visualize(
|
| 132 |
+
image=image,
|
| 133 |
+
save_path="vaas_visualization.png",
|
| 134 |
+
mode="all", # "all", "px", "binary", "fx"
|
| 135 |
+
threshold=0.5,
|
| 136 |
+
)
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
This produces a single figure containing:
|
| 140 |
+
|
| 141 |
+
- The original image
|
| 142 |
+
- Patch-level anomaly heatmaps (Px)
|
| 143 |
+
- Global attention overlays (Fx)
|
| 144 |
+
- A gauge showing the hybrid anomaly score (S_H)
|
| 145 |
+
|
| 146 |
+
The output is saved to `vaas_visualization.png`.
|
| 147 |
+
|
| 148 |
+
For examples:
|
| 149 |
+

|
| 150 |
+

|
| 151 |
+

|
| 152 |
+
|
| 153 |
+
---
|
| 154 |
+
|
| 155 |
+
### 2. Programmatic inference (scores + anomaly map)
|
| 156 |
+
|
| 157 |
+
For numerical outputs and downstream processing, call the pipeline directly:
|
| 158 |
+
|
| 159 |
+
```python
|
| 160 |
result = pipeline(image)
|
| 161 |
|
| 162 |
print(result)
|
| 163 |
anomaly_map = result["anomaly_map"]
|
|
|
|
| 164 |
```
|
| 165 |
|
| 166 |
+
#### Output format
|
| 167 |
|
| 168 |
```python
|
| 169 |
{
|
| 170 |
+
"S_F": float, # global attention score
|
| 171 |
+
"S_P": float, # patch consistency score
|
| 172 |
+
"S_H": float, # hybrid anomaly score
|
| 173 |
+
"anomaly_map": ndarray # shape (224, 224)
|
| 174 |
}
|
| 175 |
```
|
| 176 |
|
| 177 |
+
---
|
|
|
|
|
|
|
| 178 |
|
| 179 |
+
### Notes
|
|
|
|
|
|
|
| 180 |
|
| 181 |
+
- VAAS supports both local and online images
|
| 182 |
+
- PyTorch is loaded lazily and only required at runtime
|
| 183 |
+
- CPU inference is supported; GPU accelerates execution but is optional
|
| 184 |
|
| 185 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
+
## Intended Use
|
| 188 |
|
| 189 |
+
This model can be used for:
|
|
|
|
|
|
|
|
|
|
| 190 |
|
| 191 |
+
* Image anomaly detection
|
| 192 |
+
* Visual integrity assessment
|
| 193 |
+
* Explainable inspection of irregular regions
|
| 194 |
+
* Research on attention-based anomaly scoring
|
| 195 |
+
* Prototyping anomaly-aware vision systems
|
| 196 |
|
| 197 |
+
It supports **CPU-only inference** and **GPU-accelerated inference**.
|
| 198 |
+
GPU usage is recommended for faster processing but is not required.
|
|
|
|
| 199 |
|
| 200 |
---
|
| 201 |
|