Text from the interactive explanation
A Unified Anomaly Synthesis Strategy with Gradient Ascent for Industrial Anomaly Detection and Localization
Qiyu Chen, Huiyuan Luo, Chengkan Lv, Zhengtao Zhang
An interactive guide to GLASS · industrial inspection, 2024
Looms turn out cloth by the kilometre. Flaws are rare, and the worst ones are barely there. You are the inspector first: tap each flaw before it crosses the scan line.
Tap a flaw to flag it: a blue ring and a green outline mean you got it.
Missed flaws get a red outline as they pass the scan line.
Keyboard focus the cloth and press Space or Enter to flag whatever sits on the scan line.
β is the paper's transparency knob: how much of the original cloth still shows through a flaw. Every flaw here is woven with the paper's own fake-flaw recipe.
1
It has only ever seen good cloth
Flaws are hard to collect and costly to label pixel by pixel, so detectors in this field learn from normal images only. MVTec AD, the standard benchmark, gives a detector 3,629 training photos of 15 kinds of objects and textures, every one of them flawless. The authors' own woven-fabric collection (WFDD) trains on 3,657 flawless cloth images.
GLASS looks at each photo through a network that was trained beforehand on a large collection of other photos. It describes every small patch of the photo with a long list of numbers: a point in a feature map. Patches of good cloth get similar lists, so their points crowd together.
The bold flaw lands far from the crowd. The faint one lands just outside it. A detector that knows only “normal” has to draw its fence tight enough to catch that one, without fencing out good cloth.
2
Teach it with fakes
If real flaws are scarce, invent them. Synthesis-based methods add fake flaws during training, so a small judge network (the discriminator) learns where “normal” ends. GLASS makes two kinds: blotches pasted into the photo itself, and nudged points inside the feature map. Build the first kind here. The paper calls it Local Anomaly Synthesis (LAS) .
I Pick a shape
Two random cloud-like masks (Perlin noise) are combined. Each option has a one-in-three chance during training.
II Borrow a texture
A random image from a texture library (the Describable Textures Dataset) gets three random edits out of nine. Ours are code-drawn stand-ins.
III Blend
Inside the mask, texture and original are mixed: x⁺ = (1 − β)·texture + β·original. Outside it, the image is untouched.
While training, β is drawn from this bell curve around 0.5 (kept between 0.2 and 0.8), so the fakes range from bold to faint.
The same blending formula at fixed β = 0.1, 0.3, 0.5 and 0.7 is how the authors built their faint-flaw test set, MAD-sys (blending in patches from other training images), and how the flaws on the loom above were woven.
These fakes are vivid and varied, with realistic detail. But in the feature map they mostly land far from normal (the grey triangles in the lab below): they are strong, obvious anomalies, and on their own they say little about exactly where normal ends.
3
The Fence Lab
The second kind of fake is made directly in the feature map. The simplest way, used by earlier methods such as SimpleNet, is to nudge a normal point with random (Gaussian) noise and call the result a flaw. GLASS's Global Anomaly Synthesis (GAS) adds two steps: the nudged point climbs toward wherever the judge is most fooled (gradient ascent), then is fenced back into a thin band just outside normal (truncated projection).
Simulation A tiny judge network trains live in your browser on a 2-D toy map. It shows the mechanism, not the paper's network or data. The measured results come in section 4.
Before you try it: which recipe will build the tightest fence around normal?
normal patches
random-nudge fake
GAS fake (trail = climb)
pasted-texture fake
the fence: judge says 50%
r₁ and r₂
×hidden real flaw (ring = caught)
Click or drag anywhere on the map to ask the inspector about that spot.
Watch what each recipe leaves behind. Random nudges pile fakes on top of normal points, so good patches get flagged. Climb-and-fence fakes sit just outside normal, so the fence hugs the data. But GAS alone can leave stray “normal” pockets far away, where no fake ever went. The pasted-texture fakes in full GLASS cover that distant ground. The paper calls the two kinds complementary.
Climb · gradient ascent (Eq. 1)
g̃ = g + η · ∇L / ‖∇L‖
L measures how wrong the judge is when it calls this fake a flaw. Take a fixed-size step η in the direction that makes it more wrong, toward where the fake looks normal. Repeat a few times. Each step makes the fake harder to catch.
Fence · truncated projection (Eq. 2)
distance d from the source point → clamp d between r₁ and r₂ = 2r₁
Measure how far the fake has moved from the normal point it came from. Under r₁? Push it out to r₁. Over r₂? Pull it back to r₂. Fakes end up in a thin shell: near-misses, not overlaps. The paper found r₁ between 0.5 and 1 works best, with 1 as the default.
Ribbon or ball?
GLASS has two versions of the fence. GLASS-m assumes normal features lie along a thin curved sheet (a manifold) and measures from each fake's own source point. GLASS-h assumes they fill a ball around a centre c: r₁′ is set to hold 75% of normal points, GAS fakes go between r₁′ and r₂′ = 2r₁′, and pasted-texture fakes between r₂′ and r₃′ = 4r₁′. GLASS-j picks per product, using a quick test on the average training image: how compact its frequency spectrum (spectrogram) is. Low means ribbon, high means ball.
Measured Example categories from the paper's Fig. S5. In the real system a trainable adaptor also pulls normal features together while training; the toy map above is fixed.
240 normal points sit along a curve (or fill a disc). 120 more are held out to count false alarms. 36 hidden “real flaws”, 24 faint ones just outside normal and 12 bold ones far away, are never used for training. A network with one hidden layer of 24 units learns to output 0 for normal points and 1 for fakes (Adam optimizer, binary cross-entropy). The yellow line is where it says 50%; anything it scores above 50% counts as flagged.
Each batch makes 64 fresh fakes (plus 32 pasted-texture fakes in GLASS mode) and takes three training steps. Choosing a recipe starts a new inspector from scratch and fast-forwards 300 batches so you can compare fairly. Distances are in toy units. The slider starts at r₁ = 1 to echo the paper's default, but the toy's units are not the paper's feature units.
Two shortcuts stand in for high dimensions. With hundreds of numbers per point, a random nudge has almost the same length every time, and it points almost entirely away from the thin sheet of normal features. So our nudges have a nearly fixed length σ, nudges and climbs move mostly across the ribbon, and the fence (Eq. 2) is applied to that across-the-ribbon distance from the source point. Pasted-texture fakes are placed directly far from normal, as the paper's diagram describes, rather than computed from images.
4
What the experiments showed
Measured Everything above was illustration. These are the paper's measurements on real product images.
How to read the scores. AUROC: pick one flawed and one good image at random; how often does the detector give the flawed one the higher score? 50% is coin-flipping, 100% is a perfect ranking. Pixel AUROC asks the same of individual pixels. PRO (per-region overlap) checks how well each flawed region is outlined.
Fainter flaws, wider gap
MAD-sys is a test set the authors built from five MVTec AD texture categories by blending flaws in with the LAS formula at four faintness levels (4,730 flawed and 1,600 normal test images). As flaws fade, every method slips. GLASS slips least.
Source: Table S8 (GLASS-m vs. five leading methods of different families).
What each ingredient adds
The authors switched GLASS's ingredients on one at a time (GLASS-m, Table 4). MAD-man is a set of real faint flaws hand-picked from all 15 MVTec AD categories by five people independently; MAD-sys is the synthetic faint set above.
image AUROC
pixel AUROC
PRO
previous step
Noise alone does well on everyday flaws (MVTec AD) but poorly on faint synthetic ones (MAD-sys); pasted textures are the reverse. Gradient ascent and projection add only a little on MVTec AD, where scores are already near the ceiling, and more on the faint-flaw sets. This is where the toy lab is only a cartoon: there, pasted-texture fakes alone miss most faint flaws, but in these measurements they beat noise alone on MAD-sys (94.4% vs 84.1% image AUROC), whose faint flaws are local blends. The authors read this as the pasted fakes' strength on local flaws, and the two kinds of fake as complementary: together they cover more kinds of flaw than either alone.
Accurate and fast
Average image AUROC over four datasets (MVTec AD, VisA, MPDD, WFDD) against speed, measured on an NVIDIA Tesla A800 GPU (Table 2). The fakes exist only during training: at inspection time GLASS runs just the feature extractor, the adaptor and the judge.
99.9%
image AUROC on MVTec AD (GLASS-j), with 99.3% pixel AUROC
9 of 15
MVTec AD categories detected perfectly (100% image AUROC, GLASS-j)
100%
image AUROC on WFDD, the authors' woven-fabric set of 4,101 images (GLASS-j)
95.6 vs 84.6
image AUROC on faint synthetic flaws (MAD-sys): GLASS vs SimpleNet
−0.7 vs −6.2
change in image AUROC when backgrounds were made dirty (simulated on VisA Capsules): GLASS vs SimpleNet
5
Back at the loom
Your inspection
Remember the faintest flaws on the loom? That is exactly where GLASS earns its keep. By practising on near-misses, fakes that sit just outside normal, the judge learns a tighter fence, so faint flaws fall outside it. On the faintest synthetic flaws (β 0.7), GLASS scored 88.0% image AUROC where the next best method in the comparison scored 82.6%. And because the fakes are needed only while training, inspection stays fast.
What's next, according to the authors. GLASS targets structural flaws, the kind that change how a surface looks. Logical anomalies, such as a missing or misplaced component, have not yet been explored extensively. The authors also plan to make fakes without relying on an external texture library.
A frozen, pre-trained WideResNet50 extracts features from its second and third levels, averaged over 3×3 neighbourhoods, from images resized to 288×288. A trainable one-layer adaptor adjusts them. The judge is a small network with one hidden layer and a sigmoid output, giving every feature point an anomaly score between 0 and 1.
Training adds up three losses: normal features should score 0 (binary cross-entropy), GAS fakes should score 1 (binary cross-entropy), and LAS fakes are scored against their masks with a focal loss plus online hard example mining, which concentrates on the hardest pixels. Adam optimizer, 640 epochs, batch size 8.
At inspection time only the normal path runs: extractor, adaptor, judge. The score map is enlarged to image size and smoothed with a Gaussian filter to give the pixel map; the image's score is the highest value on the map.
Averaged over the four datasets, GLASS-m (ribbon) reaches 99.5% image AUROC, GLASS-h (ball) 98.4%, and GLASS-j, which chooses per category, 99.6%.
Source & credits
Qiyu Chen, Huiyuan Luo, Chengkan Lv and Zhengtao Zhang (Institute of Automation, Chinese Academy of Sciences; School of Artificial Intelligence, University of Chinese Academy of Sciences; CASI Vision Technology). A Unified Anomaly Synthesis Strategy with Gradient Ascent for Industrial Anomaly Detection and Localization. arXiv preprint arXiv:2407.09359 [cs.CV], 2024. arxiv.org/abs/2407.09359
Code and datasets, including WFDD, MAD-man and MAD-sys: github.com/cqylunlun/GLASS.
Every visual on this page is an original, code-drawn illustration or simulation; the paper's figures are not reproduced. The loom, lens map and Fence Lab are illustrations and a toy simulation of the mechanism. All numbers marked “measured” come from the paper's Tables 2, 3, 4, S1 and S8 and Fig. S5.
Topics in this iPaper
Computer science
Anomaly detection and localization aim to identify and localize abnormal
Section 1 Introduction, page 1
Engineering
have been further validated in industrial applications for woven fabric defect detection
Abstract, page 1
anomaly detection
Keywords: Industrial anomaly detection · Anomaly synthesis · Weak defect detection · Gradient ascent
Abstract and keywords, page 1
defect detection
and MPDD datasets and excels in weak defect detection
Abstract, page 1
gradient ascent
in a controllable way using Gaussian noise guided by gradient ascent and truncated projection
Abstract, page 1
unsupervised learning
Consequently, unsupervised anomaly detection techniques are widely applied in industrial inspection
Section 1 Introduction, page 1
computer vision
arXiv:2407.09359v1 [cs.CV] 12 Jul 2024
arXiv header, page 1