# A Survey on Surface Defect Inspection Based on Generative Models in Manufacturing
## 3 Defect Inspection Based on Generative Models
### Defect Inspection Based on VAEs  
VAEs have been widely used for image generation of surface defect inspection [32]. A simple way to use VAEs is for data augmentation, and then the generated samples are fed into a classifier or a detector. For instance, [PERSON] et al. [56] proposed the convolutional AE (CAE) for generating fabric defect samples and a defect detection algorithm based on Fourier convolution. [PERSON] et al. [57] designed the AE5-SSIM to reconstruct finfoil images. This model is based on structural similarity reconstruction AE, whose encoder and decoder networks have five sub-encoder blocks and five sub-decoder blocks, respectively. [PERSON] et al. [58] introduced an auto-encoder to extract useful information from unlabeled data and then performed semantic anomaly detection on the samples. [PERSON] et al. [59] reconstructed images by a VAE model and analyzed the detection performance using various image gradient filters on the surface of wooden broads. [PERSON] et al. [60] proposed a lightweight surface defect detection network based on the CAE to solve the problem of shortage of defective samples in the industry. The data augmentation strategy is simple but limited application due to the generation and representation processes being separate. Two different learning stages may result in differences in feature learning and waste the opportunity to learn the correlation between them. Therefore, more researchers choose to establish defect inspection systems in end-to-end learning schemes. For VAE-based defect methods, [PERSON] et al. [61] proposed an attention-based vector quantization VAE (AVQ-VAE) for detecting defects in colored patterned fabrics, which adopts autoregressive modeling of discrete variables and attention mechanisms to enhance the detection performance. [PERSON] et al. [62] presented a multi-scale U-shaped denoising CAE (MSUDCAE) model for fabric defect detection, which was trained on defect-free samples and calculated residual maps between the original image and the corresponding reconstructed image to improve detection results. [PERSON] et al. [63] presented an unsupervised detection method based on a dual-Siamese network. This framework tackled the problems that persist in the discriminative embedding-based methods and achieved state-of-the-art anomaly inspection performance on four public defect datasets. [PERSON] et al. [64] proposed a two-stage architecture including the railway cropping network and defects removal VAE (DR-VAE). The former extracted railroad surface and the latter carried out image reconstruction and defect detection on railway surfaces. [PERSON] et al. [65] introduced a semantic label-enhanced (LE) VAE for generating defect examples and exploited semantic label information to improve classification performance. [PERSON] et al. [66] proposed a sample-less anomaly detection strategy called FastRecon that works in low-data environments and is able to generalize across products at no additional cost. [PERSON] et al. [67] presented an introspective self-supervised reconstruction model (ISRM), which only used normal samples for training and integrated self-supervised learning into an introspective auto encoder to address the problems of sample imbalance and complex background interference. [PERSON] et al. [68] established the Fs-CAE network by adding frequency shift operation based on the CAE network. The method only needs samples without defects for model training and does not require labels, thus reducing manual labeling time. [PERSON] et al. [69] proposed an unsupervised defect detection method based on the Vision Transformer (ViT), which utilizes a transformer encoder to capture global contextual information, thereby enhancing detailed image understanding and detection performance. Table 2 presents the key features of the selected papers that are based on VAEs for defect inspection. Due to the lack of defect images and manual annotations, these studies had to perform defect inspection in the modes of unsupervised learning or weakly-supervised learning.