###### Abstract  
Although deep learning has been proven to significantly outperform most traditional methods in the classification of large-scale balanced image datasets, collecting enough samples for defect classification is extremely time-consuming and costly. In this paper, we propose a lightweight defect classification method based on few-shot image generation and self-attention fused convolution features. We constructed a 4-class dataset using welding seam images collected from a solar cell module packaging production line. To address the issue of limited defect samples, especially for classes with less than 10 images, we implemented two strategies. Geometric enhancement techniques were first used to extend the defective images. Secondly, multi-scale feature fusion Generative Adversarial Networks (GANs) were utilized to further enhance the dataset. We then performed the feature-level fusion of convolution neural networks and self-attention networks, achieving a classification accuracy of 98.19%. Our experimental results demonstrate that the proposed model performs well in small sample defect classification tasks. And, it can be effectively applied to product quality inspection tasks in industrial production lines. defect classification; few-shot generation; attention mechanism; feature fusion +
Footnote †: journal: Medical Image Generation and Self-Attention Fusion  
[PERSON] et al. [11] improved the classification accuracy of the VGGNet network by approximately 3% by replacing the B and G channels of X-ray weld seam images with binary images obtained from Canny edge detection and adaptive Gaussian thresholding. [PERSON] et al. [12] generated different minority class samples for resistance spot welding (RSW) images using balancing augmentation GAN (BAGAN) and balancing augmentation GAN with gradient penalty (BAGAN-GP), and trained ResNet50 to classify the types of RSW defects. [PERSON] et al. [13] divided the crack images in gusset plate welded joints of steel bridges into 192 small images \(64\times 64\) in size from a larger image \(1024\times 768\) in size, increasing the amount of training data while also reducing the computation related to processing large images by the network. They fine-tuned the VGG16 combined with data augmentation and achieved good detection performance. [PERSON] et al. [14] proposed a method for synthesizing X-ray data for aerospace welds. They first modeled the component using CAD and then used ray tracing simulation software to generate X-rays to obtain simulated X-ray images. Next, they added noise masks from experimental measurement images to the simulated images and finally used Mask RCNN for defect segmentation. [PERSON] [15] used three types of resampling methods: random over-sampling (ROS), random under-sampling (RUS), and the synthetic minority over-sampling technique (SMOTE)) for X-ray weld images. And, they extracted three features: statistical features based on the gray-level co-occurrence matrix (GLCM), the histogram of oriented gradients (HOG), and the stacked sparse autoencoder (SSAE). The experimental results showed that the model trained with the features based on SSAE and SMOTE resampling achieved the highest accuracy (97.2%). Previous studies have achieved good results, but there is still a lack of research on defect classification when there is an extreme lack of defect samples. One solution to the problem of insufficient defect samples is to perform simple geometric transformations on images or to generate virtual defect samples using certain algorithms. Since Generative Adversarial Networks (GANs) were introduced for image generation in 2014 by [PERSON] et al. [16], scholars have conducted extensive research. The deep convolutional GAN (DCGAN) [17] introduces convolution to the GAN. The conditional GAN (CGAN) [18] was proposed to add auxiliary information such as class labels to the generators. The auxiliary classifier GAN (ACGAN) [19] adds class information to the discriminator. The Wasserstein GAN (WGAN) [20] is trained faster.