ZSAS DSBA Lab

ZSASZero-Shot Anomaly Segmentation With Class-Specific Text Prompts

A hazelnut from the test set of MVTec AD. The same hazelnut with the anomaly map of ZSAS on the right of the divider. Image ZSAS

What the MLLM wrote for hazelnut

Normal

  • The hazelnut rests on a dark background, shell intact.
  • The hazelnut shows uniform reddish-brown color with fine ridges.
  • The hazelnut displays a circular basal scar, edges clean.

Abnormal

  • The hazelnut shows a long crack exposing kernel.
  • The hazelnut has black mold spots around the base.
  • The hazelnut features a drilled hole straight through.

Six of the 40 sentences written for the class hazelnut of MVTec AD from its name and one reference image. Browse every class.

Right of the divider

Abstract

Zero-shot anomaly segmentation (ZSAS) detects anomalous regions in unseen classes without training samples, and is valuable in data-restricted industrial and medical domains. Existing methods based on CLIP rely on class-agnostic text prompts that fail to capture class-specific anomaly characteristics, resulting in semantic ambiguity and misalignment with patch-level visual features.

We use a multimodal large language model (MLLM) to automatically generate class-specific text prompts (CSTPs), which describe each class's physical structure, normal patterns, and representative anomaly characteristics. An adapter-based residual connection structure and an alternating learning strategy enable stable training while preserving CLIP's pretrained knowledge. On diverse industrial and medical datasets, the approach attains the highest mean anomaly detection score (mAD) over the two domains and the strongest medical-domain performance, with a substantially better accuracy and efficiency trade-off in inference speed and memory.

  • 57.7mAD over the industrial and medical domains, the highest of six methods
  • 56.1mAD on the six medical datasets, the highest of six methods
  • 218msand 2,280 MB of GPU memory per image
  • $0.007to write the prompts of one class, paid once per class

Prompts written for each class, adapters trained in turns

ZSAS has three parts. An MLLM writes text prompts for each class, small residual adapters adapt a frozen CLIP to these prompts, and the image and text adapters are trained in alternate epochs.

Why the prompts are written for each class

Class-agnostic and class-specific prompts. Anomaly segmentation with class-agnostic prompts and with class-specific prompts.
Alignment with patch features. Class-agnostic and class-specific prompts compared by their alignment with patch-level features.

Highest mAD overall and in the medical domain

ZSAS has the highest mAD of the six methods on the average of the two domains (57.7) and on the medical datasets (56.1). On the industrial average Bayes-PFL is higher, 61.0 against 59.2.

Domain

Select a column to sort by it.

Comparison with existing zero-shot anomaly segmentation methods

Pixel-level metrics in percent. R is AUROC, F is F1-max, A is AP, P is AUPRO, I is IoU-max, and mAD is the mean of the five. Bold marks the best value of a column, and the bars show the column the table is sorted by.

Weights trained on MVTec AD are used for every dataset except MVTec AD, which uses weights trained on VisA, so training and test classes never overlap. Only the test split of each dataset is used. The weights are on Hugging Face.

Every dataset, every method

Where ZSAS is ahead and where it is not. Each row is one dataset and each dot one method. The line joins ZSAS and the method it is compared with, and the number on the right is their difference in points.

ZSAS on each dataset

Datasets shown
Results of ZSAS on each dataset

The last column is the mean and standard deviation of mAD over 30 independent CSTP sets.

Anomaly maps next to four zero-shot methods

Hazelnut, input image Hazelnut, anomaly map of ZSAS Image ZSAS

Sample
Shown right of the divider

Eight classes from the industrial and medical test sets, with the ground truth and the maps of WinCLIP, AnoVL, AnomalyCLIP, AdaCLIP and ZSAS. Drag the divider, or use the arrow keys while it has focus.

The prompts the MLLM wrote

GPT-5 wrote these prompts from the class name and one reference image, 20 normal and 20 abnormal sentences per class. They are the sets behind the reported numbers. They are released with the code, so the results can be reproduced without an API key.

Loading the prompts.

Which MLLM, and at what cost

Choice of MLLM. mAD with five MLLMs used for CSTP generation. The variation among them is small.
Cost of generating the CSTPs of one class
MLLMTokens in / outTotal ($)

Cost of the prompts of one class. It is paid once per class, and the prompts are reused for every image. The two open models are priced at the rate of a hosted endpoint.

Ablation, reference image and efficiency

Each component adds to the result

On VisA, mAD rises from 25.4 without any of the three components to 44.1 with the residual adapters, 48.1 when CSTPs are added, and 52.2 with alternating learning as well.

Ablation. On VisA with the weights trained on MVTec AD. Switch a component off to see the six metrics without it.

The reference image matters

When the MLLM is given only the class name, mAD drops by 2.0 %p on the industrial data and by 6.4 %p on the medical data.

Effect of the reference image. Gain in mAD on each dataset from giving the MLLM one reference image in addition to the class name.

Speed and memory

Efficiency. The same backbone and input size for every method (ViT-L-14-336, 518 by 518) on one NVIDIA Tesla V100. Bayes-PFL has the higher industrial mAD and takes 599 ms per image.

Cite

@ARTICLE{11783453,
  author={Son, Junyeong and Lee, Woojun and Sung, Siyul and Kang, Pilsung},
  journal={IEEE Transactions on Automation Science and Engineering},
  title={Zero-Shot Anomaly Segmentation With Class-Specific Text Prompts},
  year={2026},
  volume={23},
  number={},
  pages={20270-20285},
  keywords={Modeling;Training;Visualization;Learning (artificial intelligence);Anomaly detection;Conferences;Computers;Poles and zeros;Computer vision;Transistors;Image anomaly segmentation;zero-shot anomaly segmentation;multimodal large language models},
  doi={10.1109/TASE.2026.3752260}}