## 1 Introduction  
Defect inspection is an indispensable process in the field of industrial automation. To identify these defect regions, the defect area, color variation, and texture complexity are important factors that can affect the accuracy of defect inspection. In recent years, due to the development of deep-learning technology, many deep-learning models for defect inspection have been proposed, mainly divided into supervised learning and unsupervised learning. Supervised defect-inspection methods can be categorized into bounding-box-based methods and pixel-based methods. The representative bounding-box-based methods are the YOLO series [1, 2, 3, 4]. For example, research in [5, 6, 7, 8, 9] used different versions of YOLO architectures to detect the defect regions and their experiments show that both of the classification and region locating are accurate. For the pixel-based method, SegNet [10]can segment the defect area precisely and distinguish the defect category. However, the computing efficiency is low. Mask R-CNN [11] technology combines both bounding-box-based and pixel-based methods. First, the defect region is located with the bounding box, and then the precise defect region is segmented with high computational efficiency. However, training a supervised model requires a large number of labeled defect images, and the data pre-processing will consume a lot of time and human resources. In addition, the collection of defect images faces two major difficulties [12; 13; 14]. First, it is difficult to collect enough defect patterns to have high data coverage for model training; second, because the occurrence of defects is unpredictable, it is difficult to determine whether the collected samples cover all defect patterns. These problems can cause missing detection or poor accuracy in defect inspection. Therefore, this paper focuses on unsupervised learning. Most of the unsupervised learning techniques use the Autoencoder architecture [15] shown in Figure 1 to learn from normal images. The general Autoencoder model only has the capability to reconstruct normal images. However, it can only slightly repair the texture or color on the defect region shown in Figure 2. Therefore, in addition to training the Autoencoder model, it is also necessary to perform model training through methods such as clustering of feature vectors (latent vectors), to improve the model's capability to repair the defect area. For the related methods that combine Autoencoder and enhanced defect-detection technologies, the works in [16; 17] train the VAE model [18; 19] with the KL-Divergence function [20] to make the distribution of latent vectors approach Gaussian distribution. Therefore, when the test image contains a defect region, the defect region can be repaired with a correct texture pattern. However, it is found in experiments that it is difficult to balance the Gaussian distribution parameters between the normal area reconstruction and the defect area repair. As an extension of VAE technology [21], GMVAE [22] technology produces a more obvious clustering effect on Latent vectors. Literature [12] proposed a defect image classification method by randomly selecting some images from the training dataset and generating feature vectors from the encoder as  
Figure 1: Structure of Autoencoder. Figure 2: (a) A test defect image. (b) Reconstructed image through general Autoencoder. the reference samples. The feature vectors of the test images are generated in the same way. The feature vectors of the reference sample and the test image are compared to confirm whether the test image is a defect image. This method simply judges whether the test image is a defect image, and does not discuss how to detect the defect region. The MS-FCAE [13] technology uses a multi-scale architecture to simultaneously extract features across the multi-scale feature maps. Furthermore, on each scale, the clustering algorithm [23] is applied to train the model to have a better defect repair capability.