Visual inspection systems learn what a "normal" part looks like and flag anything that departs from it. That rule breaks as soon as something harmless gets in the way. A gripper finger, a strip of tape, a clamp or a hand in the frame departs from normal just as much as a scratch does, so the system either raises a false alarm on the occluder or, if we tell it to ignore occluded regions, goes blind to real defects that sit next to or partly under the occluder. This proposal builds a reconstruction-based detector that sorts every pixel into one of three bins: normal surface, harmless occluder to be looked past, or defect to be flagged. A reconstruction-based detector is one that learns to redraw any input as a defect-free version of itself and then compares the two. Ours additionally redraws the hidden surface beneath an occluder, so that a defect partly covered by it can still be found.
The motivation comes from a split in the literature. Face recognition treats occlusion as noise to be discarded (Biased Feature Learning). LiDAR anomaly detection reasons explicitly about what an obstacle hides (COVAL). The strongest 2D reconstruction detector, DRÆM, has no notion of occlusion at all: anything unusual is an anomaly. We want to know whether a 2D detector can learn the discard-versus-flag distinction from synthetic training data. The test is on real occluders it has never seen, and on defects that the occluder partly covers.
Core Claim
A DRÆM-style detector can separate harmless occluders from intrinsic defects if it is trained on two synthetic corruption processes composited onto normal images. The first adds defect-like textures blended into the surface. The second pastes occluding objects that sit on top of the surface, with their own coherent outline and a plausible contact shadow. The detector has two outputs. A reconstruction branch is always supervised toward the clean surface, including the region beneath the occluder. A three-class segmentation head labels pixels as normal, occluder or defect. The claim is that this detector does two things better than "detect occluders separately, then mask them out." It keeps defect detection intact where a defect overlaps or touches an occluder, and it keeps false alarms on occluded-but-normal parts near zero.
The hybrid segmentation loss plays a specific supporting role. Occluders are large, compact regions and defects are often tiny. Under a per-pixel loss such as Focal loss, which is all DRÆM uses, the occluder class dominates the gradient and the tiny-defect class is starved. A per-class region-overlap term (Dice, which scores the overlap of predicted and true regions independent of their size) keeps small defects weighted comparably to large occluders. This follows the reasoning behind Hybrid Loss Functions for Image Segmentation and the compound losses in Wu et al. and Enhanced U-Net. We do not claim that adding Dice to DRÆM is new or important on its own. It is an ablation here, not the contribution.
Research Program
The method borrows DRÆM's two-network design. An encoder-decoder receives a corrupted normal image and is trained with L2 plus SSIM loss to output the clean original. SSIM, the structural similarity measure, was shown in MVTec AD to beat plain L2 for this purpose. A U-Net then reads the input stacked with its reconstruction and outputs a segmentation map. We make two changes.
The first change is the training corruption. DRÆM uses one process: Perlin-noise masks filled with textures from the Describable Textures Dataset. We keep that process for defects and add a second one for occluders. The occluder process draws object cut-outs from a library of nuisance objects: tapes, cables, clips, fingers, fixtures. Each cut-out is pasted as an opaque layer with a hard alpha edge, a random affine pose and a soft cast shadow on the surface. The two processes are sampled independently, and their masks overlap in a controlled fraction of cases, so that the network sees defects partly hidden by occluders. Where they overlap, the ground truth labels the visible part of the defect as defect and the covered part as occluder. Reconstruction is supervised toward the clean surface everywhere. This carries over BFL's "biased guidance," in which the clean sample alone defines the target and occluded inputs are pushed toward it, from identity features to pixels.
The second change is the segmentation head and its loss. The head has three classes, trained with the following objective:
$$L_{\text{seg}} = L_{\text{Focal}}(\hat{M}, M) + \lambda \sum_{c \in \{\text{occ},\,\text{def}\}} L_{\text{Dice}}(\hat{M}_c, M_c)$$
Here $\hat{M}$ is the predicted three-class map, $M$ the synthetic ground-truth map, $\hat{M}_c$ and $M_c$ the predicted and true masks for class $c$, and $\lambda$ a single weight tuned on synthetic validation data only. At test time the anomaly map is the defect-class probability. The image score is its maximum after light smoothing, as in DRÆM.
The analysis focuses on what the network actually uses to tell the two classes apart. The main risk is that it learns an artifact of our generators, such as hard alpha edges versus soft Perlin blending, rather than the real distinction between something lying on top of the surface and something that is part of it. We probe this in three ways. We swap edge styles between the two generators at test time. We evaluate on occluder categories held out of the library. We evaluate on a small set of real photographed occlusions.
Baselines
The naive reference point is DRÆM trained exactly as published and run unchanged on occluded images. Its known behavior is to flag occluders as anomalies. It anchors the false-alarm rate that any occlusion-aware method must cut. On clean MVTec AD, DRÆM reports 98.0% image AUROC and 68.4% pixel average precision (DRÆM). We retrain it from the public recipe on the same GPU budget to confirm that we match those figures before comparing.
The strongest existing detector is PatchCore (Towards Total Recall in Industrial Anomaly Detection). It compares patch features from a pretrained network against a memory bank of normal patches and reports 99.6% image AUROC and 98.1% pixel AUROC on MVTec AD. It is the strongest competitor because it does not rely on reconstruction at all. If memory-bank matching handles occlusion adequately, our generative machinery is unnecessary. We run it with the published backbone and coreset ratio. In a stronger variant, we also add occluded normal images to its memory bank, so that occluder patches count as normal. No reported result was found on Lacuna for PatchCore, or any other method, on occluded MVTec images. The occluded-benchmark numbers therefore come from our own runs.
The most dangerous baseline is a two-stage pipeline. A separate occluder segmenter, a U-Net trained with the same synthetic occluder library and the same hybrid loss, predicts an occluder mask. PatchCore's or DRÆM's anomaly map is then zeroed inside that mask. This pipeline gets the same occluder data as our method, so any gain we show must come from joint training and reconstruction beneath the occluder, not from extra supervision.
Three ablations isolate our ingredients. The first is DRÆM with occluders added to training but labeled normal. This gives implicit augmentation without a separate occluder class. The second is our model with Focal loss only, which isolates the Dice term. The third is our model without reconstruction supervision beneath occluders, which isolates the value of looking through the occluder.
We beat the field only if two things hold at once on the occluded benchmark. Our defect-class average precision must exceed the two-stage masking pipeline's with non-overlapping confidence intervals across three seeds, with most of the gain on defects that touch occluders. Our false-positive rate on occluder pixels must stay at or below the masking pipeline's. On clean MVTec AD, we must remain within one point of retrained DRÆM's image AUROC.
Why not just…?
Why not just mask out detected occluders and run PatchCore? This is the real threat, and on defects far from any occluder it will probably match us. Masking discards every pixel inside the predicted occluder region. Any defect that runs under an occluder, or sits in the band where the occluder mask overshoots, is lost. There is also no reconstruction to check the covered surface. Our experiment reports results separately by distance between defect and occluder. If the masking pipeline matches us in the overlapping and adjacent bins too, then joint modeling adds nothing. We would report that and fall back to recommending the pipeline.
Why not just add occluded normal images to training and let the detector learn to ignore them? This is the implicit route. Gupta found that implicit training on occluded data underperforms explicit occlusion awareness, and Biased Feature Learning found that naively mixing occluded and clean samples degrades performance on clean inputs. Both results come from face tasks, not inspection. Our first ablation and the PatchCore memory-bank variant test the implicit route directly on MVTec. The specific failure we expect is that the detector learns to down-weight any foreign-looking texture, which suppresses texture-like defects.
Why not just add a Dice term to DRÆM? That is a one-line change and is plausibly worth doing. It does not touch the occluder problem, though: a DRÆM trained with Dice still flags occluders. We include it as an ablation on both clean and occluded data. If most of our gain on clean MVTec comes from Dice alone, we will say so and attribute only the occluded-data gains to the three-class design.
Proposed Experiments
The primary benchmark is an occluded version of the MVTec AD test split. Real photographed nuisance objects, disjoint from the training library, are composited onto both normal and defective test images at controlled rates of overlap with the annotated defect regions. Occluder categories are split so that a third never appear in training. The same protocol is applied to DAGM to check a texture-dominated domain. We report image AUROC for defect presence and pixel AUROC and average precision for the defect class. We also report false-positive rate on occluder pixels and a per-region overlap score. That score matters because MVTec AD showed raw-subtraction autoencoders reaching 0.86 AUROC but only 0.05 region overlap on "cable", so AUROC alone can hide poor localization. All metrics are stratified by defect-occluder distance. The clean MVTec AD test set is run as well to confirm that nothing breaks.
Three checks decide whether the idea holds. The first is the overlap-stratified comparison against the masking pipeline. If we do not win where defects touch or pass under occluders, the core claim fails. The second is the generator-swap test. Pasting defects with hard edges and occluders with soft blending at test time must not flip the classifications. If it does, the network has learned our compositing artifacts, and the method needs harder, more varied occluder synthesis before any real-world claim. The third, and least synthetic, is a small real capture of occluded parts physically arranged over normal and known-defective samples. We expect some drop from the composited benchmark. We will report the size of that drop as the honest measure of how far the synthetic training transfers.
References
- Biased Feature Learning for Occlusion Invariant Face Recognition
- Counterfactual Occlusion-Aware Learning via Visibility Intervention for LiDAR Anomaly Detection
- Reconstruction by inpainting for visual anomaly detection
- Deeply supervised network for white matter hyperintensities segmentation with transfer learning
- Enhanced U-Net: A Feature Enhancement Network for Polyp Segmentation
- MVTec AD - A Comprehensive Real-World Dataset for Unsupervised Anomaly Detection
- Towards Total Recall in Industrial Anomaly Detection
- You Can Run but not Hide: Improving Gait Recognition with Intrinsic Occlusion Type Awareness