Automated visual inspection is supposed to replace a tired human inspector with a fixed decision rule. Human visual error rates in electronics manufacturing are reported at 20% to 30% (Impact of Artificial Intelligence on Comparative Advantages in the Electronics Manufacturing Industry), and an inspector's working definition of "defect" drifts over a shift. Two things undercut the promise. First, the training labels still come from those same drifting humans. Second, real factory floors contain look-alikes. In Smart-Inspect, a smartphone-glass inspection system, accuracy falls from 97.77% to about 75% in dusty conditions because dust particles resemble pits and scratches. Defect datasets are also extremely imbalanced, so practitioners reach for focal loss, a training objective that down-weights easy examples and concentrates gradient on hard ones (Focal Loss for Dense Object Detection). Focal loss cannot tell why an example is hard. A real scratch hidden in a dense circuit pattern and a patch an inspector mislabeled on a bad afternoon both look "hard", and both receive amplified gradient.
We propose to separate the two causes with a cheap internal measurement borrowed from graph fraud detection. There, fraudsters camouflage themselves by linking to benign accounts, and methods such as GADAM detect them by comparing what a node looks like on its own with what its neighborhood says. We carry this over to images. Each image patch gets two predictions, one from the patch alone and one from its spatial neighbors and a bank of normal reference patches. A learned per-patch gate fuses the two predictions. The loss then gives full focal weight to hard patches where the two views disagree, which is the signature of camouflage. Hard patches where both views agree the label is wrong are down-weighted, which is the signature of label noise.
Core Claim
In imbalanced defect inspection trained on subjective human labels, the disagreement between a context-free prediction and a context-aggregated prediction identifies which hard examples are camouflaged true signal and which are annotation noise. Using this disagreement to gate both the feature fusion and the focal weighting should improve robustness to look-alike contaminants, such as Smart-Inspect's dusty split, and to drifting labels at the same time. Plain focal loss, label cleaning, or contaminant augmentation should each handle at most one of these problems.
The graph-camouflage analogy is concrete, not decorative. A genuine micro-defect behaves like a rare heterophilic node, meaning a node whose class differs from its neighbors: it is surrounded by normal surface, and averaging over context washes it out. This is the structural distribution shift problem that motivates the graph work. Dust behaves like a contaminant that is locally defect-like but globally common across the panel. The context branch can therefore recognize it as "background here". The self branch alone cannot.
Relation to Prior Work
The graph fraud literature supplies the mechanism. GADAM mines local inconsistency with an aggregation-free network and then applies attention that penalizes inconsistent neighbors. Partitioning Message Passing aggregates fraudulent, benign and unlabeled neighbors with separate node-specific functions. HAG-CFNet routes homophilic and heterophilic connections through separate channels and also addresses class skew. We reuse their core move of keeping self evidence and context evidence apart. All three treat labels as trustworthy and use the self-versus-context split only to build better representations. We additionally use the split as a diagnostic that decides how much each training example is allowed to pull on the model. From the portion of the file available to us, HAG-CFNet is the closest existing combination of camouflage, adaptive fusion and imbalance. As far as the file describes it, HAG-CFNet does not distinguish label noise from camouflage, and it operates on relational graphs rather than inspection images.
The inspection literature motivates the gap and constrains the design. Smart-Inspect's dust result shows that contaminant mimicry is a first-order failure. Reference-based methods such as NDP-Net depend on alignment with a defect-free template, and PCA-based feature reconstruction (FRE) models normality globally. Both show that normal-reference context is useful. NDP-Net's alignment requirement warns us not to build the context branch on pixel-aligned templates. We therefore use an unaligned bank of normal patch features. Line-speed constraints, such as the 62 FPS of the online PCB detector and the axial-attention approximations in DAS-YOLOv13, rule out quadratic global attention for the context branch.
The focal-loss literature supplies the objective and its known weakness. AdaFocal adapts the focusing strength per confidence bin using a validation set. Unbiased Teacher uses focal loss to stop pseudo-labels from collapsing onto the dominant class. Neither addresses the recognized failure that focal loss amplifies mislabeled examples. AdaFocal adapts by confidence level, and confidence alone cannot separate a camouflaged defect from a mislabeled patch, since both sit at low $p_t$. Our weighting uses a signal orthogonal to confidence.
Research Program
The model is a lightweight detector backbone, either a YOLO-style network as in DAS-YOLOv13 or a ResNet-18 patch encoder as in Smart-Inspect, with two heads per patch $i$.
The self head sees only the patch's own features and outputs a defect probability $p^s_i$.
The context head outputs $p^c_i$ from aggregated features. It uses cheap axial or local-window attention over spatial neighbors, plus nearest-neighbor retrieval into a bank of normal patch features. Following GADAM, the context head also receives the difference between the patch and its context, not just the aggregate, so that it can flag isolated deviations rather than smooth them away.
A small gate network, conditioned on both feature sets, produces $g_i \in [0,1]$. The fused prediction is $p_i = g_i p^s_i + (1-g_i) p^c_i$. This is the adaptive fusion ingredient. Its job is to trust the self view when context is misleading, as with a pattern-hidden scratch, and to trust the context view when the patch alone is misleading, as with dust.
Training uses a disagreement-weighted focal loss. Let $p_{t,i}$ be the fused probability assigned to the given label. Let $\delta_i = |p^s_{t,i} - p^c_{t,i}|$ be the branch disagreement, computed with gradients stopped. Let $a_i \in [0,1]$ be an estimate of how trustworthy the label is. The loss for patch $i$ is
$$ \mathcal{L}_i = -\big[\delta_i + (1-\delta_i)\,a_i\big]\,(1-p_{t,i})^{\gamma}\,\log p_{t,i}, $$
with $\gamma$ the usual focusing parameter. When the branches disagree, the patch keeps its full focal weight whatever the label's reliability, because disagreement indicates genuine camouflaged structure. When the branches agree and the example is still hard, the weight shrinks toward $a_i$.
The label-trust estimate $a_i$ is set in one of two ways. Where multiple annotators exist, it is their agreement rate. Otherwise it is a fixed constant $a$, which reduces the second term to a principled damping of consistently contradicted labels. The auxiliary heads get their own plain focal losses so that $p^s$ and $p^c$ remain meaningful. We also log $\delta$ over training to check that it does not collapse to zero.
The analysis half of the program asks whether $\delta$ actually separates the two populations. We will build controlled label noise that mimics inspector drift, grounded in the reported fatigue drift, rather than using uniform flips. Each training image is assigned a synthetic "shift time". Its label comes from a defect-size or contrast threshold that drifts with that time, producing error rates in the 20% to 30% range reported for humans. Separately, we will build a camouflage split by compositing real dust or pattern texture near true defects and by using Smart-Inspect's dusty images directly. If feasible, a small subset of each dataset will be re-annotated by several people to obtain real disagreement.
Baselines
The naive reference point is the same backbone trained with plain cross-entropy and no context branch. It shows how much imbalance alone costs.
The standard practitioner baseline is the same backbone with ordinary focal loss and tuned $\gamma$, trained on identical data. This is the method our proposal most directly modifies.
The strongest reported system on the dusty regime is the Smart-Inspect pipeline itself: Sobel-and-NMS patch extraction, ResNet-18 features, iterative k-means and a Random Forest. It reports 97.77% accuracy in clean conditions and about 75% in dusty conditions (Smart-Inspect). We will reproduce it on the same splits and treat 75% as the bar. Beating it means a statistically clear gain over our reproduction on the dusty split without losing more than a point on the clean split.
For wafer surfaces, DAS-YOLOv13 is the strongest architecture in the file, combining attention and adaptive multi-scale fusion. No reported result was found on Lacuna for DAS-YOLOv13's detection accuracy, so we will train it ourselves under our budget.
We also include two competitors aimed at each half of the claim. The first is AdaFocal, the strongest adaptive-focal method, given the same validation data. The second is the graph-derived dual-channel idea transplanted directly: our two-branch model with learned gating but plain focal loss. This second baseline is the key ablation, because it isolates whether the disagreement weighting adds anything beyond the fusion architecture. A further ablation fixes $g_i = 0.5$ to isolate the adaptive gate.
All methods share backbone, input resolution, augmentation, epochs and a matched hyperparameter search budget, for example the same number of trials. All are reported with mean and spread over at least three seeds, with latency measured on one inspection-grade GPU.
Why not just…?
Why not just augment the training data with synthetic dust? This is a real threat for the contaminant half of the problem. If Smart-Inspect's dust failure is simply a distribution-coverage gap, compositing dust into clean images might recover most of the lost accuracy with no architectural change. We will run focal loss plus dust augmentation as a named baseline on the dusty split. If it matches our method there, we will concede the contaminant claim and restrict the contribution to label-noise separation. Augmentation does nothing for drifting labels, and it cannot anticipate contaminants absent from the augmentation library. We will also test on a held-out contaminant type, pattern interference on wafers, that is not used in augmentation.
Why not just clean the labels by majority vote or use a noise-robust loss? Where several annotators exist, majority voting removes much drift. Robust losses that cap the gradient of low-$p_t$ examples also limit the damage from mislabels. Both, however, suppress all hard examples that contradict the model. That is exactly the population where camouflaged true defects live, so their recall should fall on the camouflage split. Our controlled experiment measures this directly: recall on composited camouflaged defects under each method at matched noise robustness. If a robust loss keeps camouflaged recall intact, the weighting term is unnecessary and we will say so.
Why not just use AdaFocal or tune $\gamma$ per class? Confidence-binned adaptation redistributes weight by how confident the model is. Camouflaged defects and mislabeled patches both sit at low confidence, so any confidence-indexed rule treats them the same. The decisive measurement is how well each candidate signal separates injected-noise patches from true camouflaged defects, measured by the area under the ROC curve: $\delta$ versus $1-p_t$, the only signal available to confidence-based methods. If $1-p_t$ separates them as well as $\delta$ does, our premise is wrong.
Why not just use a stronger fusion detector like DAS-YOLOv13? Better attention-based fusion may reduce camouflage by itself. It does not change how label noise enters the gradient. The two-branch-plus-plain-focal ablation and the DAS-YOLOv13 baseline together show how much of any gain is due to fusion alone.
Proposed Experiments and Decisive Checks
The benchmarks cover four product types. The first is Smart-Inspect's smartphone-glass data with its clean and dusty conditions, the most direct test of contaminant mimicry. The second is the PCB defect dataset of Tang et al., where we will also check the 62 FPS line-speed reference. The third is wafer surface defects in the DAS-YOLOv13 setting, which tests pattern-interference camouflage. The fourth is photovoltaic electroluminescence images (Fioresi et al.), which have different textures.
We report accuracy on Smart-Inspect for comparability with the published 97.77% and ~75% numbers. Everywhere we also report area under the precision-recall curve for the rare defect class, false-alarm rate on contaminant patches, recall on camouflaged defects, and latency per image.
Three checks decide the project. The first is diagnostic. On the controlled splits, $\delta$ must separate drift-noise patches from camouflaged true defects clearly better than model confidence does. If it does not, the weighting has no basis and we stop.
The second is the dusty-split result. The full method must exceed our reproduced Smart-Inspect score and the focal-plus-dust-augmentation baseline, with clean accuracy preserved.
The third is the joint condition. Under drift noise at 20% to 30%, the full method must beat plain focal loss, the robust-loss baseline and AdaFocal on defect precision-recall, while keeping camouflaged-defect recall at least at plain-focal levels. The weighting ablation must account for a meaningful share of the gain over the gated two-branch model with plain focal loss. Winning only one of the second and third checks would still be useful, but it would mean the combined claim is not supported.
References
- Impact of Artificial Intelligence on Comparative Advantages in the Electronics Manufacturing Industry: A Study of China and Vietnam
- Smart-Inspect: Micro Scale Localization and Classification of Smartphone Glass Defects for Industrial Automation
- Focal Loss for Dense Object Detection
- Boosting Graph Anomaly Detection with Adaptive Message Passing
- Partitioning Message Passing for Graph Fraud Detection
- Advancing Graph Neural Networks for Complex Relational Learning: A Multi-Scale Heterogeneity-Aware Framework with Adversarial Robustness and Interpretable Analysis
- Reference-Based Autoencoder for Surface Defect Detection
- FRE: A Fast Method For Anomaly Detection And Segmentation
- Online PCB Defect Detector On A New PCB Defect Dataset
- DAS-YOLOv13: Dual-Axis Attention and Feature Fusion Model for Wafer Surface Defect Detection
- AdaFocal: Calibration-aware Adaptive Focal Loss
- Unbiased Teacher for Semi-Supervised Object Detection
- Automated Defect Detection and Localization in Photovoltaic Cells Using Semantic Segmentation of Electroluminescence Images