###### Abstract  
Deep learning provides new ways for defect detection in automatic optical inspections (AOI). However, the existing deep learning methods require thousands of images of defects to be used for training the algorithms. It limits the usability of these approaches in manufacturing, due to lack of images of defects before the actual manufacturing starts. In contrast, we propose to train a defect detection unsupervised deep learning model, using a much smaller number of images without defects. We propose an unsupervised deep learning model, based on transfer learning, that extracts typical semantic patterns from defect-free samples (one-class training). The model is built upon a pre-trained VGG16 model. It is further trained on custom datasets with different sizes of possible defects (printed circuit boards and soldered joints) using only small number of normal samples. We have found that the defect detection can be performed very well on a smooth background; however, in cases where the defect manifests as a change of texture, the detection can be less accurate. The proposed study uses deep learning self-supervised approach to identify if the sample under analysis contains any deviations (with types not defined in advance) from normal design. The method would improve the robustness of the AOI process to detect defects. defect detection; image analysis; machine learning; transfer learning; automatic optical inspection; unsupervised learning +
Footnote †: journal:  
0000-0001-149-322-2281][PERSON] 0000-0002-1989-2281][PERSON] 0000-0001-149-322-2281][PERSON] 0000-0002-1989-2281][PERSON] 0000-0002-1989-2281][PERSON]. [PERSON], [PERSON]. Historically, AOI for PCB started with the following ideas: (a) reference approach (that compares a template with an input image), (b) reference free approach, that extracts distinctive features without any template image used, and (c) hybrid methods as combination of (a) and (b) [7]. Machine learning methods (e.g., [8; 9]) were later added to the group (c) [3]. In [8], robust features were extracted to learn the defect pattern and calculate random forest; feature densities are computed by using weighted kernel density estimation, which in turn localizes the defect. In [9], a non-pattern feature-point matching AOI method was proposed for the inspection of wafer, TFT-LCD and PCB images. We would like to highlight that the purpose of most of the existing ML methods is classification and/or identification in dataset with high inter-class variability, but in the case of PCBs, all input images have rather small variability of image contents. They are almost identical and essentially belong to the same class, so the problem is to find small variations caused by manufacturing defects. Define, measure, analyze, improve, and control (DMAIC) [10] is a strategy of Six Sigma, which is used in many industries, e.g., health care, market research, service industry, manufacturing, etc. Implementation of DMAIC aims to ensure minimal defects in the industrial process (less than 4 defects per million). Under these conditions, to get even few defective cases is rather hard due to the rarity of defect samples. The task of collecting a large number of comprehensive samples of defects of all possible categories to be used for training of supervised learning model is rather unrealistic. For successful supervised learning, the number of samples of different classes should not only be large but also balanced. We may not know in advance about all possible classes of defects, and the identified classes might not have a lot of manifestations to be enough for training. To cope with such a problem, artificially fabricated samples are often used [6], in which case, the realism and relevancy of the artificial data becomes a serious issue, since the distribution and properties of such data could vary from real world samples. Usually, the defects are grouped into fixed classes, according to the domain area experience, as well as based on hand-made features.