# Learning local and global prototypes with optimal transport for unsupervised anomaly detection and localization

Robin Trombetta, Carole Lartizien

► To cite this version:

Robin Trombetta, Carole Lartizien. Learning local and global prototypes with optimal transport for unsupervised anomaly detection and localization. Learning From Small Data (LFSD), European Conference on Machine Learning and Principles and Practice of Knowledge Discovery in Databases (ECML) Workshop, Sep 2025, Porto, Portugal. 10.48550/arXiv.2508.12927. [hal-05397692]

HAL Id: hal-05397692

https://hal.science/hal-05397692v1

Submitted on 4 Dec 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
Learning local and global prototypes with
optimal transport for unsupervised anomaly
detection and localization

Robin Trombetta<sup>[0009-0001-7945-6953]</sup> (✉) and Carole
Lartizien<sup>[0000-0001-7594-4231]</sup>

Univ. Lyon, CNRS UMR 5220, Inserm U1294, INSA Lyon, UCBL, CREATIS, France

robin.trombetta@creatis.insa-lyon.fr

**Abstract.** Unsupervised anomaly detection aims to detect defective parts of a sample by having access, during training, to a set of normal, i.e. defect-free, data. It has many applications in fields, such as industrial inspection or medical imaging, where acquiring labels is costly or when we want to avoid introducing biases in the type of anomalies that can be spotted. In this work, we propose a novel UAD method based on prototype learning and introduce a metric to compare a structured set of embeddings that balances a feature-based cost and a spatial-based cost. We leverage this metric to learn local and global prototypes with optimal transport from latent representations extracted with a pretrained image encoder. We demonstrate that our approach can enforce a structural constraint when learning the prototypes, allowing to capture the underlying organization of the normal samples, thus improving the detection of incoherencies in images. Our model achieves performance that is on par with strong baselines on two reference benchmarks for anomaly detection on industrial images. The code is available at https://github.com/robintrmbtt/pradot.

**Keywords:** Unsupervised anomaly detection · Prototype learning · Optimal transport.

# 1 Introduction

Anomaly detection refers to the task of identifying samples that deviate from the distribution of normal cases. In domains such as video analysis or medical imaging, obtaining large-scale annotated datasets is often prohibitively expensive. Furthermore, relying on labeled data inherently biases the model toward detecting only known types of anomalies. As a result, rare or previously unseen anomalies can go undetected. To address these limitations, unsupervised anomaly detection (UAD) has emerged as an alternative approach to supervised learning. Instead of learning from both normal and abnormal examples, UAD models are trained exclusively on normal (i.e., anomaly-free) data and learn to capture the underlying distribution or structure of the normal data. At test time, the model computes the distance between the new sample and the learnt
data distribution. Based on this measure, it is expected to differentiate between in-distribution samples and samples that deviate from the anomaly-free distribution. The research in the field on UAD for automatic industrial inspection was greatly pushed by the MVTec AD dataset [2], which set a robust benchmark for the evaluation of UAD methods. More recently, a new version of the dataset called MVTec AD LOCO [1] was released to address the shortcomings of the first benchmark. In particular, it introduces anomalies of a more logical nature, which violate the expected structural or semantic organization of the image, the detection of which can require capturing long-range dependencies between the different subparts of the image.

To address the challenge of unsupervised anomaly detection, a wide range of methods have been developed, employing different strategies to localize abnormal regions in images. A prominent family of methods relies on the extraction of hierarchical features from a pre-trained encoder to build a memory bank, that is, a set of discrete prototypical features representing normal patterns [3, 6, 24, 13, 23]. At inference time, a distance metric quantifies the discrepancy between the latent features of the test image and the learnt prototypes. The abnormal parts of the image are identified when there is a high dissimilarity between a latent feature and the prototypes. Various techniques allow to learn such prototypes such as kNN [6,13] or coreset sampling [25]. These methods have received particular attention because of their high performance, simplicity, speed and efficiency at low data regime. One of their shortcomings is their limited ability to spot abstract incoherencies in the images, such as misplaced objects, even when employing multi-level feature maps and improved neighbour-awareness mechanisms [6,25],

In this work, we propose using optimal transport to efficiently learn prototypes for features extracted from the pre-trained encoder. Inspired by fused Gromov-Wasserstein [35] (FGW) distance, we introduce a discrepancy function that balances a feature-based cost and a spatial-based cost. By playing on the ratio between these two components, we are able to learn more *local* or more *global* representatives of the normal class, thus capturing diverse patterns on the training images. By applying it to features extracted from a pre-trained backbone, such as ResNet50 [14], we propose a novel method for Prototype-based Anomaly Detection with Optimal Transport (PRADOT). Compared to previous state-of-the-art methods that leverage a memory bank [6,25], our approach, in particular due to the structural constraint enforced by assignment to local prototypes, is shown to better identify incoherencies in images. We evaluate our method on MVTec AD and MVTec AD LOCO, two standard benchmarks for unsupervised anomaly detection and localization on industrial images, where it achieves competitive performances compared to state-of-the-art methods.

## 2 Related Work

**Unsupervised anomaly detection.** Earliest works focusing on anomaly detection tried to estimate the support of the normal samples with one-class sup-
port machine or support vector data description [31,26]. A large family of meth-
ods makes use of generative models, in particular Auto-Encoders or Generative
Adversarial Nets [12,27], and expects to localize anomalies with the pixel-wise
distance between an input image and its reconstruction. However, recent studies
have highlighted the fact that auto-encoders can generalize their reconstruction
abilities to anomalous parts of images [46], thus limiting the effectiveness of such
approaches. To overcome this issue, more advanced auto-encoder based meth-
ods have incorporated masking strategies [46,41], memory mechanisms [23,11] or
synthetic data [45,28]. Recently, the generative abilities of diffusion models [15]
have also been employed for unsupervised anomaly detection [42].

Many UAD methods exploit the representative power of features extracted
from pre-trained encoders. Density-based methods learn the distribution of nor-
mal features via direct likelihood estimation [3,19] while support-based methods
[26,43] aim to spot anomalies as samples with a high distance to the estimated
boundaries of the distribution of anomaly-free cases. Normalizing flows have been
widely applied in UAD, mainly through network-parametrized density estima-
tion of deep latent features [44,49]. In knowledge distillation, a frozen pre-trained
encoder is used as a teacher to guide the training of a student network, and the
anomalies are detected by a large discrepancy between the features of the two
networks [37,10,47]. The methods most closely related to this work are those
based on prototypes [6,23,25,13]. A cornerstone work falling in this category is
PatchCore [25], which builds a memory bank of locally aware prototypes with
coreset sampling and uses nearest neighbours search at inference to evaluate
the distance between a feature and the discrete representatives of the normal
samples.

**Prototype learning.** Prototypical-based methods are popular in machine learn-
ing, one of their advantages being that they provide good explainability. Indeed,
their exemplar-driven decision process generally allows for intuitive interpreta-
tion. One of the most popular applications of prototype learning is the Vector-
Quantized Variational Auto-Encoder (VQ-VAE) [34], where the bottleneck of a
typical Auto-Encoder is replaced by a dictionary for discrete encoding. SwAV [5]
is a widespread self-supervised technique that makes use of assignments to dis-
crete clusters to learn visual features. [48] analyses the task of semantic segmen-
tation from a prototype view and explicitly learns multiple prototypes of pixel
embeddings to better capture intra-class diversity. This paradigm also found ap-
plications in few- and zero-shot learning [30,17], sample-level out-of-distribution
detection [20] or unsupervised anomaly detection [25,13,23].

**Optimal transport.** Optimal transport (OT) provides a mathematical frame-
work for comparing probability distributions by identifying the minimal cost
required to shift from one to the other. Computational methods for OT have
successfully been applied to many applications in machine learning such as do-
main adaptation [7,9], visual place recognition [16], zero-shot segmentation [18],
multi-modal problems [40,4] or out-of-distribution detection [20,21]. In methods
that use prototypes or clusters, optimal transport is often used for assignment
during training [5,48]. It can force equipartition between the discrete represen-
tatives and thus avoid having unassigned prototypes or collapsing prototypes.
Similar to our work, optimal transport is used in [29,33] for industrial anomaly
detection, in their case in a few-shot learning setup. [29] generates bilateral se-
mantic correspondence between a query image and a small guidance set, while
[33] refines a set of prototypes by computing the optimal transfer plan with a
query image. When employed on large-scale data, the classical OT problem is of-
ten reformulated by adding an entropic regularization term, which allows much
faster computation [8]. Through (fused) Gromov-Wasserstein [35,24], optimal
transport is often used in graph-related problems [39,32,36].

3 Method

Given a set $\mathcal{D}^{\text{train}} = \{(x_i, y_i)\}_{i=1}^{N_{\text{train}}}$ of normal images $x_i$ ($y_i = 0$), and a test set $\mathcal{D}^{\text{test}} = \{(x_j, y_j)\}_{j=1}^{N_{\text{test}}}$ containing normal and abnormal images $x_j$ with their associated pixel-level ground-truth $y_j$, we aim to train a model solely on normal images which is able to detect whether or not a test image lies inside the normal distribution and if not localize where are the abnormal parts of the image. The overview of the proposed method is illustrated in Figure 1, and the method is described in detail in the following sections.

Its principle can be summarized in three main steps: 1) We extract multi-scale
features from the training images with a pre-trained encoder 2) Using optimal
transport with a tailored cost function, we assign each feature of a batch to the
local and global prototypes and update the prototypes with exponential moving
average 3) At inference, we assign each feature vector extracted from the input
image to the closest prototype and use the distance between the two as indicator
of the presence or absence of an anomaly.

3.1 Prototype learning with optimal transport

**Hierarchical feature extraction.** As many anomaly detection methods, we consider a pre-trained encoder $\phi_\theta$, typically a ResNet50, that extracts multi-level features $\phi_\theta(x) = \{z^l\}_l$ from an input image $x$, where $l$ is the stage of the encoder at which the features are extracted and $z^l \in \mathbb{R}^{H_l \times W_l \times D_l}$ is the deep representation of the input and composed of $H_l \times W_l$ feature vectors of dimension $D_l$. Given a set of intermediate features $\mathcal{F}^l = \{z^l_i\}_{i=1}^{N_{\text{train}}}$ extracted from the images of the training set, the idea is to leverage optimal transport to learn the barycentre of the features $\mathcal{F}_l$. In many applications, images have a local structure and coherence, hence we want to design a way to capture local information and structure from the training dataset. For simplicity and as the method is independent of the stage $l$ of the encoder where the features are extracted, we will drop this variable from the notations in the following.
<figure><img src="image_2.png" /><figcaption>Fig. 1. Overview of the proposed method. a) During training, we extract features from the training images and learn local and global prototypes with b) optimal transport assignment from embeddings to prototypes and exponential moving average update. c) At inference, the distances between each of the image embeddings and the closest local and global prototypes serve as anomaly score.</figcaption></figure>

**Problem setup.** We can consider that the features $z$ extracted by the encoder $\phi_\theta$ from an input image $x$ can be divided in a regular grid of size $H \times W$ and consequently embed each feature vector at the position $(i, j)$ of this grid with its (normalized) coordinates $c_{ij} = (\frac{i}{H}, \frac{j}{W})$, with $(i, j) \in [1, H] \times [1, W]$. From now on, the term *input embedding* will refer to both the feature vector extracted from the encoder and its coordinates, i.e. $f_{ij} = (z_{ij}, c_{ij}) \in \mathbb{R}^D \times \mathbb{R}^2$.

We define a set of prototypes $\mathcal{P} = \{P_i\}_{i=1}^{N_p}$ where a prototype $P_i = (p_i, \rho_i)$ is composed of a feature vector $p_i \in \mathbb{R}^D$ and spatial coordinates $\rho_i = (\frac{\rho_{x,i}}{H}, \frac{\rho_{y,i}}{W}) \in \mathbb{R}^2$. Although in theory the coordinates of the prototypes could be left free, we decide to simplify the modelling by imposing that the prototypes be placed on the same grid as the embeddings. Hence, their coordinate vectors $(\rho_{x,i}, \rho_{y,i})$ are defined only on $[1, H] \times [1, W]$. To allow for a richer representation, we set that there can be $n$ prototypes per grid element, resulting in a total number of prototypes of $N_p = n \times H \times W$.

To quantify the closeness between an input embedding $f = (z, c)$ and a prototype $P = (p, \rho)$, we define the following cost, inspired by the fused Gromov-Wasserstein distance [35]:

$$ \mathcal{C}(f, P) = (1 - \alpha)(1 - \frac{\langle z, p \rangle}{\|z\| \|p\|}) + \alpha \|c - \rho\|^2 \quad (1) $$
where $\alpha \in [0, 1]$ is a hyperparameter and $\langle \cdot, \cdot \rangle$ designates the dot product between vectors. This cost introduces a balance between a feature-based cost, with the cosine distance between the feature vectors of the image embedding and the prototype, and a structural (or spatial) cost with the $L^2$ norm between their 2D coordinates.

**Optimal transport problem.** Given a set of input images $\{x_i\}_{i=1}^N$, we formalize an optimal transport problem between their extracted embeddings $\{f_{ij}^n\}_{i,j,n=1}^{i=H,j=W,n=N}$ and the prototypes $\{P_i\}_{i=1}^{N_p}$ as the search for a transport plan $T^*$ which minimizes the total transportation cost between embeddings and prototypes, while respecting the total mass constraint:

$$ T^* = \min_{T \in \Pi(\mu, \nu)} \langle M, T \rangle = \min_{T \in \Pi(\mu, \nu)} \sum_{i=1}^{N \times H \times W} \sum_{j=1}^{N_p} M_{ij} T_{ij} \quad (2) \\ \text{s.t } \Pi(\mu, \nu) = \{T \in \mathbb{R}_+^{(NHW) \times N_p} | T1_{N_p} = \mu, T1_{NHW} = \nu\}, $$

where $\langle \cdot, \cdot \rangle$ designates the Frobenius dot product. $\mu$ and $\nu$ are the mass distributions respectively associated with the embeddings and the prototypes; without any *a priori* knowledge on the data, both are set to uniform distributions. $M \in \mathbb{R}^{(NHW) \times N_p}$ designates the total cost matrix between the input embeddings and the prototypes. More specifically, this cost matrix is a normalized version of the cost $C$ introduced in Eq. (1):

$$ M = (1 - \alpha) \frac{M_{\text{feat}}}{\max(M_{\text{feat}})} + \alpha \frac{M_{\text{struct}}}{\max(M_{\text{struct}})} \quad (3) $$

with $M_{\text{feat}}(i, j) = 1 - \frac{\langle z_i, p_j \rangle}{\|z_i\| \|p_j\|}$ and $M_{\text{struct}}(i, j) = \|c_i - \rho_j\|^2$.

In practice, solving Eq. (2) is not computationally efficient. In our case, considering ResNet50 as backbone and input images of size $224 \times 224$, for $l = 2$, a grid of features is composed of $28 \times 28 = 786$ vectors. If we consider solving the problem for multiple images and prototypes, the size of the cost matrix will rapidly grow and the solution will be intractable. To overcome this issue, we consider instead the entropic version of the optimal transport problem [8] by introducing a regularization term $H(T)$:

$$ \min_{T \in \Pi(\mu, \nu)} \langle M, T \rangle - \epsilon H(T), \quad (4) $$

where $\epsilon > 0$ and $H(T) = \sum_{i,j} T_{ij}(\log T_{ij} - 1)$. This formulation makes the problem strictly convex, which allows for much faster solving using the Sinkhorn-Knopp algorithm.
**Prototypes update.** Instead of computing the optimal transport plan between the prototypes and the entire training dataset at once, we process the inputs in batches. This strategy not only enables the method to scale to large datasets but also allows for the use of data augmentation during training, thereby increasing sample diversity and reducing the risk of overfitting. At each step of the training, we draw a subset of images {$x_i$}$_{i=1}^B$ from our training set, with $B \ge n$, and find the optimal transport $T^*$ plan in Eq. (4) between all $B$ embeddings of the considered batch {$f_{ij}^n$}$_{i,j,n=1}^B$ and all $n \times H \times W$ prototypes. $T^*$ contains the assignment weights between batch embeddings and prototypes. Analogous to the barycentre search algorithm in [35], the features of the prototypes are updated using these assignation weights:

$$p_i \leftarrow \eta p_i + (1 - \eta) N_p \sum_{k=1}^{B \times H \times W} T^*(k, i) z_k \quad (5)$$

where $\eta \in [0, 1]$ is the exponential moving average update parameter. When the parameter in the cost $\alpha$ equals zero, the prototypes are only feature-based (or global) barycentres of the training dataset. As $\alpha$ increases, a prototype $p_i$ gathers information from its spatial neighbours and becomes more of a local barycentre. The pseudocode describing prototype learning is provided in Appendix B.

## 3.2 Anomaly localization et image-level score

Once the prototype features have been learnt, we can infer the anomaly map for defect localization as well as the image-level score. First, we pass the image through the encoder $\phi_\theta$ to get their intermediate feature representation {$F^l$}$_l$. For each embedding $f = (z, c)$, the anomaly score $S_f$ is the minimum distance between the embedding and the prototypes for the cost of Eq. (1):

$$S_f = \min_{P \in \mathcal{P}} \mathcal{C}(f, P) \quad (6)$$

Intuitively, when $\alpha$ increases, a greater structural constraint is applied to find the closest prototype to $f$. If no similar prototype in terms of feature representation can be found in the spatial neighbourhood of the embedding, the assignment will either favour a far prototype with higher feature similarity, or a nearby prototype with lower feature similarity. In both cases, one of the two components of the cost (1) will increase, leading to a higher anomaly score $S_f$ compared to normal embeddings, which are able to match with semantically and spatially coherent prototypes.

This process yields an anomaly map of size $H_l \times W_l$ for each scale $l$, computed separately using global ($\alpha = 0$) and local ($\alpha > 0$) prototypes. The two resulting maps are then averaged and upsampled to the original image resolution to produce the anomaly map $A_l$. The final prediction $\mathcal{A}$ for anomaly localization is obtained by averaging the predictions across all scales $\mathcal{A} = \sum_l A_l$. The image-level score is defined as the maximum value of the final anomaly map.
# 4 Experiments and Discussions

## 4.1 Experimental Setup

**Datasets.** We use two public datasets for anomaly detection and localization on industrial images: MVTec AD [2] and MVTec AD LOCO [1]. The first comprises 15 categories, which can either be objects or textures, each containing around 100 to 300 anomaly-free images per category for the training and between 44 and 175 images in the test set with various types of anomalies. The second was introduced more recently to propose more diverse defect types. The images are divided into five categories, each with around 400 samples for the training and 300 for the evaluation. The test samples contain anomalies that can be either structural defects or logical inconsistencies within the images.

**Metrics.** On MVTec AD, performance in anomaly segmentation is measured with the pixel-level AU-ROC and the image-level detection performance is measured with the AU-ROC based on the predicted image-level anomaly score. On MVTec AD LOCO, following [1], we use the AU-sPRO metric up to a false positive rate of 5% to assess the localization performance, and the AU-ROC for image-level classification performance.

**Implementation details and hyperparameters.** All images are resized to a common shape of 224 × 224. We use ResNet50 as backbone and extract intermediate features at the stages $l = 2, 3$, resulting in feature grids of respective sizes of 28 × 28 and 14 × 14. We set the number of prototypes per element of the spatial grid $n$ to 16, the exponential moving average learning rate $\eta$ to 0.95 and the value of $\alpha$ to 0.3 for local prototypes. The weights of the prototypes are initially randomly initialized with a Gaussian distribution with a mean of 0 and a standard deviation of 1. The regularization parameter to solve the optimal transport problem (4) is set to 0.01, and we limit the number of iterations for the Sinkhorn-Knopp algorithm to 100. The model is trained for 50 epochs with a batch size of 64 and no data augmentation is applied.

## 4.2 Results

We compare our approach with several baselines from the literature, namely Cut-Paste [19], STPM [37], PaDiM [3], FastFlow [44], DRAEM [45], PatchCore [25], SPADE [6] and RD4D [10]. For all these methods, we report their performances from the study [38], which provides an extensive and uniform benchmark on industrial image anomaly detection and localization. Table 1 reports the results of our method compared to baselines on the datasets MVTec AD LOCO and MVTec AD, respectively. Figure 2 showcases some visual examples of anomaly localizations for both datasets.

On MVTec AD LOCO, PRADOT achieves an average image-level anomaly detection AU-ROC of 78.9% and an AU-sPRO of 52.6% for pixel-level segmentation. Among all compared methods, our method ranks second both in terms
<figure><img src="image_3.png" /><figcaption>**Fig. 2.** Examples of predictions of anomaly localization, including failure cases, on various objects of MVTec AD LOCO (top) and MVTec AD (bottom).</figcaption></figure>

<table><caption>**Table 1.** Results of our method compared to several UAD baselines on MVTec AD LOCO and MVTec AD. The metrics reported are the averages over all categories of each dataset. The results of the baselines are taken from [38]. Full results by category are provided in Appendix A.</caption><thead><tr><th rowspan="2"></th><th colspan="2">MVTec AD LOCO</th><th colspan="2">MVTec AD</th></tr><tr><th>Classification (AU-ROC)</th><th>Localization (AU-sPRO)</th><th>Classification (AU-ROC)</th><th>Localization (AU-ROC)</th></tr></thead><tbody><tr><td>CutPaste</td><td>82.3</td><td>-</td><td>91.8</td><td>-</td></tr><tr><td>STPM</td><td>68.0</td><td>42.8</td><td>92.4</td><td>95.4</td></tr><tr><td>PaDiM</td><td>67.1</td><td>42.6</td><td>90.8</td><td>96.6</td></tr><tr><td>SPADE</td><td>70.1</td><td>52.0</td><td>85.4</td><td>95.5</td></tr><tr><td>FastFlow</td><td>72.0</td><td>35.7</td><td>90.5</td><td>95.5</td></tr><tr><td>DRAEM</td><td>73.6</td><td>42.6</td><td>98.1</td><td>97.5</td></tr><tr><td>PatchCore</td><td>75.5</td><td>34.3</td><td>99.2</td><td>99.4</td></tr><tr><td>RD4AD</td><td>78.7</td><td>63.7</td><td>98.6</td><td>97.8</td></tr><tr><td>PRADOT (ours)</td><td>78.9</td><td>52.6</td><td>97.3</td><td>97.6</td></tr></tbody></table>

of classification and localization. On MVTec AD, our method reaches a classification AU-ROC score of 97.3% and a localization score of 97.6%. Notably, on MVTec AD LOCO, PRADOT outperforms the SOTA memory-based method PatchCore, but the latter is significantly ahead on MVTec AD. This behavior is mainly due to the differences in types of anomalies between the two datasets. Indeed, MVTec AD mainly contains structural defects such as dents and scratches, while MVTec AD LOCO also contains anomalies in the form of violations of the logical rules, such as permissible objects occurring in invalid locations. With PRADOT, we introduce local prototypes that can identify such logical anomalies, but the way we learn the prototypes seems less effective than PatchCore for
<table><caption>**Table 2.** Impact of local and global averaging (Avg.) and multi-scale aggregation on the performance on the datasets MVTec AD LOCO and MVTec AD. Performances are given as Image AU-ROC/Pixel AU-sPRO for MVTec AD LOCO and Image AU-ROC/Pixel AU-ROC for MVTec AD.</caption><thead><tr><th rowspan="2"></th><th colspan="3">l = 2</th><th colspan="3">l = 3</th><th rowspan="2">PRADOT</th></tr><tr><th>α = 0</th><th>α = 0.3</th><th>Avg.</th><th>α = 0</th><th>α = 0.3</th><th>Avg.</th></tr></thead><tbody><tr><td>MVTec AD LOCO</td><td>75.5/47.5</td><td>76.1/49.1</td><td>76.4/49.4</td><td>76.3/42.4</td><td>75.8/42.3</td><td>76.4/44.0</td><td>78.9/52.6</td></tr><tr><td>MVTec AD</td><td>96.7/96.1</td><td>96.6/96.6</td><td>97.0/96.8</td><td>95.2/96.1</td><td>95.2/96.0</td><td>95.4/96.1</td><td>97.3/97.6</td></tr></tbody></table>

structural anomalies. On MVTec AD, most objects or textures are either symmetric or uniform. Consequently, learning local prototypes has little to no advantage compared to learning global embedding representatives. This phenomenon, as well as the role of global and local prototypes in detecting structural and logical anomalies, will be further discussed in Section 4.3.

Qualitatively, Figure 2 shows that our method can spot both large and subtle defects. On MVTec AD LOCO, PRADOT can successfully detect structural and logical anomalies, although the segmentation performances are notably better for structural anomalies (see Figure 3.b)).

## 4.3 Ablation study

**Local, global and multi-scale aggregation.** We investigate in Table 2 the importance of aggregating anomaly detection maps obtained from global ($α = 0$) or local ($α > 0$) embedding-to-prototype assignment and the benefits of extracting features at various stages of the image encoder. On scales $l = 2$ and $l = 3$, averaging global and local predictions (Avg.) improves the performance of the model on the two datasets and both in terms of image-level classification and pixel-level detection. An even greater performance gain is achieved with multi-scale aggregation. We can also notice that the scale $l = 2$ is slightly better at pixel-level anomaly localization than the scale $l = 3$.

**Number of prototypes and batch size.** An important hyperparameter of the model is the number of prototypes per grid cell $n$. Moreover, when learning prototypes, previous works [5] have shown that using a large batch size is essential. Therefore, we study how the parameter $n$ influences the performance of our approach and vary the ratio between the batch size and $n$ to see if a low ratio deteriorates the performance. Figure 3.a) illustrates these two experiments on MVTec AD LOCO. As expected, performance is noticeably reduced when the ratio between the batch size and the parameter $n$ is low, in particular when the batch size is equal to or lower than $n$. However, our model does not require a very large batch size, as the improvement between a value of 2 and 4 for this ratio is small. Regarding the number of prototypes per grid cell $n$, it plays an important role in the classification and localization performances, as we observe a substantial difference in metrics between $n = 4, n = 8$ and $n = 16$.
<figure><img src="image_4.png" /><figcaption>**Fig. 3.** a) Impact of the ratio between batch size and number of prototypes per grid cell $n$ on MVTec AD LOCO in terms of image-level classification and pixel-level localization, for $\alpha = 0.3$. b) Impact of the parameter $\alpha$ on the localization performance on structural and logical anomalies for MVTec AD LOCO and on all categories but *transistor* and on *transistor* only for MVTec AD.</figcaption></figure>

**Impact of the structural constraint.** We investigate the impact of the structural constraint in loss (1) and the role of global and local prototypes by evaluating how the parameter $\alpha$ influences the classification and localization performance. The results of this experiment are shown in Figure 3.b). On MVTec AD LOCO, we distinguish performance on structural and logical anomalies. There are clear correlations between the value of $\alpha$ and the localization performance of logical and structural anomalies. A higher value of $\alpha$ is beneficial for identifying logical defects while a lower value improves the localization of structural imperfections. On MVTec AD, all objects except *transistor* are symmetric and all textures are uniform. Moreover, the anomalies are mainly alterations of the shape, surface or colour of the objects or textures. Thus, imposing a structural constraint on the embedding-to-prototype assignment with a strictly positive value for $\alpha$ is of little or no use. This phenomenon is clearly observable in Figure 3.b), where the pixel-level AU-ROC of all categories except *transistor* is slightly decreased when $\alpha$ increases, while the same metric on *transistor* only is greatly boosted by a greater structural constraint, i.e. a high value for $\alpha$. Figure 4 shows three examples of logical anomalies and the estimated anomaly score map of the scale $l = 2$ for three values of $\alpha$. We also show with blue arrows where each feature extracted from the $H_2 \times W_2$ grid finds its closest prototypes for Eq. (6). The features of anomalous regions of the images are associated with prototypes located elsewhere in the image. When $\alpha$ is low, the cost (6) does not much penalize such a violation of structural organization, hence the anomaly maps for $\alpha = 0$ and $\alpha = 0.3$ fail to catch those logical anomalies. However, for $\alpha = 0.5$, the penalty for not having found a similar prototype in the neighbourhood of the features is high enough to be able to detect the anomalous regions.

**Prototypes visualization and image reconstructions.** When training is finished and the weights of the prototypes are fixed, we can try to visualize in the pixel domain what each prototype looks like. To do so, for a scale $l$ at which the features are extracted from the encoder, we divide each image of the training into a grid of $H_l \times W_l$ of non-overlapping patches of sizes $\frac{H_0}{H_l} \times \frac{W_0}{W_l}$ where $H_0$
<figure><img src="image_5.png" /><figcaption>**Fig. 4.** Examples of embedding-to-prototype assignment at scale *l* = 2 for α = 0, 0.3 and 0.5. Each blue vector starts from the position (i, j) of a feature extracted from the input image and ends at the position of the prototype to which it has been assigned for the Eq. (6). When α increases, a greater structural constraint is applied, which allows to identify some logical anomalies that global embedding-to-prototype assignments (α = 0) can not spot. Best viewed zoomed in.</figcaption></figure>

and $W_0$ designate the height and width of an input image. For a feature map of size $H_l \times W_l$, we consider that the representation in the pixel space of a feature vector at position (i, j) of the grid is the patch located at the same spot in the input image. We iterate over all the images in the training dataset and, for each prototype, we find the feature with which it maximizes the cosine similarity and associate to this prototype the patch in the pixel domain corresponding to this feature. The left part of Figure 5 illustrates how this procedure allows for reconstructing prototypes. We can observe that when there is more than one prototype per grid cell, i.e. when $n > 1$, each prototype can learn a different feature from the images of the training dataset.

Once this is done, when a test image is given to the model, we can look, for each feature extracted by the encoder, for the prototype which minimizes the cost $C$, or the antecedent of the Eq. (6), and replace in the original test image the patch corresponding to the feature by the pixel-level representation of the prototype in question. The right part of Figure 5 displays some examples of restored test images that can be obtained with this method. We can observe that abnormal regions are removed from the images and often replaced by semantically coherent patches. This property could potentially be leveraged to further improve the detection performance.

**Latent space visualization.** We provide with Figure 6 a last visualization of the influence of the parameter $\alpha$. We project the embeddings of test images and prototypes for the object *transistor* into a 2-dimensional space using UMAP [22] and the cost (1) as the pairwise distance. Each point, cross or diamond corresponds to a single embedding or prototype at the scale *l* = 2. An embedding
<figure><img src="image_6.png" /><figcaption>**Fig. 5.** (left) Examples of reconstructed prototypes in the image domain by association with the patch corresponding to the feature with the highest cosine similarity. (right) For a test image, we can obtain a restored version of the image where each patch comes from the representation in the pixel domain of the reconstructed prototypes.</figcaption></figure>

<figure><img src="image_7.png" /><figcaption>**Fig. 6.** UMAP projections of normal embeddings, abnormal embeddings and prototypes for various values of $\alpha$. The cost (1) is used as a pairwise distance between the points to compute their 2-dimensional projection. Colour gradient encodes the spatial position of embeddings and prototypes. Best viewed zoomed in.</figcaption></figure>

of a test image is considered abnormal if its corresponding patch in the image domain has more than 30% of abnormal pixels. We also colour each symbol with a gradient based on the spatial location on the $H_l \times W_l$ grid of the associated embedding or prototype. This means that two embeddings or prototypes with similar colours come from the same part of the image. When $\alpha$ is close to zero, image embeddings and prototypes can be neighbouring even if they come from different regions of the images. As $\alpha$ increases, the neighbourhoods become more spatially coherent and the assignment of an embedding to a prototype must comply with this spatial constraint.
# 5 Conclusion

In this work, we propose a novel prototype-based method to tackle the challenging task of unsupervised anomaly detection on industrial images. We leverage pre-trained image encoders and optimal transport to learn prototypes. We introduce a distance function that balances a feature-based cost and a spatial-based cost. By playing on the ratio between these two components, we can enforce a structural constraint during the learning of the prototypes and at inference, which allows for better detection of incoherencies in the images. Evaluated on the public benchmarks MVTec AD LOCO and MVTec AD, our method achieves performance on par with strong baselines.

One of the advantages of our approach is the simplicity and comprehensibility of the prototype learning and inference procedure. This makes it easy to understand and anticipate the strengths and weaknesses of the method depending on the application, the structure of the input images and the type of anomalies to detect. PRADOT is inspired by the problem of barycentre search in fused Gromov Wasserstein [35]. Compared to our problem formulation, FGW is a graph-based approach and therefore implies different geometrical constraints, such as permutation invariance, which may be beneficial for some applications. The investigation of this extension is left for future work. We believe that the spatially consistent assignment used in our approach could have applications in other problems, such as supervised image segmentation, or combined with other UAD approaches that use a memory mechanism [34, 11, 13].

**Acknowledgments.** This work was partially funded by ANR-18-CE17-0012 (IMAGINA) and ANR-24-CE45-4399 (SEIZURE) grants from Agence Nationale de la Recherche (ANR). This work was granted access to the HPC resources of IDRIS under the allocation 2025-AD011014900R1 made by GENCI.

**Disclosure of Interests.** The authors have no competing interests to declare that are relevant to the content of this article.
## A Additional results

<table><caption>**Table 3.** Results of our method compared to several UAD baselines on all five categories of MVTec AD LOCO. Performance metrics are displayed as: Image-level AU-ROC / Pixel-level AU-sPRO (5%). Results of the baselines are taken from [38].</caption><thead><tr><th>Method</th><th>Breakfast box</th><th>Juice bottle</th><th>Pushpins</th><th>Screw bag</th><th>Connectors</th><th>Mean</th></tr></thead><tbody><tr><td>CutPaste</td><td>86.4/-</td><td>92.5/-</td><td>72.6/-</td><td>78.0/-</td><td>81.9/-</td><td>82.3/-</td></tr><tr><td>STPM</td><td>50.7/14.2</td><td>85.2/65.4</td><td>68.8/43.5</td><td>67.6/34.8</td><td>67.9/56.3</td><td>68.0/42.8</td></tr><tr><td>PaDiM</td><td>57.5/49.4</td><td>88.1/82.6</td><td>63.2/32.6</td><td>61.5/45.8</td><td>65.1/50.0</td><td>67.1/52.1</td></tr><tr><td>FastFlow</td><td>59.3/12.2</td><td>84.7/52.9</td><td>66.4/37.7</td><td>72.2/14.5</td><td>77.1/61.4</td><td>72.0/35.7</td></tr><tr><td>DRAEM</td><td>73.4/44.2</td><td>86.9/73.3</td><td>69.1/39.4</td><td>71.8/20.7</td><td>66.9/35.3</td><td>73.6/42.6</td></tr><tr><td>PatchCore</td><td>77.7/38.1</td><td>86.1/39.4</td><td>70.2/22.3</td><td>74.8/45.1</td><td>68.7/26.3</td><td>75.5/34.3</td></tr><tr><td>SPADE</td><td>63.0/24.3</td><td>88.0/73.4</td><td>62.6/42.7</td><td>60.9/50.4</td><td>75.9/68.9</td><td>70.1/52.0</td></tr><tr><td>RD4AD</td><td>68.7/42.3</td><td>93.9/83.8</td><td>74.5/62.1</td><td>71.2/57.4</td><td>85.3/73.0</td><td>78.7/63.7</td></tr><tr><td>PRADOT (ours)</td><td>81.6/56.9</td><td>89.7/68.9</td><td>73.0/39.0</td><td>70.5/44.4</td><td>79.6/53.9</td><td>78.9/52.6</td></tr></tbody></table>

<table><caption>**Table 4.** Results of our method compared to several UAD baselines on all fifteen categories of MVTec AD. The performance metrics are displayed as: Image-level AU-ROC / Pixel-level AU-ROC. The results of the baselines are taken from [38].</caption><thead><tr><th>Method</th><th>SPADE</th><th>DRAEM</th><th>FastFlow</th><th>PaDiM</th><th>PatchCore</th><th>STPM</th><th>PRADOT (ours)</th></tr></thead><tbody><tr><td>Carpet</td><td>95.0/99.2</td><td>96.3/96.2</td><td>87.5/96.1</td><td>88.9/98.9</td><td>98.8/99.2</td><td>92.5/98.8</td><td>99.9/99.2</td></tr><tr><td>Grid</td><td>91.3/84.6</td><td>100.0/99.6</td><td>88.1/95.9</td><td>90.4/96.5</td><td>97.9/99.0</td><td>77.4/76.5</td><td>96.2/97.5</td></tr><tr><td>Leather</td><td>94.9/98.3</td><td>100.0/98.9</td><td>96.1/97.5</td><td>84.3/98.1</td><td>100.0/99.4</td><td>95.3/98.6</td><td>100.0/99.3</td></tr><tr><td>Tile</td><td>97.1/98.9</td><td>100.0/99.5</td><td>63.2/92.3</td><td>86.5/97.8</td><td>99.5/96.4</td><td>99.0/98.4</td><td>100.0/95.7</td></tr><tr><td>Wood</td><td>72.2/95.1</td><td>99.2/97.2</td><td>90.8/94.3</td><td>80.8/95.7</td><td>99.1/94.9</td><td>96.3/98.8</td><td>99.0/94.6</td></tr><tr><td>Bottle</td><td>99.4/97.1</td><td>96.9/99.3</td><td>100.0/98.0</td><td>99.4/98.4</td><td>100.0/98.8</td><td>100.0/98.3</td><td>100.0/98.5</td></tr><tr><td>Cable</td><td>86.2/91.6</td><td>93.4/95.4</td><td>91.2/93.5</td><td>85.0/95.4</td><td>99.7/98.8</td><td>74.8/88.4</td><td>99.1/98.4</td></tr><tr><td>Capsule</td><td>97.3/85.8</td><td>96.1/94.0</td><td>99.2/93.0</td><td>94.9/90.6</td><td>97.9/99.2</td><td>94.4/96.9</td><td>93.4/98.4</td></tr><tr><td>Hazelnut</td><td>88.7/92.5</td><td>100.0/99.5</td><td>98.8/92.7</td><td>99.1/93.0</td><td>100.0/99.0</td><td>95.6/87.8</td><td>100.0/98.9</td></tr><tr><td>Metal</td><td>83.4/98.7</td><td>99.4/98.7</td><td>90.8/97.4</td><td>87.6/98.5</td><td>99.9/98.7</td><td>94.0/98.0</td><td>100.0/96.6</td></tr><tr><td>Pill</td><td>78.4/97.5</td><td>96.8/97.6</td><td>98.0/98.9</td><td>98.1/98.8</td><td>96.7/98.3</td><td>93.0/98.7</td><td>95.7/97.2</td></tr><tr><td>Screw</td><td>47.4/97.6</td><td>99.2/99.7</td><td>97.8/98.1</td><td>92.2/94.5</td><td>98.8/99.6</td><td>97.6/98.9</td><td>91.0/97.9</td></tr><tr><td>Toothbrush</td><td>90.5/99.2</td><td>99.7/98.1</td><td>100.0/99.4</td><td>100.0/99.2</td><td>100.0/98.8</td><td>100.0/99.4</td><td>88.3/98.6</td></tr><tr><td>Transistor</td><td>85.9/97.1</td><td>94.2/90.0</td><td>88.1/92.7</td><td>94.1/96.6</td><td>99.9/96.1</td><td>97.2/95.5</td><td>99.3/96.2</td></tr><tr><td>Zipper</td><td>73.3/99.4</td><td>99.7/98.6</td><td>67.5/93.4</td><td>80.9/97.8</td><td>99.5/99.0</td><td>78.5/97.6</td><td>97.2/96.8</td></tr><tr><td>Average</td><td>85.4/95.5</td><td>98.1/97.5</td><td>90.5/95.5</td><td>90.8/96.6</td><td>99.2/99.4</td><td>92.4/95.4</td><td>97.3/97.6</td></tr></tbody></table>
B Pseudocode for prototype learning algorithm

<caption>**Algorithm 1:** Prototype learning with PRADOT</caption>

**Input:**
$\mathcal{D}^{\text{train}} = \{x_i\}_{i=1}^{N_{\text{train}}}$, pre-trained feature encoder $\phi_{\theta}$, stages $\{l\}_{l \in L}$ at which features are extracted from $\phi_{\theta}$, number of prototypes per grid cell $n$, cost parameter $\alpha$, EMA rate $\eta$, entropic regularization $\epsilon$, batch size $B$.

**Initialization:**
**foreach** intermediate stage $l \in L$ **do**
    Prototypes $\mathcal{P}_l = \{(p_{i,l}, \rho_{i,l})\}_{i=1}^{n \times H \times W}$.
**end**

**while** not converged **do**
    Sample $\{x_k\}_{k=1}^B$ from $\mathcal{D}^{\text{train}}$
    Extract multi-scale features: $\{z_k\}_{k \in L} \leftarrow \phi_{\theta}(x_k)$
    **foreach** intermediate stage $l \in L$ **do**
        Compute cost matrix $M$ (Eq.3) between embeddings and prototypes
        Solve entropic OT problem (Eq.4) with Sinkhorn algorithm to obtain $T^*$
        **for** prototype $p_i$ **do**
            Update $p_{i,l} \leftarrow \eta p_{i,l} + (1-\eta)(n \times H_l \times W_l) \sum_{k=1}^{B \times H_l \times W_l} T^*(k, i)z_k$
        **end**
    **end**
**end**

References

1. Bergmann, P., Batzner, K., Fauser, M., Sattlegger, D., Steger, C.: Beyond dents and scratches: Logical constraints in unsupervised anomaly detection and localization. International Journal of Computer Vision **130**(4), 947–969 (2022)

2. Bergmann, P., Fauser, M., Sattlegger, D., Steger, C.: Mvtec ad — a comprehensive real-world dataset for unsupervised anomaly detection. In: 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). pp. 9584–9592 (2019)

3. Brendel, W., Bethge, M.: Approximating cnns with bag-of-local-features models works surprisingly well on imagenet. International Conference on Learning Representations (2019)

4. Cao, Z., Xu, Q., Yang, Z., He, Y., Cao, X., Huang, Q.: Otkge: Multi-modal knowledge graph embeddings via optimal transport. Advances in neural information processing systems **35**, 39090–39102 (2022)

5. Caron, M., Misra, I., Mairal, J., Goyal, P., Bojanowski, P., Joulin, A.: Unsupervised learning of visual features by contrasting cluster assignments. Advances in neural information processing systems **33**, 9912–9924 (2020)

6. Cohen, N., Hoshen, Y.: Sub-image anomaly detection with deep pyramid correspondences. arXiv preprint arXiv:2005.02357 (2020)
7. Courty, N., Flamary, R., Tuia, D., Rakotomamonjy, A.: Optimal transport for domain adaptation. IEEE transactions on pattern analysis and machine intelligence 39(9), 1853–1865 (2016)

8. Cuturi, M.: Sinkhorn distances: Lightspeed computation of optimal transport. In: Advances in Neural Information Processing Systems. vol. 26 (2013)

9. Damodaran, B.B., Kellenberger, B., Flamary, R., Tuia, D., Courty, N.: Deepjdot: Deep joint distribution optimal transport for unsupervised domain adaptation. In: Proceedings of the European conference on computer vision (ECCV). pp. 447–463 (2018)

10. Deng, H., Li, X.: Anomaly detection via reverse distillation from one-class embedding. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). pp. 9737–9746 (June 2022)

11. Gong, D., Liu, L., Le, V., Saha, B., Mansour, M.R., Venkatesh, S., Hengel, A.v.d.: Memorizing normality to detect anomaly: Memory-augmented deep autoencoder for unsupervised anomaly detection. In: Proceedings of the IEEE/CVF international conference on computer vision. pp. 1705–1714 (2019)

12. Goodfellow, I., Pouget-Abadie, J., Mirza, M., Xu, B., Warde-Farley, D., Ozair, S., Courville, A., Bengio, Y.: Generative adversarial networks. Communications of the ACM 63(11), 139–144 (2020)

13. Guo, H., Ren, L., Fu, J., Wang, Y., Zhang, Z., Lan, C., Wang, H., Hou, X.: Template-guided hierarchical feature restoration for anomaly detection. In: Proceedings of the IEEE/CVF International Conference on Computer Vision. pp. 6447–6458 (2023)

14. He, K., Zhang, X., Ren, S., Sun, J.: Deep residual learning for image recognition. In: Proceedings of the IEEE conference on computer vision and pattern recognition. pp. 770–778 (2016)

15. Ho, J., Jain, A., Abbeel, P.: Denoising diffusion probabilistic models. Advances in neural information processing systems 33, 6840–6851 (2020)

16. Izquierdo, S., Civera, J.: Optimal transport aggregation for visual place recognition. In: Proceedings of the ieee/cvf conference on computer vision and pattern recognition. pp. 17658–17668 (2024)

17. Kim, J., Oh, T.H., Lee, S., Pan, F., Kweon, I.S.: Variational prototyping-encoder: One-shot learning with prototypical images. In: Proceedings of the IEEE/CVF conference on computer vision and pattern recognition. pp. 9462–9470 (2019)

18. Kim, K., Oh, Y., Ye, J.C.: Zegot: Zero-shot segmentation through optimal transport of text prompts. arXiv preprint arXiv:2301.12171 (2023)

19. Li, C.L., Sohn, K., Yoon, J., Pfister, T.: Cutpaste: Self-supervised learning for anomaly detection and localization. In: Proceedings of the IEEE/CVF conference on computer vision and pattern recognition. pp. 9664–9674 (2021)

20. Lu, H., Gong, D., Wang, S., Xue, J., Yao, L., Moore, K.: Learning with mixture of prototypes for out-of-distribution detection. arXiv preprint arXiv:2402.02653 (2024)

21. Lu, Y., Qin, Y., Zhai, R., Shen, A., Chen, K., Wang, Z., Kolouri, S., Stepputtis, S., Campbell, J., Sycara, K.: Characterizing out-of-distribution error via optimal transport. Advances in Neural Information Processing Systems 36, 17602–17622 (2023)

22. McInnes, L., Healy, J., Melville, J.: UMAP: Uniform Manifold Approximation and Projection for Dimension Reduction. ArXiv e-prints (2018)

23. Park, H., Noh, J., Ham, B.: Learning memory-guided normality for anomaly detection. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. pp. 14372–14381 (2020)
24. Peyré, G., Cuturi, M., Solomon, J.: Gromov-wasserstein averaging of kernel and distance matrices. In: International conference on machine learning. pp. 2664–2672. PMLR (2016)

25. Roth, K., Pemula, L., Zepeda, J., Schölkopf, B., Brox, T., Fehler, P.: Towards total recall in industrial anomaly detection. In: Proceedings of the IEEE/CVF conference on computer vision and pattern recognition. pp. 14318–14328 (2022)

26. Ruff, L., Vandermeulen, R.A., Görnitz, N., Deecke, L., Siddiqui, S.A., Binder, A., Müller, E., Kloft, M.: Deep one-class classification. In: Proceedings of the 35th International Conference on Machine Learning. vol. 80, pp. 4393–4402 (2018)

27. Schlegl, T., Seeböck, P., Waldstein, S.M., Langs, G., Schmidt-Erfurth, U.: f-anogan: Fast unsupervised anomaly detection with generative adversarial networks. Medical image analysis **54**, 30–44 (2019)

28. Schlüter, H.M., Tan, J., Hou, B., Kainz, B.: Natural synthetic anomalies for self-supervised anomaly detection and localization. In: European Conference on Computer Vision. pp. 474–489. Springer (2022)

29. Shan, D., Zhang, Y., Coleman, S., Kerr, D., Liu, S., Hu, Z.: Unseen-material few-shot defect segmentation with optimal bilateral feature transport network. IEEE Transactions on Industrial Informatics **19**(7), 8072–8082 (2023). https://doi.org/10.1109/TII.2022.3216900

30. Snell, J., Swersky, K., Zemel, R.: Prototypical networks for few-shot learning. Advances in neural information processing systems **30** (2017)

31. Tax, D.M., Duin, R.P.: Support vector data description. Machine learning **54**, 45–66 (2004)

32. Thual, A., Tran, Q.H., Zemskova, T., Courty, N., Flamary, R., Dehaene, S., Thirion, B.: Aligning individual brains with fused unbalanced gromov wasserstein. Advances in neural information processing systems **35**, 21792–21804 (2022)

33. Tian, L., Li, Y., Dai, Y., Chen, W., Liu, X., Chen, B.: Fastref:fast prototype refinement for few-shot industrial anomaly detection (2025), https://arxiv.org/abs/2506.21398

34. Van Den Oord, A., Vinyals, O., et al.: Neural discrete representation learning. Advances in neural information processing systems **30** (2017)

35. Vayer, T., Courty, N., Tavenard, R., Laetitia, C., Flamary, R.: Optimal transport for structured data with application on graphs. In: Proceedings of the 36th International Conference on Machine Learning. vol. 97, pp. 6275–6284 (2019)

36. Vincent-Cuaz, C., Flamary, R., Corneli, M., Vayer, T., Courty, N.: Template based graph neural network with optimal transport distances. Advances in Neural Information Processing Systems **35**, 11800–11814 (2022)

37. Wang, G., Han, S., Ding, E., Huang, D.: Student-teacher feature pyramid matching for anomaly detection. arXiv preprint arXiv:2103.04257 (2021)

38. Xie, G., Wang, J., Liu, J., Lyu, J., Liu, Y., Wang, C., Zheng, F., Jin, Y.: Im-iad: Industrial image anomaly detection benchmark in manufacturing. IEEE Transactions on Cybernetics **54**(5), 2720–2733 (2024)

39. Xu, M., Gould, S.: Temporally consistent unbalanced optimal transport for unsupervised action segmentation. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. pp. 14618–14627 (2024)

40. Xu, Y., Chen, H.: Multimodal optimal transport-based co-attention transformer with global structure consistency for survival prediction. In: Proceedings of the IEEE/CVF international conference on computer vision. pp. 21241–21251 (2023)

41. Yan, X., Zhang, H., Xu, X., Hu, X., Heng, P.A.: Learning semantic context from normal samples for unsupervised anomaly detection. In: Proceedings of the AAAI conference on artificial intelligence. vol. 35, pp. 3110–3118 (2021)
42. Yao, H., Liu, M., Yin, Z., Yan, Z., Hong, X., Zuo, W.: Glad: towards better reconstruction with global and local adaptive diffusion models for unsupervised anomaly detection. In: European Conference on Computer Vision. pp. 1–17. Springer (2024)

43. Yi, J., Yoon, S.: Patch svdd: Patch-level svdd for anomaly detection and segmentation. In: Proceedings of the Asian conference on computer vision (2020)

44. Yu, J., Zheng, Y., Wang, X., Li, W., Wu, Y., Zhao, R., Wu, L.: Fastflow: Unsupervised anomaly detection and localization via 2d normalizing flows. arXiv preprint arXiv:2111.07677 (2021)

45. Zavrtanik, V., Kristan, M., Skočaj, D.: Draem-a discriminatively trained reconstruction embedding for surface anomaly detection. In: Proceedings of the IEEE/CVF international conference on computer vision. pp. 8330–8339 (2021)

46. Zavrtanik, V., Kristan, M., Skočaj, D.: Reconstruction by inpainting for visual anomaly detection. Pattern Recognition **112**, 107706 (2021)

47. Zhang, J., Suganuma, M., Okatani, T.: Contextual affinity distillation for image anomaly detection. In: Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision. pp. 149–158 (2024)

48. Zhou, T., Wang, W., Konukoglu, E., Van Gool, L.: Rethinking semantic segmentation: A prototype view. In: Proceedings of the IEEE/CVF conference on computer vision and pattern recognition. pp. 2582–2593 (2022)

49. Zhou, Y., Xu, X., Song, J., Shen, F., Shen, H.T.: Msflow: Multiscale flow-based framework for unsupervised anomaly detection. IEEE Transactions on Neural Networks and Learning Systems (2024)