README.md
June 30, 2026 Β· View on GitHub
AG-VAS: Anchor-Guided Zero-Shot Visual Anomaly Segmentation with Large Multimodal Models (CVPR 2026)
Zhen Qu, Xian Tao, Xiaoyi Bao, Dingrong Wang, ShiChen Qu, Zhengtao Zhang, Xingang Wang
Large multimodal models (LMMs) exhibit strong task generalization capabilities, offering new opportunities for zero-shot visual anomaly segmentation (ZSAS). However, existing LMM-based segmentation approaches still face fundamental limitations: anomaly concepts are inherently abstract and context-dependent, lacking stable visual prototypes, and the weak alignment between high-level semantic embeddings and pixel-level spatial features hinders precise anomaly localization. To address these challenges, we present AG-VAS (Anchor-Guided Visual Anomaly Segmentation), a new framework that expands the LMM vocabulary with three learnable semantic anchor tokensβ[SEG], [NOR], and [ANO], establishing a unified anchor-guided segmentation paradigm. Specifically, [SEG] serves as an absolute semantic anchor that translates abstract anomaly semantics into explicit, spatially grounded visual entities (e.g., holes or scratches), while [NOR] and [ANO] act as relative anchors that model the contextual contrast between normal and abnormal patterns across categories. To further enhance cross-modal alignment, we introduce a Semantic-Pixel Alignment Module (SPAM) that aligns language-level semantic embeddings with high-resolution visual features, along with an Anchor-Guided Mask Decoder (AGMD) that performs anchor-conditioned mask prediction for precise anomaly localization. In addition, we curate Anomaly-Instruct20K, a large-scale instruction dataset that organizes anomaly knowledge into structured descriptions of appearance, shape, and spatial attributes, facilitating effective learning and integration of the proposed semantic anchors. Extensive experiments on six industrial and medical benchmarks demonstrate that AG-VAS achieves consistent state-of-the-art performance in the zero-shot setting.
Table of Contents
- π Introduction
- π§ Environments
- π Data Preparation
- π Run Experiments
- π Citation
- π Acknowledgements
- π License
Introduction
This repository contains source code for AG-VAS implemented with PyTorch οΌAccepted by CVPR 2026οΌ.
Data Preparation
The overall composition of the dataset, including the training and test sets, is presented as follows. Note that, except for the anomaly_seg and anomaly_instruct_20K datasets, all other subsets require no additional processing and can be downloaded directly from official or third-party sources. We provide the download links for the datasets in the following section.
my_dataset/ # Root directory
β
βββ ade20k/ # Task: sem_seg
β βββ annotations/
β β βββ training/
β β βββ validation/
β βββ images/
β β βββ training/
β β βββ validation/
β βββ objectInfo150.txt
β βββ sceneCategories.txt
β
βββ coco/ # Task: sem_seg (images for COCOStuff)
β βββ train2017/
β βββ *.jpg
β
βββ cocostuff/ # Task: sem_seg
β βββ train2017/
β βββ *.png
β
βββ mapillary/ # Task: sem_seg
β βββ config_v1.2.json
β βββ config_v2.0.json
β βββ LICENSE
β βββ README
β βββ demo.py
β βββ testing/
β β βββ images/
β βββ training/
β β βββ images/
β β βββ v1.2/
β β βββ v2.0/
β βββ validation/
β βββ images/
β βββ v1.2/
β βββ v2.0/
β
βββ vlpart/ # Task: sem_seg (part detection)
β βββ paco/
β β βββ annotations/
β β βββ paco_lvis_v1_train.json
β βββ pascal_part/
β βββ Annotations_Part/
β βββ train.json
β βββ train_base.json
β βββ train_base_one.json
β βββ train_one.json
β βββ val.json
β βββ VOCdevkit/
β
βββ refer_seg/ # Task: refer_seg
β βββ images/
β β βββ mscoco/
β β β βββ images/
β β β βββ train2014/
β β βββ saiapr_tc-12/
β βββ refclef/
β β βββ instances.json
β β βββ refs(unc).p
β β βββ refs(berkeley).p
β βββ refcoco/
β β βββ instances.json
β β βββ refs(unc).p
β β βββ refs(google).p
β βββ refcoco+/
β β βββ instances.json
β β βββ refs(unc).p
β βββ refcocog/
β βββ instances.json
β βββ refs(umd).p
β βββ refs(google).p
β
βββ vqa_dataset/ # Task: vqa
β βββ llava_dataset
β βββ llava_instruct_150k.json
β βββ anomalyov_dataset
β βββ images
β βββ bmad
β βββ webAD
β βββ bmad_zero_shot.json
β βββ webad_processed.json
β
βββ reason_seg/ # Task: reason_seg
β βββ ReasonSeg/
β βββ explanatory/
β β βββ train.json
β βββ train/
β β βββ *.jpg
β β βββ *.json
β βββ val/
β βββ test/
βββ anomaly_seg/ # Task: anomaly segmentation and reasoning
β βββ mvtec/
β βββ KSDD2/
β βββ RSDD/
β βββ ISIC/
β βββ ColonDB/
β βββ Road/
β βββ ZJU/
β βββ RealIADC1/
β βββ DTD/
β βββ Goods/
β βββ MIAD/
β βββ meta_mvtec.json
β βββ meta_visa.json
β βββ meta_KSDD2.json
β βββ meta_RSDD.json
β βββ meta_ISIC.json
β βββ meta_ColonDB.json
β βββ meta_Road.json
β βββ meta_ZJU.json
β βββ meta_RealIADC1.json
β βββ meta_DTD.json
β βββ meta_MIAD.json
β βββ meta_Goods.json
βββ anomaly_instruct_20K/
β βββ RealIADC.json
β βββ DTD.json
β βββ Goods.json
βββββββββββββββββββββ
ade20k: Download
coco: Download
cocostuff: Download
mapillary: Download
vlpart: Download of paco, Download of pascal_part
refer_seg: images/mscoco, images/saiapr_tc-12, refCOCO, refCOCO+, refCOCOg, refCLEF
vqa_dataset: LLaVA-Instruct-150k, anomalyov_dataset
reason_seg: ReasonSeg
Prepare the anomaly_seg sub-datasets:
The organization and construction of the anomaly_seg dataset follow the same procedure as that used in Bayes-PL and DictAS:
1γDownload and prepare the original MVTec-AD, VisA, RealIAD, GoodsAD, DTD-Synthetic, MIAD, Zju-leaper to any desired path. Taking MVTec-AD and VisA as examples, the original dataset format is as follows:
path1
βββ mvtec
βββ bottle
βββ train
βββ good
βββ 000.png
βββ test
βββ good
βββ 000.png
βββ anomaly1
βββ 000.png
βββ ground_truth
βββ anomaly1
βββ 000.png
path2
βββ visa
βββ candle
βββ Data
βββ Images
βββ Anomaly
βββ 000.JPG
βββ Normal
βββ 0000.JPG
βββ Masks
βββ Anomaly
βββ 000.png
βββ split_csv
βββ 1cls.csv
βββ 1cls.xlsx
2γStandardize the MVTec-AD and VisA datasets to the same format and generate the corresponding .json files.
- run ./dataset/make_dataset.py to generate standardized datasets ./dataset/mvisa/data/visa and ./dataset/mvisa/data/mvtec
- run ./dataset/make_meta.py to generate ./dataset/mvisa/data/meta_visa.json and ./dataset/mvisa/data/meta_mvtec.json (This step can be skipped since we have already generated them.)
The format of the standardized datasets is as follows:
./datasets/mvisa/data
βββ visa
βββ candle
βββ train
βββ good
βββ visa_0000_000502.bmp
βββ test
βββ good
βββ visa_0011_000934.bmp
βββ anomaly
βββ visa_000_001000.bmp
βββ ground_truth
βββ anomaly1
βββ visa_000_001000.png
βββ mvtec
βββ bottle
βββ train
βββ good
βββ mvtec_000000.bmp
βββ test
βββ good
βββ mvtec_good_000272.bmp
βββ anomaly
βββ mvtec_broken_large_000209.bmp
βββ ground_truth
βββ anomaly
βββ mvtec_broken_large_000209.png
βββ meta_mvtec.json
βββ meta_visa.json
Other Datasets
Please download the other datasets from Google Drive: [DTAT.zip]. The processing methods for the datasets are similar to those for MVTec and VisA; all datasets are standardized into the MVTec format with a corresponding meta.json file.
Dataset Brief Description:
(1) HeadCT, BrainMRI, Br35H, ISIC, CVC-ColonDB, and CVC-ClinicDB are carefully curated by the AdaCLIP project, while Endo and Kvasir are curated by the AnomalyCLIP project. We sincerely appreciate their excellent work and dedication.
(2) KSDD2, RSDD, and DAGM datasets were post-processed by us, including operations such as random cropping. The original DAGM dataset was designed for weakly supervised defect segmentation, and thus its pixel-level annotations are imprecise elliptical labels. To make it suitable for anomaly segmentation, we manually re-annotated the dataset with precise pixel-level labels. Moreover, since the test sets of these datasets contain no normal samples, they are not directly suitable for anomaly classification. Therefore, when generating standardized datasets, we randomly selected an equal number of normal samples from the training set to match the number of abnormal samples in the test set for evaluation purposes. Due to the randomness involved, re-running ./dataset/make_dataset.py may result in different selections of normal samples. Therefore, we have also uploaded the version used in our paper for reference: [DATA_three.zip].
Environments
Create a new conda environment and install required packages.
conda create -n llava_ov python=3.10
conda activate llava_ov
conda install pytorch==2.1.2 torchvision==0.16.2 torchaudio==2.1.2 pytorch-cuda=12.1 -c pytorch -c nvidia
conda env create -f environment.yml
Acknowledgements
We thank the great works WinCLIP(zqhang), WinCLIP(caoyunkang), RegAD, VCP-CLIP, APRIL-GAN, Bayes-PFL, FastRecon, AnomalyGPT, PromptAD, MetaUAS and ResAD for assisting with our work.
Todo list
- Release our AG-VAS paper
- Release our training code of DictAS
- Release our model weights
- Release our training code of DictAS
License
The code and dataset in this repository are licensed under the MIT license.