Learn to Differ: Sim2Real Small Defection Segmentation Network

Zexi Chen, Zheyuan Huang, Yunkai Wang, Xuecheng Xu, Yue Wang, Rong XiongarXiv 2021

TL;DR

Researchers have developed SSDS (Sim2Real Small Defection Segmentation), a network that learns to identify tiny defects on surfaces like Printed Circuit Boards (PCBs) by focusing solely on the differences between a template and a target image. By training on simple, randomized simulations rather than expensive real-world data, SSDS achieves remarkable generalization, outperforming existing methods when faced with new backgrounds, lighting changes, and assembly errors.

What Problem Does This Paper Address?

In industrial automation, detecting small defects (like a missing component or a stray particle on a PCB) is a high-stakes task. Current deep learning approaches usually fall into two traps:

  1. Context Overfitting: Networks often "memorize" the background of their training data. If the lighting changes or a new PCB design is introduced, the model fails because the context has shifted.
  2. Data Scarcity: Collecting and labeling thousands of real-world images with tiny, varied defects is incredibly expensive and time-consuming.

Existing methods like simple image subtraction (XOR) are too sensitive to tiny misalignments, while generative models (like GANs) often lack the precision to find "unseen" random objects. The authors ask: Can we train a network once in a cheap simulation and have it work on any real-world PCB?

Fig. 1: Existing methods for defection segmentation either failed in dealing with lighting changes, e.g. template based XOR logical manipulator (violet box), or lack of general- izing ability, e.g. generative methods (orange box). These make them inapplicable in practical applications where both lighting and context keep changing. Our proposed method (blue box) specifically learns differences between images so that even when trained in simulation, it can still be applied in the real world.

Methods

The core philosophy of SSDS is "learning to differ." Instead of learning what a PCB looks like, it learns the mathematical nature of a discrepancy between two images.

  • Differentiable Phase Correlation (DPC): The system first aligns the "Defection-free Template" to the "Defected Source" image. It uses Fourier transforms to handle rotation, scale, and translation in a way that the network can backpropagate through.
  • Difference Learner ($N_d$): A U-Net-based backbone takes the aligned images and produces two intermediate outputs ($O_t$ and $O_s$).
  • Irrelevance Loss ($L_{irr}$): This is the "secret sauce." The authors leverage a property of phase correlation: if two images are completely unrelated, their phase correlation map shows a single peak at exactly 180°. By enforcing this loss, the network is forced to strip away the shared background context, leaving the defect in one output and nothing in the other.
  • Outlier Masking ($N_m$): A final layer filters out "noise" caused by imperfect pixel-wise alignment (e.g., a component slightly shifted during assembly) to ensure only true defects are segmented.
Fig. 2: Demonstration of the network structure for SSDS. Defection-free template is first transformed to be overall pose aligned with the defected source, leaving alone the pixel-wise error caused in practical applications. They are then concatenated to be one single tensor to be processed by the difference learning layer. The pose between intermediate template and source is then calculated and the result of which is further supervised by a “Irrelevant Loss” Lirr so that the two intermediate variables’ content is different and one of them contains the defections with noises. These intermediate variables are then processed by the outlier masking layer and are further supervised by the ground truth of defection.

Datasets

The authors introduced a new benchmark and a unique training strategy:

  • Simulation Training Set: Purely synthetic data consisting of random geometric shapes (circles, triangles, crosses) on black backgrounds. This forces the model to learn the logic of difference rather than the appearance of PCBs.
  • HiDefection:SIM: A dataset of real PCB backgrounds with simulated defects (random shapes and dropped electronic components).
  • HiDefection:REAL: The most challenging set, featuring real-world particles, actual PCB defects, varying lighting conditions, and intentional assembly misalignments.

Key Insights and Ideas

  • Context is a Distraction: By training on simple shapes, the network never learns to rely on PCB-specific features. This makes it "context-insensitive."
  • Self-Supervision via Phase Correlation: Using the 180-degree peak property of phase correlation as a loss function is a clever way to ensure the network actually separates the "defect" signal from the "background" noise without needing explicit labels for the intermediate steps.
  • Sim2Real works for Differences: While Sim2Real is often hard for object recognition (because simulations don't look "real" enough), it is highly effective for segmenting differences, as the mathematical concept of a "difference" is the same in simulation and reality.

Key Results

SSDS demonstrated superior generalization compared to baselines like GANomaly, SSIM-based autoencoders, and TDD-Net.

  • Generalization to Real Data: When trained only on simulation, SSDS achieved an Average Precision (AP) of 98.1% and a MaxF1 of 96.3% on the HiDefection:REAL dataset.
  • Robustness: Unlike baselines, which saw their performance crater when moving from simulation to real-world images (often dropping to 10-30% AP), SSDS remained stable.
  • Handling Lighting: SSDS successfully ignored global lighting changes that typically cause traditional subtraction methods to fail.
Fig. 5: Qualitative comparison of dynamic obstacle detection of baselines trained in simulation and HiDefection:REAL. Note that SSDS is only trained in simulation.

Limitations and Future Work

  • Small Defect Focus: The network is specifically designed for small defects (less than 1% of the image area). Its performance on large-scale structural changes or missing large components wasn't the primary focus.
  • Template Requirement: Like all template-based methods, it requires a "golden" defect-free image for comparison, which may not always be available in every manufacturing scenario.
  • Future Directions: The authors suggest this "learning to differ" approach could be extended to other domains, such as fingerprint detection in screen manufacturing or change detection in satellite imagery.

Summary updated

BibTeX
@misc{chen2021learn,
  author = {Zexi Chen and Zheyuan Huang and Yunkai Wang and Xuecheng Xu and Yue Wang and Rong Xiong},
  title = {{Learn to Differ: Sim2Real Small Defection Segmentation Network}},
  year = {2021},
  eprint = {2103.04297},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2103.04297},
}
Figure