University of Padova's MIRAGE Fakes Factory Defects With 0.93 Pixel Accuracy
A training-free pipeline turns Gemini 2.5 Flash Image into a factory defect generator, releasing 13,000 labeled image-mask pairs across MVTec AD and VisA.
ProTakeaways
- MIRAGE generates realistic industrial defects using Gemini 2.5 Flash Image via API, requiring no training or real anomalies.
- A dual-branch mask pipeline combines Grounding DINO semantic features with YOLOv26-Seg structural features, hitting 0.93 pixel AUROC.
- Human raters ranked MIRAGE within 0.28 TrueSkill points of real defect photos across 1,550 pairwise votes.
- Downstream U-Net segmentation trained on MIRAGE data beats GLASS, RealNet, and AnomalyAny on MVTec AD and VisA.
- A CLIP-based filter that drops misaligned generations lifts image-level AUROC from 0.70 to 0.80 on MVTec.
- Authors released 13,000+ image-mask pairs and code on GitHub and Hugging Face.
Factory inspection models have a chicken-and-egg problem: they need examples of defects to learn from, but real defects are rare, expensive to collect, and often confidential. A new pipeline out of the University of Padova sidesteps that entirely by asking a general-purpose image model to hallucinate industrial defects on top of clean product photos, then automatically generating pixel-perfect masks for them, all without training a single network.
The system, called MIRAGE, treats the generator as a black box behind an API call. It is a fully automated pipeline for realistic anomalous image generation and pixel-level mask creation that requires no training and no anomalous images, and it accesses any generative model as a black box via API calls, uses a VLM for automatic defect prompt generation, and includes a CLIP-based quality filter to retain only well-aligned generated images. The current implementation uses Gemini 2.5 Flash Image (Nano Banana) as the backbone, but any generator with an API can be swapped in.
Why synthetic defects are hard to get right
Most industrial anomaly detection sits in the one-class regime: train only on normal parts, flag anything that looks off. Adding even a handful of labeled defective samples boosts accuracy sharply, which is why synthetic anomaly generation has become its own subfield. The existing options all come with painful tradeoffs.
- Copy-paste methods like DRAEM and GLASS paste Perlin-noise textures onto clean images. Cheap, but the results rarely look like real cracks or scratches.
- Per-category diffusion approaches like RealNet train a dedicated DDPM for every product class, which does not scale.
- Few-shot conditioning methods produce highly realistic defects but need real anomalous examples to bootstrap, defeating the point.
- Zero-shot state of the art AnomalyAny uses a frozen Stable Diffusion with attention-guided optimization. It still requires a GPU with at least 30 GB of VRAM, long generation times, and substantial implementation effort, making it difficult to adopt in practical industrial deployments.
How the pipeline actually runs
MIRAGE breaks the job into three stages, each of which is either a single API call or a small forward pass through a pretrained model.
- Prompt generation. A vision-language model (the authors used ChatGPT-5) is shown a few normal reference images and asked to list ten plausible defects for that product, each with a short generation-ready description. Because the VLM sees actual product photos, the defects are grounded in the material and geometry, not just the class name.
- Image generation. For each normal image and defect description, Gemini 2.5 Flash Image is called with an instruction to produce a photorealistic version containing that defect while preserving background, lighting, and layout. The paper generates 500 images per category (10 defect types x 50 images).
- CLIP quality filter. Not every generation lands. A CLIP check compares four image-text similarities and keeps only images where the defect prompt aligns better with the anomalous image than with the normal one, and better than the normal prompt does. Failed generations get discarded.
The interesting engineering happens in stage four: producing the pixel mask. Naive pixel differencing between the normal and generated image fails because generative models introduce subtle global shifts in color and texture during re-rendering. MIRAGE runs a dual-branch feature diff instead.

The semantic branch uses Grounding DINO conditioned on defect keywords like "scratch, linear mark." It extracts intermediate features for both the normal and anomalous images under the same text prompt, then takes the L2 difference across channels. Conditioning on the normal image with the defect prompt gives a baseline activation that gets subtracted away, suppressing false positives where the normal texture partially matches the defect description.
The structural branch uses YOLOv26-L-Seg, comparing multi-scale backbone features between the two images with no text conditioning. Early layers catch fine local changes, deeper layers catch broader deformations. The final mask is the element-wise product of the two normalized maps, keeping only pixels that are both semantically relevant and structurally different. Reference masks are collected for 1,000 image pairs on MVTec AD and 720 on VisA, and the pipeline substantially outperforms View-Delta on both benchmarks, achieving an average pixel-level AUROC of 0.93 compared to 0.73. The whole mask stage takes about one second per image on a single RTX A6000 using roughly 3 GB of VRAM.
How the results stack up
The authors ran the most thorough evaluation the field has seen so far: downstream U-Net segmentation on MVTec AD and VisA, Inception Score, IC-LPIPS, and a human perceptual study with 31 participants casting 1,550 pairwise votes ranked via TrueSkill.
| Method | TrueSkill | Win rate |
|---|---|---|
| Real images | 28.61 | 73.8% |
| MIRAGE | 28.33 | 67.2% |
| AnomalyAny | 27.16 | 59.2% |
| RealNet | 23.54 | 33.7% |
| GLASS | 20.26 | 14.4% |
MIRAGE lands within 0.28 TrueSkill points of real defect photos, which is remarkable given it never sees one. It also posts the best mean Inception Score (2.68) and IC-LPIPS (0.38) on MVTec AD, and the best mean downstream U-Net pixel-AUROC on both benchmarks (0.92 on MVTec, 0.92 on VisA). The CLIP filter alone lifts image-level AUROC on MVTec from 0.70 to 0.80 without touching the model.
What ships, and where it breaks
The team open-sourced the full pipeline on GitHub and released the generated data on Hugging Face. That is 500 image-mask pairs per category for every MVTec AD and VisA class, over 13,000 pairs in total, plus every prompt used to generate them. Prior anomaly generation papers typically released neither, so anyone wanting to compare had to regenerate from scratch.
The honest caveats: quality is bounded by whatever generator you point it at, and highly creative generations that drift too far from the source image can degrade mask accuracy because the change-detection assumes reasonable visual correspondence. There is also a small per-category calibration step that uses 5-8 reference masks from a higher-cost Gemini variant to pick the binary threshold. Beyond that, the model-agnostic design means the next better image model to ship becomes a one-line endpoint swap, which is exactly the point.