betaFeedback

WorksComputer Science

MSW: a Multi-Scale Sliced Wasserstein Distance Between Image Distributions

Abstract

We propose the multi-scale sliced Wasserstein (MSW) distance between image distributions, which operates in pixel space and requires no trained network. MSW convolves images with a fixed bank of discrete cosine filters at several scales, pools the responses over all positions, and compares the resulting one-dimensional distributions using the Wasserstein distance. We pair MSW with an exact two-sample test that gives calibrated p-values. Most metrics compare two image sets in the latent space of a pretrained network. We show that these metrics are insensitive to simple perturbations of the images, because the latent space is nearly invariant to them. In contrast, MSW detects smaller perturbations than latent-space metrics and needs far fewer images to do so. Although it uses no learned features, it still detects semantic changes of the image distribution. Finally, MSW matches or outperforms existing Wasserstein-based metrics in our experiments.

Introduction

Many tasks require a comparison of two sets of images. A generative model, for instance, is evaluated by a distance between the distribution of its outputs and that of real images. For images with dd pixel values, the Wasserstein distance on Rd\mathbb{R}^{d} is expensive to compute, and its estimation requires a number of images exponential in dd [1]. In practice, the images are therefore first projected onto a simpler space, where distributions are easy to compare.

Latent-based metrics such as FID [2] and CMMD [3] are the standard choice. Each image is mapped to a latent space by a pretrained network, and the two sets of latent vectors are then compared using a distance, such as the Fréchet distance or a maximum mean discrepancy. Such metrics are only as sensitive as their latent spaces. The networks underlying FID and CMMD are trained to classify images or to match them with text. They have no reason to keep the details of an image that do not help with these tasks. Thus, their latent spaces are nearly invariant to small perturbations such as a faint noise, a slight blur or a faint periodic pattern. A latent-based metric detects such a perturbation only when it is strong or when many images are available, and it cannot detect a perturbation to which the latent space is invariant.

We propose the multi-scale sliced Wasserstein (MSW) distance, which is computed directly in pixel space and contains no trained component. Instead of a latent space, MSW projects the images onto many one-dimensional spaces. It convolves every image with a fixed bank of discrete cosine filters at different scales. A filter returns one value at every position of an image. For each filter, the values from all positions and all images of a set form a single histogram (Figure 1). The histograms of the two sets are then compared using the Wasserstein distance, which in one dimension reduces to a sorting operation. The use of every position is based on the approximate translation invariance of image statistics [4]. It allows MSW to operate with few images since each image contributes as many samples as it has positions instead of a single latent vector.

We compare MSW with FID, CMMD and the convolution sliced Wasserstein distance (CSW) [5]. For most low-level perturbations, such as noise, blur and periodic patterns, MSW detects much smaller amplitudes than the latent-based metrics, and it needs far fewer images. On Stable Diffusion images of increasing quality, it recovers the order of the sets from a few images more reliably than they do. On super-resolution networks, it agrees with them on the gain in realism brought by adversarial training. Semantic changes are the hardest case for a metric without learned features. MSW still separates nearly all pairs of COCO classes. Across all these experiments, MSW also outperforms CSW, which its authors report to improve on the conventional sliced Wasserstein distance on images. The code and the experiment scripts will be released upon acceptance.

Related work

We consider two families of metrics. Latent-based metrics compare two image sets in a latent space, and sliced Wasserstein distances compare one-dimensional projections of two image sets directly in pixel space.

Latent-based metrics. FID [2], the standard metric for generated images, fits a Gaussian to the Inception latent vectors of each set and reports the 2-Wasserstein distance between the two Gaussians. CMMD [3], designed to correct the weaknesses of FID, computes a Gaussian-kernel maximum mean discrepancy between CLIP latent vectors.

Sliced Wasserstein distances. The sliced Wasserstein distance (SW) [6, 7] averages the Wasserstein distance between the projections of the two distributions over uniformly random directions. Applied to vectorized images, random directions ignore the spatial structure of the data. CSW [5] accounts for this structure by projecting each image with a sequence of random convolutions. We take CSW as the baseline of this family, since it is designed for images. Sliced distances between distributions of patches or network features were used earlier to evaluate GANs [8] and as losses for texture synthesis [9, 10]. He et al. [11] measure colour differences between two images this way. In our experiments, CSW and the patch distance of Karras et al. [8] give similar results. MSW uses a fixed and interpretable filter bank rather than random directions. Unlike CSW, it keeps every position of a convolution output. Such filter banks come from texture analysis, where the histograms of their outputs describe the local statistics of an image [12]. The Fréchet wavelet distance [13] also uses fixed filters, but fits a Gaussian to their outputs.

The MSW distance

Background

For two probability distributions μ,ν\mu,\nu on Rd\mathbb{R}^{d} and for p≥1p \ge1, the pp-Wasserstein distance is

Wpp(μ,ν)=min⁡γ∈Π(μ,ν)∫∥x−y∥p dγ(x,y),(1)W_p^p(\mu,\nu)=\min_{\gamma\in\Pi(\mu,\nu)}\int\lVert x-y\rVert^p\,\mathrm{d}\gamma(x,y), \tag*{(1)}

where Π(μ,ν)\Pi(\mu,\nu) is the set of couplings of μ\mu and ν\nu, that is, the joint distributions γ\gamma on Rd×Rd\mathbb{R}^{d}\times\mathbb{R}^{d} whose marginals are μ\mu and ν\nu. In one dimension, WpW_p reduces to a comparison of the quantile functions1 QμQ_\mu and QνQ_\nu [14 Prop. 2.17],

Wpp(μ,ν)=∫01∣Qμ(t)−Qν(t)∣p dt,(2)W_p^p(\mu,\nu)=\int_0^1\lvert Q_\mu(t)-Q_\nu(t)\rvert^p\,\mathrm{d}t, \tag*{(2)}

and for two empirical distributions with nn samples each, it equals the mean of ∣x(i)−y(i)∣p\lvert x_{(i)}-y_{(i)}\rvert^p, where x(i)x_{(i)} and y(i)y_{(i)} are the iith smallest samples. In higher dimension, the optimal transport problem in (1) is costly to solve. The distance between the empirical distributions of nn samples also converges slowly to Wp(μ,ν)W_p(\mu,\nu), at the rate O(n−1/d)O(n^{-1/d}) [15].

The sliced Wasserstein distance [6, 7] avoids both issues. A direction is a unit vector θ∈Rd\theta\in\mathbb{R}^{d}. Let Pθ(x)=θTxP_\theta(x)=\theta^{\mathsf{T}}x denote the projection onto θ\theta and (Pθ)#μ(P_\theta)_{\#}\mu the pushforward of PθP_\theta for x∼μx\sim\mu. Then,

SW⁡pp(μ,ν)=Eθ[Wpp((Pθ)#μ,(Pθ)#ν)],(3)\operatorname{SW}_p^p(\mu,\nu)=\mathbb{E}_{\theta}\left[W_p^p\left((P_\theta)_{\#}\mu,(P_\theta)_{\#}\nu\right)\right], \tag*{(3)}

where θ\theta is uniform on the unit sphere Sd−1\mathbb{S}^{d-1}. By the Cramér–Wold theorem [16], SW⁡p\operatorname{SW}_p is a metric. Each projection costs a sort, and a Monte-Carlo estimate with JJ directions converges at the rate O(J−1/2)O(J^{-1/2}), independently of dd. The price is that a random direction mixes all coordinates and dilutes any difference between μ\mu and ν\nu. For p=2p=2, it is known [17 Sec. 2.2] that W2≤d−1/2W2W_2 \le d^{-1/2}W_2. For images, the directions along which two distributions differ are far from random.

Choice of the directions and scales

When μ\mu has a density, the one-dimensional densities of its projections (Pθ)#μ(P_\theta)_{\#}\mu over all directions θ\theta form the Radon transform of μ\mu [7, 18]. As in tomography, each projection is a view of μ\mu from one angle. The sliced Wasserstein distance compares μ\mu and ν\nu one projection at a time. The full set determines μ\mu, but only finitely many can be computed.

If the projections of an image onto two directions are correlated, the second direction only tells little more than the first. We therefore want directions with uncorrelated projections. The pixels themselves are a poor choice. Neighbouring pixels of natural images are indeed highly correlated, and this correlation extends over long distances [4, 19]. The statistics of natural images are also approximately invariant to translation. For a small patch, the basis of the discrete cosine transform (DCT) then gives nearly uncorrelated projections [20, 21]. This basis is the same for every set of natural images, and MSW takes its directions from it.

A small patch misses the long-range correlation. Natural images have nearly the same statistics at every scale [19, 22]. We therefore apply the same filters to coarser versions of the image, as in a multiresolution decomposition [23]. At a coarse scale, a filter covers a large part of the image.

Multiscale sliced Wasserstein distance

Let x∈RC×H×Wx \in\mathbb{R}^{C \times H \times W} be an image with CC channels, and let xsx_s denote the image at scale s>0s > 0, obtained from xx by ss successive blur-and-decimate steps, with x0=xx_0 = x. A slice q=(s,h,c)q = (s,h,c) consists of a scale ss, a spatial filter h∈RK×Kh \in\mathbb{R}^{K \times K} and a channel vector c∈RCc \in\mathbb{R}^{C}. It defines the linear map

Φq(x)=h∗(c⊤xs),(4)\Phi_q(x) = h * \left(c^{\top}x_s\right), \tag*{(4)}

where c⊤c^{\top} combines the channels and ∗* is the two-dimensional convolution. The response map Φq(x)\Phi_q(x) is an image with nsn_s pixels, and Φq(x)[k]\Phi_q(x)[k] is its value at the pixel kk, which we call a position. Each value is a linear functional of xx, and we normalize hh so that this functional has unit norm. § 3.4 specifies the filters and the channel vectors.

For a distribution μ\mu over images, the slice distribution μq\mu_q collects the responses of slice qq at all positions. Formally, μq\mu_q is the average, over the nsn_s positions kk, of the distribution of Φq(x)[k]\Phi_q(x)[k] for x∼μx \sim\mu. A set of NN images thus provides NnsNn_s samples of it. Figure 1 shows the histograms of such samples. The MSW distance between two distributions μ\mu and ν\nu over images is

Figure 1. Histograms of the responses of one high-frequency filter under six perturbations (darker is stronger). The textures are synthetic (§ 4.2).

MSW⁡(μ,ν)=(∑qλqW22(μq,νq))1/2,(5)\operatorname{MSW}(\mu,\nu) = \left(\sum_q \lambda_q W_2^2(\mu_q,\nu_q)\right)^{1/2}, \tag*{(5)}

with weights λq∝4−s/σq\lambda_q \propto4^{-s}/\sigma_q normalized to sum to one. The factor 4−s4^{-s} is the fraction of positions contributed by scale ss, and σq\sigma_q is the standard deviation of the slice distribution of a fixed reference set of natural images, measured once. This normalization brings all slices to a comparable scale without making the weights depend on μ\mu or ν\nu. Figure 2 summarizes the construction. Each term of (5) belongs to one slice. The terms can be read one by one, and they show at which scale, in which frequency band and along which colour axis two sets of images differ.

Overview of MSW

Figure 2. Overview of MSW: for each slice, the responses of all images and positions form one histogram per set.

MSW is a sliced Wasserstein distance with fixed directions, applied to patches. The samples are the K×KK \times K patches of xsx_s at all positions, and the filters and the channel vectors give the directions. A patch has only CK2CK^2 dimensions, so that a complete basis of directions is affordable. This is not the case for whole images. When μ\mu is stationary, μq\mu_q is the distribution of the response at any position, and pooling over positions is most effective. Otherwise, without assuming stationarity, MSW still applies, and μq\mu_q is the average of the distributions at the nsn_s positions. This average describes the local statistics of μ\mu, but not where they occur. Such statistics remain informative on photographs, which are not stationary [24, 25]. The use of all positions makes MSW usable with few images. The number of samples per slice grows with the number of positions and with the number of images, whereas a latent-based metric obtains one vector per image and CSW one scalar per image and projection.

MSW is a pseudometric. It is symmetric, vanishes for μ=ν\mu= \nu and satisfies the triangle inequality, since each term of (5) is a Wasserstein distance between two distributions obtained from μ\mu and ν\nu by the same map. It is not a metric, because the bank has finitely many filters and two distributions with identical slice distributions are not distinguished. Since each slice map is a mixture of unit-norm linear functionals and the weights sum to one, MSW⁡(μ,ν)≤W2(μ,ν)\operatorname{MSW}(\mu,\nu) \le W_2(\mu,\nu) (Appendix § 8).

In practice, μ\mu and ν\nu are known only through two sets AA and BB of NN images each, and μq\mu_q and νq\nu_q are replaced by the empirical distributions of the responses. Computed between two finite samples, W22W_2^2 is biased upward. The same bias makes FID [26] and CSW depend on the number of images. Like CMMD, we use an estimator whose expectation is exactly zero when μ=ν\mu= \nu. The detection rule of § 4 is an exact test of the hypothesis μ=ν\mu= \nu. The distance (5) uses fixed weights, and this test uses data-dependent weights [27, 28] (Appendix § 8).

The filter bank

A slice combines a filter, a channel vector and a scale.

Spatial filters. The filters hh are the 24 non-constant atoms of the 5 × 5 DCT (Figure 3). Computed in a sliding window, the DCT is a bank of convolution filters [12], and its responses at a pixel are nearly uncorrelated (§ 3.2). The atoms also tile the frequency plane, so that each slice has a scale and a frequency band.

The 5×5 DCT atoms and the three channel axes

Figure 3. The 5×5 DCT atoms and the three channel axes.

Channel vectors. The vectors cc are the three opponent colour axes of Figure 3, luminance (1,1,1)/3(1, 1, 1)/\sqrt{3}, red–green (1,−1,0)/2(1, -1, 0)/\sqrt{2} and blue–yellow (1,1,−2)/6(1, 1, -2)/\sqrt{6}, which approximately decorrelate the colour channels of natural images [29]. The bank therefore comprises 72 slices per scale. With the three constant patches, their directions form an orthogonal basis of the 5 × 5 colour patches. Natural images carry little variance on the chromatic axes, where small perturbations stand out.

Scales. From one scale to the next, the image is smoothed with the binomial filter (1,4,6,4,1)/16(1, 4, 6, 4, 1)/16 [30] along each axis and downsampled by two. All scales larger than the filters are used, three at 32 pixels and six at 256.

Experiments

The experiments go from low-level changes of the images to semantic ones. Sections 4.2 and 4.3 study controlled perturbations, Sections 4.4 and 4.5 compare generators and networks, and Section 4.6 compares classes.

Protocol

All experiments share the same metrics and detection rule.

Metrics. We compare MSW with FID, CMMD and CSW. FID and CMMD use the publicly released Inception and CLIP networks (Appendix § 9).

Detection rule. Let DD be any of the four metrics. One run draws two independent sets AA and AεA_\varepsilon of NN images at random from the dataset, and perturbs the images of AεA_\varepsilon with amplitude ε\varepsilon. Since D(A,A0)D(A,A_0) varies between draws, the perturbation is considered detected when D(A,Aε)D(A,A_\varepsilon) exceeds tDt_D, the 95th percentile of D(A,A0)D(A,A_0). The power of DD is its probability of detection over independent runs, that is, the share of runs with a pp-value below 0.05,

power⁡D(ε,N)=P[D(A,Aε)>tD].(6)\operatorname{power}_D(\varepsilon,N)=\mathbb{P}\left[D(A,A_\varepsilon)>t_D\right]. \tag*{(6)}

For FID, CMMD and CSW, we estimate tDt_D from unperturbed runs and count the perturbed runs that exceed it (Appendix § 9). For MSW, the exact test of Appendix § 8 gives the pp-value directly, without unperturbed sets. This test weights the slices of (5) according to their variance.

Two quantities summarize each experiment. The detection threshold ε0.8\varepsilon_{0.8} is the smallest amplitude ε\varepsilon such that power⁡D(ε,500)≥0.8\operatorname{power}_D(\varepsilon,500) \ge0.8. The sample requirement N∗N^* is, at a fixed amplitude ε\varepsilon, the smallest NN such that power⁡D(ε,N′)≥0.8\operatorname{power}_D(\varepsilon,N') \ge0.8 for all N′≥NN' \ge N. The level 0.05 and the power 0.8 are conventional [31].

Cost. MSW is more than ten times faster to evaluate than FID or CMMD, and several times faster when its test is included. CSW is the fastest (Appendix § 9).

Controlled perturbations

We first inject a perturbation of amplitude ε\varepsilon into one of the two sets. Table 1 gives the detection threshold and the sample requirement of the four metrics for ten perturbations.

detection threshold ε0.8\varepsilon_{0.8} (N=500N=500)sample requirement N∗N^* at amplitude ε\varepsilon
FIDCMMDCSWMSWε\varepsilonFIDCMMDCSWMSW
CelebAGaussian noise0.010.0025–0.00050.0025–128–8
Gaussian blur0.330.22–0.100.33256128–8
COCOgrey checkerboard0.040.040.040.0050.045122562568
red–green checkerboard0.160.080.080.010.08–2565128
shading0.160.040.160.080.081024128–256
CIFAR-10Gaussian blur0.50.22–0.150.3351264–16
synthetic texturesspectral slope0.1280.064–0.0080.0641024512–8
white noise0.160.08–0.040.08–256–8
heavier tails1/121/121/121/481/12512512512128
heavy-tailed texturesspectral slope0.1280.128–0.0320.128128128–64

Table 1. Ten controlled perturbations, with detection as defined in (6), by the exact test for MSW (–: no detection).

Gaussian noise. Gaussian noise is the first disturbance on which FID was validated [2]. Score-based generators can also leave in their images a noise that the eye does not see [32]. We add Gaussian noise of standard deviation ε\varepsilon, for pixel values in [0,1][0, 1], to crops of CelebA face images [33] (Table 1, first row). MSW detects the weakest noise, about an eighth of a grey level, and it needs the fewest images at a fixed amplitude. This sensitivity comes mainly from the chromatic slices. The responses of unperturbed faces along the opponent axes are tightly concentrated, and even faint noise broadens them measurably (Figure 1).

Checkerboard. Checkerboard patterns are a common artefact of generated images. They are left by the upsampling layers of the generator, and they are often visible only at close range [34]. Such periodic traces are found across architectures and datasets, and a classifier can use them to recognize generated images [35]. We add +ε+\varepsilon or −ε-\varepsilon to every pixel in such a pattern, on COCO photographs of 512 pixels [36]. The pattern is either grey, with the same sign in the three colour channels, or red–green, with opposite signs in the red and green channels. MSW detects both patterns at a far smaller amplitude than the other metrics, and it needs the fewest images (Table 1). The pattern shifts the output of the highest-frequency filter up at one position and down at the next, so that its histogram splits in two (Figure 1, right).

The networks of FID and CMMD resize their inputs. On ImageNet images of 256 pixels [37], this removes more than half of the amplitude of the red–green pattern. In Figure 4, MSW detects this pattern in every run from 128 images, and CMMD and CSW only with the largest sets. On the same images, CMMD detects a blur from smaller sets, so the failure is specific to the pattern (Appendix § 9). FID does not detect the pattern at any set size, because its latent space is nearly invariant to it (§ 1).

Figure 4. A red–green checkerboard on ImageNet, ε=0.02\varepsilon= 0.02.

Blur, shading and textures. The other rows of Table 1 are seven further perturbations (Appendix § 11). On CelebA and CIFAR-10 [38] images, we apply a Gaussian blur of standard deviation ε\varepsilon pixels, the second disturbance of [2]. On the COCO photographs, we add a smooth random shading of standard deviation ε\varepsilon. The synthetic textures are Gaussian random fields with a power-law spectrum, whose distribution is known exactly. We change their spectral slope by ε\varepsilon, add white noise of standard deviation ε\varepsilon, or give them heavier tails with the same spectrum (a Student-tt distribution with 1/ε1/\varepsilon degrees of freedom). The last row changes the slope of textures that already have heavy tails.

MSW has the smallest detection threshold and the smallest sample requirement in every row except shading. Shading alters only the lowest frequencies, and CMMD detects it at half the amplitude. The other perturbations are of different kinds. Blur removes the highest frequencies, and heavier tails do not change the power spectrum of the textures. § 4.7 examines the ingredients of MSW one by one.

Comparison with a true distance

Here, the true distance between the two sets is known. Let TT be a map that changes an image, and T#μT_{\#}\mu the distribution of the changed images. By Brenier’s theorem [39], if TT is the gradient of a convex function, then it is an optimal transport map [14 Thm. 1.48]. The coupling of each image xx with T(x)T(x) then attains the minimum in (1) for p=2p = 2, and the distance is the root mean square of the change,

W22(μ,T#μ)=∫∥x−T(x)∥2 dμ(x),(7)W_2^2(\mu,T_{\#}\mu)=\int\lVert x-T(x)\rVert^2\,\mathrm{d}\mu(x), \tag*{(7)}

which we compute from the images. This holds for every denoiser of the form T(x)=arg min⁡y12∥x−y∥2+f(y)T(x)=\mathop{\operatorname{arg\,min}}\limits_y \frac{1}{2}\lVert x-y\rVert^2+f(y) with ff convex [40]. The denoiser removes the detail x−T(x)x-T(x) from the image. The map x↦x+(x−T(x))x\mapsto x+(x-T(x)) adds the same detail instead, and it is also the gradient of a convex function (Appendix § 9). Both maps move each image by the same amount, and thus give the same distance ((7)).

Figure 5 shows each metric against this distance, for the total-variation denoiser [41] (left) and for a blur of the colours (right). Each metric is divided by its value at the left end. The grey line is the true distance, and a metric proportional to it stays on this line. MSW follows it on both sides. FID and CMMD grow with it when detail is removed, but not when it is added. CSW also grows on both sides, but in the right panel it reaches twice the true distance.

Photographs with detail removed, original, detail doubled, colours blurred, original, and colours sharpened, with relative-distance plots

Figure 5. Removing or adding detail (left) and colour detail (right) in photographs.

Generated images

The next experiment follows the benchmark of the CMMD paper [3]. Stable Diffusion 1.4 generates one image for each caption of COCO-30k, and the images after the last six of its sampling iterations form six sets of increasing quality, which are compared with the COCO images of the same captions (Appendix § 9). On the full sets, CMMD and MSW decrease at every iteration, whereas FID first decreases and then increases, the failure reported in [3]. The question here is how many images each metric needs to recover the order.

We draw NN captions at random, keep only their images in the six sets and in COCO, and score the six sets. We repeat this draw and count how often a metric orders all six sets correctly (Figure 6). MSW recovers the order most reliably, in about nine draws out of ten from the smallest size and in every draw from 64 images. CMMD and CSW catch up only at the larger sizes. FID recovers the order in fewer than half of the draws at every size and in none at the largest, where it reproduces its wrong order. The value of MSW is also stable in NN. On a thirtieth of the images, FID reads several times its value on the full sets, whereas CMMD and MSW stay within a few percent of theirs (Appendix § 9).

Percentage of random draws of N images per set in which metrics order the six Stable Diffusion sets correctly

Figure 6. Percentage of random draws of NN images per set in which a metric orders the six Stable Diffusion sets correctly.

Super-resolution

In this experiment, the order that a metric should recover is known from the literature rather than chosen by us. A super-resolution network trained to minimize the pixel error (PSNR-trained) produces faithful but blurry images. When the same network is trained further with an adversarial loss (GAN-trained), its outputs are less faithful pixel by pixel, but they are sharp and their distribution is closer to that of real images. This is the perception–distortion trade-off [42]. ESRGAN [43] interpolates linearly between the weights of the two networks, with a weight α\alpha on the GAN-trained one. The outputs go from blurry at α=0\alpha= 0 to sharp at α=1\alpha= 1, and they are over-sharpened beyond (Figure 7, top). The distance between the outputs and the originals should therefore decrease up to about α=1\alpha= 1 and increase beyond.

Super-resolution interpolation paths for same scenes and different scenes

Figure 7. Super-resolution along the ESRGAN interpolation path.

We enlarge the DIV2K validation images [44] by a factor of four (Appendix § 9). In Figure 7(a), the outputs are compared with the originals of the same scenes, and each metric is divided by its value at α=0\alpha= 0. All four metrics are smallest near the GAN-trained network. MSW follows CMMD closely, without a pretrained network, whereas FID and CSW have a shallow minimum.

In practice, two sets rarely show the same scenes. In Figure 7(b), the outputs and the originals come from disjoint sets of 48 images, and each curve is the mean over 200 random draws. MSW keeps a clear minimum at the GAN-trained network. FID and CSW are now flat. CMMD decreases less than MSW, although it ranks the two networks correctly in more draws (Appendix B). Four other pairs of networks lead to the same conclusions, with the minimum of MSW slightly beyond α=1\alpha= 1 for two of them.

Semantic changes

MSW contains no learned component, whereas the networks of FID and CMMD are trained to classify images or to match them with text. A change of semantic content is thus the hardest case for MSW, and we expect FID and CMMD to be ahead. We compare the metrics on pairs of COCO classes. A photograph belongs to the class of its largest annotated object, and the 14 classes with the most photographs form 91 pairs. For each pair, the two sets contain NN images of one class and NN images of the other, and the null distribution of each baseline is measured on two disjoint sets of the first class. The detection rule is that of § 4.1. Figure 8 shows the share of pairs separated with power 0.8, and Table S2 lists them (Appendix B).

Figure 8. Percentage of the pairs of COCO classes that a metric separates from NN images per set.

pairFIDCMMDCSWMSWpairFIDCMMDCSWMSWpairFIDCMMDCSWMSW
airplane–bed1681632boat–motorcycle883232clock–truck16812832
airplane–boat886432boat–person6483232dining table–giraffe3286416
airplane–bus883216boat–toilet883216dining table–horse883232
airplane–car1683216boat–train88128128dining table–motorcycle3283232
airplane–clock883216boat–truck16812864dining table–person32812864
airplane–dining table328816bus–car88256128dining table–toilet883216
airplane–giraffe881616bus–clock8812832dining table–train3283232
airplane–horse883216bus–dining table3281632dining table–truck3281632
airplane–motorcycle881616bus–giraffe886416giraffe–horse168256128
airplane–person3281632bus–horse8825632giraffe–motorcycle8812832
airplane–toilet881616bus–motorcycle886432giraffe–person32812832
airplane–train886416bus–person3283232giraffe–toilet886416
airplane–truck1683216bus–toilet883216giraffe–train886416
bed–boat1683232bus–train88–128giraffe–truck16812816
bed–bus883216bus–truck88–256horse–motorcycle8825664
bed–car886432car–clock16812864horse–person64812864
bed–clock1683232car–dining table883232horse–toilet883216
bed–dining table32812832car–giraffe16812832horse–train8825664
bed–giraffe16812816car–horse168256128horse–truck168–64
bed–horse1686416car–motorcycle32812864motorcycle–person64812832
bed–motorcycle1683216car–person32812864motorcycle–toilet88328
bed–person328–128car–toilet886416motorcycle–train886464
bed–toilet16812832car–train88256128motorcycle–truck32812864
bed–train886416car–truck6432––person–toilet1686432
bed–truck1683216clock–dining table3283232person–train6483232
boat–bus8812864clock–giraffe8812832person–truck6486464
boat–car16812864clock–horse8812864toilet–train88648
boat–clock8812832clock–motorcycle8812832toilet–truck883216
boat–dining table3281616clock–person328128128train–truck88–256
boat–giraffe883232clock–toilet883216
boat–horse8812832clock–train886432

Table S2. Sample requirement N∗N^* of every pair of COCO classes (–: no detection).

MSW separates most pairs from a few dozen images per set, and all but one from the largest sets. As expected, FID and CMMD need several times fewer images. CSW needs more than MSW. The pair that MSW does not separate is car against truck, and the other hard pairs are mostly two vehicles, such as bus against truck. Image categories differ in their low-level statistics, since the power spectra of natural images depend on the scene category [24] and a classifier restricted to small patches reaches a high accuracy on ImageNet [25]. Accumulated over all positions of the images, these differences separate nearly every pair of classes.

Ablation

In Figure 9, we replace the DCT atoms, the opponent colour axes and the scales of MSW one at a time. With random filters, Gaussian noise on CelebA images is not detected at ten times the threshold of MSW. With learned filters, the thresholds do not change (Appendix A). With the R, G, B axes, the threshold of this noise is ten times larger. With one scale, the threshold of a change in the lowest frequencies of a synthetic texture is four times larger (Appendix C).

MSW with one ingredient replaced

Figure 9. MSW (black) with one ingredient replaced (grey).

Limitations

MSW has the following limitations.

Global colour offsets. All filters have zero mean, so that MSW is invariant to a constant offset of the channels, at any amplitude. CMMD detects such an offset (Appendix A).

Dependence between filters. MSW compares the responses of each filter separately. It does not compare how the responses of different filters vary together, although they are not independent [4].

Semantic changes. Latent-based metrics separate pairs of COCO classes with several times fewer images than MSW (§ 4.6).

Memorization and definiteness. Like FID, MSW ignores the identity of individual images and therefore does not detect a generator that reproduces its training set. The bank also spans finitely many frequency bands, and two distributions that agree on all of them are indistinguishable.

Conclusion

In most of our experiments, MSW outperforms FID, CMMD and CSW. It detects smaller perturbations from fewer images, and it follows a true distance more closely. Latent-based metrics still need fewer images for the changes that their networks are trained to recognize, such as a change of object class. MSW has no trained component. Its design rests on well-studied properties of natural images: their stationarity, their decorrelation by fixed filters and their similar statistics at every scale. Our results show that these properties are enough to build a simple and interpretable metric that competes with large pretrained networks.

LLM Usage Statement

We used an LLM assistant (Claude, Anthropic), mainly to refine author-produced content: the code and parts of the text. The authors verified all content and take full responsibility for it.

Computational details

We will define hereafter the practical way of computing MSW with finite samples and the exact test that we use for the detection of perturbations. In the continuum, recall (5) that

MSW⁡2(μ,ν)=∑qλqW22(μq,νq),\operatorname{MSW}^{2}(\mu,\nu)=\sum_q \lambda_q W_2^2(\mu_q,\nu_q),

where μq\mu_q and νq\nu_q are the slice distributions of μ\mu and ν\nu.

Bias due to finite-sample sets. For a set of images AA and a slice qq, let AqA_q denote the empirical distribution of the nn responses of the slice at all positions of all images of AA. It replaces μq\mu_q. Let rq(A)∈Rnr_q(A)\in\mathbb{R}^n be these responses in increasing order. For two sets AA and BB of the same size, we have

W22(Aq,Bq)=1n∥rq(A)−rq(B)∥2.W_2^2(A_q,B_q)=\frac{1}{n}\lVert r_q(A)-r_q(B)\rVert^2.

For two sets drawn from the same distribution, W22(Aq,Bq)W_2^2(A_q,B_q) is strictly positive with probability one (the sets of images are independent), and its expectation decreases only slowly with the number of images. FID has the same property, with a bias of order 1/N1/N for sets of NN images [26]. We need to correct for this upward bias.

Bias correction. Under the null hypothesis (when the two sets of images come from the same distribution), we want our estimator of MSW⁡2(μ,ν)\operatorname{MSW}^2(\mu,\nu) to be zero on average. We split each set by image into two blocks, A(1),A(2)A^{(1)},A^{(2)} and B(1),B(2)B^{(1)},B^{(2)} (Figure S1), and we define, for the slice qq, the U-statistic

Blocks of the estimate $U_q$ and of the exact test

Figure S1. Blocks of the estimate UqU_q (a) and of the exact test (b).

Uq=12[W22(Aq(1),Bq(2))+W22(Aq(2),Bq(1))]⏟between A and B−12[W22(Aq(1),Aq(2))+W22(Bq(1),Bq(2))]⏟bias correction.(8)U_q=\frac{1}{2}\underbrace{\left[W_2^2(A_q^{(1)},B_q^{(2)})+W_2^2(A_q^{(2)},B_q^{(1)})\right]}_{\text{between }A\text{ and }B} -\frac{1}{2}\underbrace{\left[W_2^2(A_q^{(1)},A_q^{(2)})+W_2^2(B_q^{(1)},B_q^{(2)})\right]}_{\text{bias correction}}. \tag*{(8)}

With dq(i)=rq(B(i))−rq(A(i))d_q^{(i)}=r_q(B^{(i)})-r_q(A^{(i)}), we obtain

Uq=⟨dq(1),dq(2)⟩n.(9)U_q=\frac{\langle d_q^{(1)},d_q^{(2)}\rangle}{n}. \tag*{(9)}

Proposition S1. If all images of AA and BB are drawn independently from the same distribution μ\mu, then E[Uq]=0\mathbb{E}[U_q]=0 for every slice qq and every NN.

Proof. The four blocks are identically distributed, so that E[dq(1)]=E[dq(2)]=0\mathbb{E}[d_q^{(1)}]=\mathbb{E}[d_q^{(2)}]=0. The two factors of (S2) involve disjoint blocks and are therefore independent, which implies that E[Uq]=⟨E[dq(1)],E[dq(2)]⟩/n=0\mathbb{E}[U_q]=\langle\mathbb{E}[d_q^{(1)}],\mathbb{E}[d_q^{(2)}]\rangle/n=0.

In order to improve the accuracy of UqU_q, each set is cut into L=16L=16 blocks2 of ⌊N/L⌋\lfloor N/L\rfloor images, denoted by A(i)A^{(i)} and B(i)B^{(i)} for i=1,…,Li=1,\ldots,L. We then take for UqU_q the average of ⟨dq(i),dq(j)⟩/n\langle d_q^{(i)},d_q^{(j)}\rangle/n over all pairs i≠ji\ne j, which also has zero expectation when μ=ν\mu=\nu. In practice, we estimate MSW⁡2(μ,ν)\operatorname{MSW}^2(\mu,\nu) with finite samples through the weighted sum

MSW⁡2(A,B)=∑qλqUq.\operatorname{MSW}^2(A,B)=\sum_q\lambda_qU_q.

Figure S2 shows the mean of a metric between two sets drawn from the same distribution, in units of its standard deviation over 1000 runs. A run splits 2N2N images taken at random from a pool of 65,536 synthetic textures or CelebA crops of 32 pixels, and the four metrics share the draws. MSW and CMMD stay within 0.1 standard deviation of zero for all NN between 8 and 8192. CSW lies 4 to 9 standard deviations above zero, and FID 9 to 115.

Bias between two sets of the same distribution

Figure S2. Bias between two sets of the same distribution.

Comparison with W2W_2. Write μq=1ns∑k(ϕq,k)#μ\mu_q=\frac{1}{n_s}\sum_k(\phi_{q,k})_\#\mu, where ϕq,k(x)=Φq(x)[k]\phi_{q,k}(x)=\Phi_q(x)[k] is defined in (4). The map ϕq,k\phi_{q,k} is a linear functional of unit norm, and hence 1-Lipschitz.

In addition, W22W_2^2 is jointly convex under mixtures with common weights. We therefore have that

W22(μq,νq)≤convexity1ns∑kW22((ϕq,k)♯μ,(ϕq,k)♯ν)≤1-LipschitzW22(μ,ν).(10)W_2^2(\mu_q,\nu_q) \mathrel{\leq}^{\text{convexity}} \frac{1}{n_s}\sum_k W_2^2\left((\phi_{q,k})_\sharp\mu,(\phi_{q,k})_\sharp\nu\right) \mathrel{\leq}^{\text{1-Lipschitz}} W_2^2(\mu,\nu). \tag*{(10)}

As the weights λq\lambda_q are nonnegative and sum to one,

MSW⁡2(μ,ν)≤max⁡qW22(μq,νq)≤W22(μ,ν).(11)\operatorname{MSW}^2(\mu,\nu) \leq\max_q W_2^2(\mu_q,\nu_q) \leq W_2^2(\mu,\nu). \tag*{(11)}

The test for detection. In order to detect whether AA and BB come from the same distribution, we perform the classical sign-flip test [45]. A choice of swaps is a vector ξ=(ξ1,…,ξL)\boldsymbol{\xi}=(\xi_1,\ldots,\xi_L), where ξi=−1\xi_i=-1 if the blocks A(i)A^{(i)} and B(i)B^{(i)} are exchanged and ξi=1\xi_i=1 otherwise. For each choice ξ\boldsymbol{\xi}, we compute a statistic TξT^{\boldsymbol{\xi}} from the blocks after the swaps. We write TT for its value without any swap. If the two sets come from the same distribution, then the swaps do not change the distribution of the data, and TT behaves like any of the TξT^{\boldsymbol{\xi}}. The pp-value is therefore the fraction of the choices ξ\boldsymbol{\xi} for which TξT^{\boldsymbol{\xi}} is larger than TT. We use 4096 choices when L=16L=16.3 A swap only changes the sign of dq(i)d_q^{(i)} (Figure S1), which multiplies ⟨dq(i),dq(j)⟩\langle d_q^{(i)},d_q^{(j)}\rangle by ξiξj\xi_i\xi_j. The swaps therefore need no new convolutions or sorts.

The statistic is the largest of six values T1ξ,…,T6ξT_1^{\boldsymbol{\xi}},\ldots,T_6^{\boldsymbol{\xi}},

Tξ=max⁡mTmξ/ρm,(12)T^{\boldsymbol{\xi}}=\max_m T_m^{\boldsymbol{\xi}}/\rho_m, \tag*{(12)}

where ρm2\rho_m^2 is the mean of (Tmξ)2(T_m^{\boldsymbol{\xi}})^2 over all the choices ξ\boldsymbol{\xi}. It brings the six values to the same scale. Taking the maximum of several statistics over the same swaps is classical [46] and used by recent kernel tests [28, 47].

Each TmξT_m^{\boldsymbol{\xi}} is built like MSW⁡2(A,B)\operatorname{MSW}^2(A,B), from the estimates UqξU_q^{\boldsymbol{\xi}} computed after the swaps ξ\boldsymbol{\xi}. It is the weighting that changes. The fixed weights λq\lambda_q of (5) make MSW⁡2(A,B)\operatorname{MSW}^2(A,B) comparable from one experiment to the next. For detection, a slice with a precise estimate should count more. This is the classical inverse-variance weighting [27]. We use it with two variances,

Tblocksξ=∑qUqξ/vqξ∑q1/vqξ,Tswapsξ=∑qUqξ/vq′∑q1/vq′.(13)T_{\mathrm{blocks}}^{\boldsymbol{\xi}}=\frac{\sum_q U_q^{\boldsymbol{\xi}}/v_q^{\boldsymbol{\xi}}}{\sum_q 1/v_q^{\boldsymbol{\xi}}},\qquad T_{\mathrm{swaps}}^{\boldsymbol{\xi}}=\frac{\sum_q U_q^{\boldsymbol{\xi}}/v'_q}{\sum_q 1/v'_q}. \tag*{(13)}

The variance vqξv_q^{\boldsymbol{\xi}} comes from the LL blocks after the swaps ξ\boldsymbol{\xi}. It changes with ξ\boldsymbol{\xi}. The variance vq′v'_q is the mean of (Uqξ)2(U_q^{\boldsymbol{\xi}})^2 over all the choices ξ\boldsymbol{\xi} [28]. It is the same for every ξ\boldsymbol{\xi}. A third value keeps a single scale,

Tscaleξ=max⁡sU‾sξ/σsξ,(14)T_{\mathrm{scale}}^{\boldsymbol{\xi}}=\max_s \overline{U}_s^{\boldsymbol{\xi}}/\sigma_s^{\boldsymbol{\xi}}, \tag*{(14)}

where U‾sξ\overline{U}_s^{\boldsymbol{\xi}} is the mean of UqξU_q^{\boldsymbol{\xi}} over the slices of the scale ss and σsξ\sigma_s^{\boldsymbol{\xi}} is its standard error over the blocks. A difference at one scale is then not averaged out by the other scales. We compute these three values with the red, green and blue channels, and again with the opponent axes of § 3.4 (without the luminance axis for the first two), which gives the six values. Single-channel images give three values. We check the test on two sets drawn from one distribution, where it should reject in 5% of the draws. On 1000 draws for each of five image families and for N=16N=16 and N=500N=500, it rejects in 4.6% to 6.0% of them, and in 533 of 10000 overall.

Other filters. In Table S1, we replace the DCT atoms by random filters, or by filters learned from image patches by principal component analysis (PCA), and keep everything else. The random filters have Gaussian entries and unit norm, and the PCA filters are fitted to patches of CIFAR-10 images. The random filters are behind in every row except shading. The PCA filters reach the same thresholds as the DCT atoms, which need no computation.

DCTrandomPCA
CelebAGaussian noise0.0005–0.0005
CelebAGaussian blur0.100.330.10
CelebAshading0.080.080.08
CIFAR-10checkerboard0.01–0.01
synthetic texturesspectral slope0.0080.0160.008

Table S1. Threshold ϵ0.8\epsilon_{0.8} with other filters (–: no detection).

Global colour offsets. A constant chromatic offset ϵ(1,−1,0)/2\epsilon(1,-1,0)/\sqrt{2} on CelebA crops is invisible to every filter of the bank, since the atoms have zero mean. The test does not detect it at any amplitude of the grid. CMMD detects the offset from 0.02, and FID from 0.08.

Protocol details

This appendix gives the set-up of the experiments of § 4.

Baselines. FID uses the Inception-v3 network with the weights and the preprocessing of the pytorch-fid package [2]. CMMD uses the CLIP ViT-L/14 network [48] on images resized to 224 pixels, a Gaussian kernel of bandwidth 10 [3] and the unbiased estimate of the MMD. In § 4.4, we follow its released code, with the 336-pixel network and the biased estimate. CSW uses the convolution slicers and the estimate of its released code [5]. Single-channel images are rescaled so that their mean, plus or minus four standard deviations, covers [0,1][0,1]. They are then clipped to [0,1][0,1] and replicated to three channels.

Cost. The table below gives the time of one evaluation on a pair of sets of NN images, at 32 pixels and three channels, on a shared V100 GPU. Each entry is the median of 25 to 30 calls.

NNFIDCMMDCSWMSWMSW with pp-value
2001.63 s4.23 s0.018 s0.078 s0.498 s
5004.13 s10.6 s0.026 s0.203 s0.816 s
10008.36 s21.2 s0.037 s0.404 s1.329 s

Table 2.

Checkerboard on ImageNet. The images are ImageNet images of 256 pixels. The networks of FID and CMMD resize them, which leaves 34 % to 48 % of the amplitude of the checkerboard. As a control, we blur these images instead. CMMD then detects the change from sets of 500 images, so its difficulty is specific to the checkerboard. In Figure 4, the power of a baseline is computed with a Gaussian approximation of its values.

Power of the baselines. The power of a baseline DD is estimated in two steps. First, we compute D(A,A0)D(A,A_0) on 100 unperturbed runs, and tDt_D is the 95th percentile of these values. Second, we compute D(A,Aε)D(A,A_\varepsilon) on 12 perturbed runs, and the power is the share of these values that exceed tDt_D. The amplitudes ε\varepsilon follow a geometric grid.

For the sample requirement, we repeat the two steps at each set size NN, with at least 50 unperturbed and 10 perturbed runs. The sizes are the powers of two from 16 to at least 1024.

MSW skips the first step, since its test needs no unperturbed runs. Its power is the share of at least 24 perturbed runs that the test rejects, and its sizes start at 8.

Comparison with the true distance. We use 4096 ImageNet validation images [37], reduced to 64 pixels. In each run, we draw two sets of 800 images and we change the images of the second set. The curves of Figure 5 are averages over 16 runs. We now prove the claim of § 4.3 that removing the detail and adding it give the same distance.

Proposition S2. Let f:Rd→Rf:\mathbb{R}^d \to\mathbb{R} be convex, let

T(x)=arg min⁡y 12∥x−y∥2+f(y),(15)T(x)=\underset{y}{\operatorname{arg\,min}}\ \frac{1}{2}\lVert x-y\rVert^2+f(y), \tag*{(15)}

and let R(x)=2x−T(x)R(x)=2x-T(x). For every distribution μ\mu on Rd\mathbb{R}^d with a finite second moment, W22(μ,T#μ)W_2^2(\mu,T_\#\mu) and W22(μ,R#μ)W_2^2(\mu,R_\#\mu) are both equal to the right-hand side of (7).

Proof. Let g(x)=min⁡y12∥x−y∥2+f(y)g(x)=\min_y \frac{1}{2}\lVert x-y\rVert^2+f(y). This function is convex, as the minimum over yy of a function that is convex in (x,y)(x,y). Its gradient is x−T(x)x-T(x) [40]. The function

12∥x∥2−g(x)=max⁡yxTy−12∥y∥2−f(y)(16)\frac{1}{2}\lVert x\rVert^2-g(x)=\max_y x^{\mathsf T}y-\frac{1}{2}\lVert y\rVert^2-f(y) \tag*{(16)}

is also convex, as a maximum of affine functions of xx. Thus, TT and RR are the gradients of the convex functions 12∥x∥2−g(x)\frac{1}{2}\lVert x\rVert^2-g(x) and 12∥x∥2+g(x)\frac{1}{2}\lVert x\rVert^2+g(x), and both are optimal transport maps [14 Thm. 1.48]. The cost of TT is the integral of ∥x−T(x)∥2\lVert x-T(x)\rVert^2. The cost of RR is the same, since R(x)−x=x−T(x)R(x)-x=x-T(x). □

In the left panel of Figure 5, ff is a multiple of the total variation [41], with eight weights from 0.005 to 0.12. We compute TT with 1000 iterations of an accelerated projected-gradient algorithm on the dual problem. In the right panel, TT is a periodic Gaussian blur of the two colour axes of § 3.4, with seven standard deviations from 0.75 to 6 pixels. It is a symmetric matrix BB with eigenvalues in (0,1](0,1], and it has the form (S8) with f(y)=12yT(B−1−I)yf(y)=\frac{1}{2}y^{\mathsf T}(B^{-1}-I)y. The horizontal axis is the root mean square of x−T(x)x-T(x) over the pixels of the changed images, for images in [0,1][0,1]. FID, CMMD and CSW are shown as in Figure 7, after the values of FID and CSW between two sets of unchanged images are subtracted. The images with doubled detail leave the range [0,1][0,1]. The networks of FID and CMMD need images in [0,1][0,1], so these images are first rescaled as described above for single-channel images. MSW and CSW receive them as they are.

Generated images. The reference set is the 30,000 images of COCO-30k (val 2014), centre-cropped and resized to 512 pixels as in the CMMD paper, and the generated sets are the Stable Diffusion 1.4 images for the same captions after DDIM iterations 95 to 100 of 100, decoded from the stored latents. FID uses the clean-fid preprocessing [49], CMMD the official configuration (CLIP ViT-L/14 at 336 pixels), and MSW the distance of (5) at 512 pixels. CSW also uses 512 pixels. On the full sets, the metrics read as follows.

iteration9596979899100
FID15.814.113.012.513.213.4
CMMD0.6690.6110.5690.5430.5160.512
MSW0.05370.05210.05070.04960.04850.0484

Table 3.

In Figure 6, each draw takes NN of the first 4096 captions without replacement, and the six sets are ordered correctly when the metric decreases strictly from iteration 95 to 100. There are 100 draws per size up to N=128N=128, 50 at 256 and 30 at 512. On five random subsets of the 30,000 captions per size, FID reads 494 %, 300 % and 177 % of its full-set value at 1000, 2000 and 5000 images, CMMD 100 %, 98 % and 100 %, and MSW 98 %, 99 % and 100 %.

Super-resolution

Super-resolution. We use 99 images of the DIV2K validation set [44], with the low-resolution images that come with it (bicubic, factor four). From each image, we take the four central crops of 512 pixels, in the original and in the output. A full set therefore has 396 images. The weight α\alpha goes from 0 to 1.4 in steps of 0.1, and in steps of 0.05 between 0.8 and 1.2. MSW uses six scales, and the four crops of a scene stay in the same block. CSW uses 2048 slices.

In Figure 7(b), a draw takes two disjoint sets of 12 scenes, which gives 48 images per set. The originals of the first set are compared with the outputs of the second. All metrics use the same 200 draws.

Figure 7 uses the two networks released with ESRGAN [43]. We repeat the experiment with four other pairs of a PSNR-trained and a GAN-trained network. They are the ESRGAN and SRGAN [50] pairs of the MMEditing project [51], Real-ESRGAN [52] and BSRGAN [53]. The last two are trained for unknown blur, noise and compression. The table below gives the median of three quantities over the five pairs.

(a) same scenes(b) different scenes
minimumminimumdraws
FID0.740.9990 %
CMMD−0.090.77100 %
CSW0.811.0051.5 %
MSW0.120.2099 %

Table 7.

The minimum is the lowest value of the curve, and closer to zero is better. A value of 1 means that the curve has no minimum. The estimate of CMMD is unbiased, so it can be slightly negative. The last column is the share of draws in which the metric is smaller at α=1\alpha= 1 than at α=0\alpha= 0, and larger is better. In panel (a), the minimum of MSW lies beyond α=1.05\alpha= 1.05 only with Real-ESRGAN and BSRGAN.

Class pairs. We use the COCO-30k photographs, centre-cropped and resized to 512 pixels. A photograph belongs to the class of its largest annotated object. We keep the 14 classes with at least 512 photographs: person, dining table, train, bus, bed, car, toilet, truck, clock, horse, motorcycle, giraffe, airplane and boat. Each class is limited to 1024 photographs, taken at random.

For a pair of classes, a run draws NN images of each class. An unperturbed run draws two disjoint sets of NN images of the same class. At each size NN, there are 30 runs per pair and 30 unperturbed runs per class. The power of a baseline follows the two steps above, with the unperturbed runs of the first class of the pair. The sizes stop at 256, since the smallest class has 512 photographs.

On the unperturbed runs, the test of MSW rejects 5 % of the time on average, and at most 17 % for one class and size. The median sample requirement over the pairs is 32 images for MSW, 64 for CSW, and 8 for FID and CMMD.

Details for the controlled perturbations

Figure S3 shows seven of the ten settings of Table 1, and two more: a grey checkerboard on CIFAR-10 images and the shading on CelebA images.

Figure S3. Nine settings, clean and perturbed.

Natural images. The CelebA images are crops of 32 pixels. The COCO images are 4096 photographs of COCO30k, centre-cropped and resized to 512 pixels. The blur is Gaussian, with a standard deviation of ε\varepsilon pixels. The checkerboard has a period of two pixels, and the red–green pattern is the checkerboard times ε(1,−1,0)/2\varepsilon(1,-1,0)/\sqrt{2}. The shading is a random smooth image with one to three cycles per image and standard deviation ε\varepsilon, added equally to the three channels.

For the two settings outside Table 1, FID and CMMD detect the grey checkerboard on CIFAR-10 images from 0.01, and the shading on CelebA images of 64 pixels from 0.04. Table S3 gives the thresholds of CSW and MSW.

detection threshold ε0.8\varepsilon_{0.8} (N=500N=500)sample requirement N∗N^* at amplitude ε\varepsilon
SWCSWMSWε\varepsilonSWCSWMSW
CelebAGaussian noise––0.00050.0025––8
Gaussian blur0.75–0.100.33––8
shading0.080.160.080.085121024256
CIFAR-10checkerboard0.020.020.010.011024–256
Gaussian blur––0.150.33––16
synthetic texturesspectral slope––0.0080.064––8
white noise––0.040.08––8
heavier tails1/121/121/481/12512512128
heavy-tailed texturesspectral slope––0.0320.128––64

Table S3. Sliced Wasserstein distance (SW) on the nine controlled perturbations (–: no detection).

Synthetic textures. The textures are Gaussian random fields of 32 pixels, with unit variance and power spectrum ∥ω∥−3\lVert\omega\rVert^{-3} at the spatial frequency ω\omega. The change of spectral slope multiplies the spectrum by ∥ω∥−ε\lVert\omega\rVert^{-\varepsilon} and keeps the variance. The white noise has standard deviation ε\varepsilon. For the heavier tails, every image is multiplied by a random scale, which gives a Student-tt distribution with 1/ε1/\varepsilon degrees of freedom.

Heavy-tailed textures. The textures of the last row of Table 1 follow a Student-tt distribution with three degrees of freedom. Every image is brought to zero mean and unit variance before the metrics are applied. Without this step, the thresholds of FID and CMMD are the same, and CSW and MSW do not detect the change.

without the testwith the test
SetPerturbationFIDCMMDCSWFIDCMMDCSWMSW
CelebAGaussian noise0.010.0025–0.0050.00250.040.0005
Gaussian blur0.330.22–0.330.220.50.10
COCOgrey checkerboard0.040.040.040.020.040.040.005
red–green checkerboard0.160.080.080.080.080.040.01
shading0.160.040.160.080.040.160.08
CIFAR-10Gaussian blur0.50.22–0.330.220.330.15
synthetic texturesspectral slope0.0640.064–0.1280.0640.1280.008
white noise0.160.08–0.160.080.160.04
heavier tails1/61/121/121/61/121/121/48
heavy-tailed texturesspectral slope0.0640.064–0.1280.0640.1280.032

Table S4. Threshold ε0.8\varepsilon_{0.8} at N=500N = 500 when the features of the baselines go through the test of MSW (–: no detection).

Sliced Wasserstein distance. Table S3 adds the sliced Wasserstein distance of (3) (SW), with 8192 random zero-mean directions on the vectorized images and the same estimate as CSW. SW detects four of the nine perturbations and CSW three. Neither is ahead of MSW in any row.

Ablation. Figure 9 uses sets of 500 images. In the left and middle panels, the perturbation is the Gaussian noise on CelebA of Table 1, and the random filters are those of Table S1. In the right panel, the images are Gaussian textures of 128 pixels with power spectrum ∥ω∥−1/2\lVert\omega\rVert^{-1/2}. The perturbation multiplies their amplitude by 1+ε1 + \varepsilon between one and three cycles per image, at fixed variance.

Baselines with the test of MSW

Table S4 shows whether the baselines improve when their features go through the test of MSW.

Set-up. We give the test of Appendix § 8 the features of a baseline in place of the slices of MSW: the 2048 Inception coordinates of FID, the 768 CLIP coordinates of CMMD, or the 2048 projections of CSW. The settings are those of Table 1, with 48 perturbed runs per amplitude (24 on COCO). On 100 unperturbed runs, the test rejects between 1 % and 8 % of the time. Without the test, FID and CMMD use the threshold of Appendix § 9 on the same runs. Four of their values on the synthetic textures then differ from Table 1 by one step of the grid.

Results. The thresholds of CMMD do not change. The threshold of FID moves by one step of the grid, down in five rows and up in two. CSW now detects every perturbation. MSW keeps the smallest threshold in nine rows of ten. On the shading, CMMD is ahead with and without the test.

References

  1. [1]Gabriel Peyré and Marco Cuturi. Computational optimal transport. Foundations and Trends in Machine Learning, 11 (5-6):355–607, 2019. 1
  2. [2]Martin Heusel, Hubert Ramsauer, Thomas Unterthiner, Bernhard Nessler, and Sepp Hochreiter. GANs trained by a two time-scale update rule converge to a local Nash equilibrium. In NeurIPS, 2017. 1, 5, 11
  3. [3]Sadeep Jayasumana, Srikanth Ramalingam, Andreas Veit, Daniel Glasner, Ayan Chakrabarti, and Sanjiv Kumar. Rethinking FID: Towards a better evaluation metric for image generation. In CVPR, 2024. 1, 6, 11
  4. [4]Eero P. Simoncelli and Bruno A. Olshausen. Natural image statistics and neural representation. Annual Review of Neuroscience, 24:1193–1216, 2001. 1, 2, 7
  5. [5]Khai Nguyen and Nhat Ho. Revisiting Sliced Wasserstein on images: From vectorization to convolution. In NeurIPS, 2022. 1, 2, 11
  6. [6]Julien Rabin, Gabriel Peyré, Julie Delon, and Marc Bernot. Wasserstein barycenter and its application to texture mixing. In SSVM, 2011. 2
  7. [7]Nicolas Bonneel, Julien Rabin, Gabriel Peyré, and Hanspeter Pfister. Sliced and Radon Wasserstein barycenters of measures. Journal of Mathematical Imaging and Vision, 51(1):22–45, 2015. 2
  8. [8]Tero Karras, Timo Aila, Samuli Laine, and Jaakko Lehtinen. Progressive growing of GANs for improved quality, stability, and variation. In ICLR, 2018. 2
  9. [9]Eric Heitz, Kenneth Vanhoey, Thomas Chambon, and Laurent Belcour. A sliced Wasserstein loss for neural texture synthesis. In CVPR, 2021. 2
  10. [10]Ariel Elnekave and Yair Weiss. Generating natural images with direct patch distributions matching. In ECCV, 2022. 2
  11. [11]Jiaqi He, Zhihua Wang, Leon Wang, Tsein-I Liu, Yuming Fang, Qilin Sun, and Kede Ma. Multiscale sliced Wasserstein distances as perceptual color difference measures. In ECCV, 2024. 2
  12. [12]Michael Unser. Local linear transforms for texture measurements. Signal Processing, 11(1):61–79, 1986. 2, 4
  13. [13]Lokesh Vermeacheneni, Moritz Wolter, Hilde Kuehne, and Juergen Gall. Fréchet wavelet distance: A domain-agnostic metric for image generation. In ICLR, 2025. 2
  14. [14]Filippo Santambrogio. Optimal Transport for Applied Mathematics: Calculus of Variations, PDEs, and Modeling. Birkhäuser, 2015. 2, 5, 12DOI
  15. [15]Nicolas Fournier and Arnaud Guillin. On the rate of convergence in Wasserstein distance of the empirical measure. Probability Theory and Related Fields, 162(3-4):707–738, 2015. 2
  16. [16]Harald Cramér and Herman Wold. Some theorems on distribution functions. Journal of the London Mathematical Society, 11(4):290–294, 1936. 2
  17. [17]Sangmin Park and Dejan Slepčev. Geometry and analytic properties of the sliced Wasserstein space. Journal of Functional Analysis, 289(7):110975, 2025. 2
  18. [18]Soheil Kolouri, Kouri Nadjahi, Umut Simsekli, Roland Badeau, and Gustavo K. Rohde. Generalized sliced Wasserstein distances. In Advances in Neural Information Processing Systems, 2019. 2arxiv.org/abs/1902.00434
  19. [19]David J. Field. Relations between the statistics of natural images and the response properties of cortical cells. Journal of the Optical Society of America A, 4(12):2379–2394, 1987. 2
  20. [20]Nasir Ahmed, T. Natarajan, and Kamisetty R. Rao. Discrete cosine transform. IEEE Transactions on Computers, C-23 (1):90–93, 1974. 2DOI
  21. [21]Michael Unser. On the approximation of the discrete Karhunen-Loève transform for stationary processes. Signal Processing, 7(3):231–249, 1984. 2
  22. [22]Daniel L. Ruderman and William Bialek. Statistics of natural images: Scaling in the woods. Physical Review Letters, 73 (6):814–817, 1994. 2
  23. [23]Stéphane G. Mallat. A theory for multiresolution signal decomposition: The wavelet representation. IEEE Transactions on Pattern Analysis and Machine Intelligence, 11(7):674–693, 1989. 2
  24. [24]Antonio Torralba and Aude Oliva. Statistics of natural image categories. Network: Computation in Neural Systems, 14(3):391–412, 2003. 3, 7
  25. [25]Wieland Brendel and Matthias Bethge. Approximating CNNs with bag-of-local-features models works surprisingly well on ImageNet. In ICLR, 2019. 3, 7
  26. [26]Min Jin Chong and David Forsyth. Effectively unbiased FID and Inception Score and where to find them. In CVPR, 2020. 3, 10
  27. [27]William G. Cochran. The combination of estimates from different experiments. Biometrics, 10(1):101–129, 1954. 3, 11
  28. [28]Felix Biggs, Antonin Schrab, and Arthur Gretton. MMD-FUSE: Learning and combining kernels for two-sample testing without data splitting. In NeurIPS, 2023. 3, 11
  29. [29]Daniel L. Ruderman, Thomas W. Cronin, and Chuan-Chin Chiao. Statistics of cone responses to natural images: Implications for visual coding. Journal of the Optical Society of America A, 15(8):2036–2045, 1998. 4
  30. [30]Michael Unser. Splines: Perfect fit for signal and image processing. IEEE Signal Processing Magazine, 16(6):22–38, 1999. 4
  31. [31]Jacob Cohen. Statistical Power Analysis for the Behavioral Sciences. Lawrence Erlbaum Associates, 2nd edition, 1988. 4
  32. [32]Alexia Jolicoeur-Martineau, Rémi Piché-Taillefer, Ioannis Mitliagkas, and Rémi Tachet des Combes. Adversarial score matching and improved sampling for image generation. In ICLR, 2021. 5
  33. [33]Ziwei Liu, Ping Luo, Xiaogang Wang, and Xiaou Tang. Deep learning face attributes in the wild. In ICCV, 2015. 5arxiv.org/abs/1411.7766
  34. [34]Augustus Odena, Vincent Dumoulin, and Chris Olah. Deconvolution and checkerboard artifacts. Distill, 2016. 5DOI
  35. [35]Joel Frank, Thorsten Eisenhofer, Lea Schönherr, Asja Fis- cher, Dorothea Kolossa, and Thorsten Holz. Leveraging fre- quency analysis for deep fake image recognition. In ICML, 2020. 5arxiv.org/abs/2003.08685
  36. [36]Tsung-Yi Lin, Michael Maire, Serge Belongie, James Hays, Pietro Perona, Deva Ramanan, Piotr Dollár, and C. Lawrence Zitnick. Microsoft COCO: Common objects in context. In ECCV, 2014. 5arxiv.org/abs/1405.0312
  37. [37]Jia Deng, Wei Dong, Richard Socher, Li-Jia Li, Kai Li, and Li Fei-Fei. ImageNet: A large-scale hierarchical image database. In CVPR, 2009. 5, 12
  38. [38]Alex Krizhevsky. Learning multiple layers of features from tiny images. Technical report, University of Toronto, 2009. 5
  39. [39]Yann Brenier. Polar factorization and monotone rearrangement of vector-valued functions. Communications on Pure and Applied Mathematics, 44(4):375–417, 1991. 5
  40. [40]Jean-Jacques Moreau. Proximité et dualité dans un espace hilbertien. Bulletin de la Société Mathématique de France, 93:273–299, 1965. 5, 12
  41. [41]Leonid I. Rudin, Stanley Osher, and Emad Fatemi. Nonlinear total variation based noise removal algorithms. Physica D: Nonlinear Phenomena, 60(1–4):259–268, 1992. 5, 12
  42. [42]Yochai Blau and Tomer Michaeli. The perception-distortion tradeoff. In CVPR, 2018. 6DOI
  43. [43]Xintao Wang, Ke Yu, Shixiang Wu, Jinjin Gu, Yihao Liu, Chao Dong, Yu Qiao, and Chen Change Loy. ESRGAN: Enhanced super-resolution generative adversarial networks. In ECCV Workshops, 2018. 6, 13arxiv.org/abs/1809.00219
  44. [44]Eirikur Agustsson and Radu Timofte. NTIRE 2017 challenge on single image super-resolution: Dataset and study. In CVPR Workshops, 2017. 6, 13
  45. [45]Erich L. Lehmann and Joseph P. Romano. Testing Statistical Hypotheses. Springer, 3rd edition, 2005. 11
  46. [46]Peter H. Westfall and S. Stanley Young. Resampling-Based Multiple Testing: Examples and Methods for p-Value Adjustment. Wiley, 1993. 11DOI
  47. [47]Antonin Schrab, Ilmun Kim, Mélisande Albert, Béatrice Laurent, Benjamin Guedj, and Arthur Gretton. MMND aggregated two-sample test. Journal of Machine Learning Research, 24(194):1–81, 2023. 11
  48. [48]Alec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh, Gabriel Goh, Sandhini Agarwal, Girish Sastry, Amanda Askell, Pamela Mishkin, Jack Clark, Gretchen Krueger, and Ilya Sutskever. Learning transferable visual models from natural language supervision. In ICML, 2021. 11
  49. [49]Gaurav Parmar, Richard Zhang, and Jun-Yan Zhu. On aliased resizing and surprising subtleties in GAN evaluation. In CVPR, 2022. 12
  50. [50]Christian Ledig, Lucas Theis, Ferenc Huszár, Jose Caballero, Andrew Cunningham, Alejandro Acosta, Andrew Aitken, Alykhan Tejani, Johannes Totz, Zehan Wang, and Wenzhe Shi. Photo-realistic single image super-resolution using a generative adversarial network. In CVPR, 2017. 13
  51. [51]MMEditing Contributors. MMEditing: OpenMMLab image and video editing toolbox. https://github.com/open-mmlab/mmediting, 2022. 13
  52. [52]Xintao Wang, Liangbin Xie, Ke Yu, Kelvin C. K. Chan, Chao Dong, and Ying Shan. Real-ESRGAN: Training real-world blind super-resolution with pure synthetic data. In ICCV Workshops, 2021. 13
  53. [53]Kai Zhang, Jingyun Liang, Luc Van Gool, and Radu Timofte. Designing a practical degradation model for deep blind image super-resolution. In ICCV, 2021. 13

Paper details

vlnc:W_gs4kkubb
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 2

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Claude

View statement
Looking for related papers…
Contents