Supplementary data
Description
Automated optical inspection must localize small defects despite textured backgrounds, limited defective samples, and changes in illumination or focus. This study presents an edge-conditioned lightweight U-Net that concatenates a fixed Sobel gradient-magnitude channel with the raw grayscale image before encoder-decoder segmentation. A fully disclosed procedural benchmark of 3,000 images was generated across four surface families and four defect morphologies (scratch, pit, contamination, and crack). The benchmark comprised 1,500 training, 300 validation, 600 in-domain test, and 600 domain-shift images. The domain-shift set increased illumination gradients, blur, noise, gamma variation, and reduced defect contrast. On the held-out in-domain set, the proposed model achieved a Dice score of 0.819, intersection-over-union of 0.694, precision of 0.828, recall of 0.811, and pixel AUROC of 0.985. The plain U-Net achieved 0.791 Dice and 0.654 IoU. Paired image-level bootstrap resampling estimated the Dice improvement at 0.029 (95% confidence interval: 0.021-0.037). Under domain shift, Dice increased from 0.657 to 0.683, with a paired improvement confidence interval of 0.013-0.041. The edge-conditioned model used 30,505 trainable parameters and required approximately 1.15 ms per image on a five-thread Intel Xeon CPU. These results support edge conditioning as a low-cost inductive bias for compact defect segmentation. Because all images are synthetic, the work is a controlled method-validation study rather than evidence of production-line performance; validation on public and factory datasets is required before deployment.