# Assembly Quality Detection Based on Class-Imbalanced Semi-Supervised Learning
## 1 Introduction  
Screw fasteners are simple in construction and easy to operate. They are widely used in the mechanical structure as the crucial part of large equipment, such as aero-engine, high-speed railways, production machinery, wind turbines, air conditioning systems, and elevator cranes. The assembly quality should be carefully inspected because it determines the mechanical properties and safety of products. Screw-gasket-seal is a typical connector assembly structure. The gasket is used to protect the surface of the connector from screw abrasion. The seal can pass through several structures to form a closed loop, preventing the structure from being loose. The images of qualified assembly samples are shown in Figure 1(a1-a4), with a lead threading through two parallel holes of the hexagon screw and a gasket placed between the two mating surfaces to increase friction. Unqualified assemblies (Figure 1(b1-b4)) without gaskets or lead seals have hidden safety hazards, which may cause inestimable loss of life and property. Therefore, it is crucial to detect whether such assemblies are qualified effectively. With the advent of industry 4.0 and the continuous development of machine learning technology, the manufacturing industry has an increasing demand for automatic and intelligent production [1, 2]. Both industrial practitioners and academic researchers are exploring intelligent detection methods to replace manual inspection. Common noncontact inspection methods include 3D scanning [3, 4, 5] and machine vision. The 3D scanning methods can provide the precision position of the component to assist the industrial robots. Machine vision detection methods use the camera to capture images from production lines and then designalgorithms to complete the extraction and analysis of image information. It can provide objective, high-speed measurement and good reliability with a simple system and strong adaptability. Before the rise of deep learning algorithms, there have been many studies based on low-level visual features. For example, in [6], Hoff transform was applied to the bolt-loosening detection in the connection of wind turbine tower segments; [PERSON] et al. [2] used the gradient coded co-occurrence matrix (GCCM) to inspect the missing of bogie block key on freight cars. Due to its data-driven nature, the fast-developing deep learning algorithms can extract knowledge from historical data, reducing the dependence on expert domain knowledge and avoiding artificial design of visual features. They have been widely used in the detection of key components of high-speed trains [7; 8; 9; 10], fault diagnosis [11; 12; 13], high-voltage transmission line detection [14; 15; 16], and other industrial applications. The high generalization performance of deep learning relies on a large amount of labeled data. However, massive manpower and repeated labor will be needed to collect and annotate tens of thousands of data, and the sample number of the unqualified class is often low, resulting in the class imbalance of the training set. These factors will significantly affect the neural network model. Few-shot learning, generative methods, and semi-supervised learning have been presented to alleviate these problems. Few-shot learning is one method that fully utilizes a small number of labeled data [17]. It is suitable for tasks where a variety of prior knowledge is available, including supervised data from other domains and modalities. [PERSON] et al. [11] used a classification algorithm based on the similarity of sample pairs in intelligent bearing fault diagnosis, which included feature learning and metric learning modules. The feature learning module used twin neural networks to extract features from the sample pair separately, and the metric learning module was used to predict the similarity of the sample pair. The classification was conducted according to the similarity between the test sample and the labeled sample.