Image defect detection method based on memory tree structure
By constructing a memory tree structure encoding network, a latent vector decoding network, and a feature reconstruction network, the problems of abnormal information inflow and feature loss are solved, achieving efficient image defect detection and improving image reconstruction effect and detection performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA UNIV OF PETROLEUM (EAST CHINA)
- Filing Date
- 2024-09-05
- Publication Date
- 2026-06-05
Smart Images

Figure CN119090854B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image defect detection methods, and relates to the technical fields of memory modules, image visual processing, and computer vision industrial defect detection. Background Technology
[0002] With the development of the industrial and computer fields, image detection technology in the industrial sector has gradually matured. Image defect detection is a computer vision task that identifies image defects among a large number of normal images. Image defect detection mainly includes three levels: whether the image has defects, where the defects are located, and the size of the defects. Current mainstream image defect detection techniques include two categories: image restoration and image reconstruction. Image restoration involves simulating defects in a network using noise as input, transforming the image defect detection task into an image denoising task, with image denoising as the goal of image defect detection. However, recent studies have shown that the ability of noise to simulate defects is limited, thus restricting the further development of image restoration methods. Image reconstruction-based methods use learning the behavior patterns of normal images as the training objective, avoiding interference from abnormal information. Therefore, in image defect detection, even if a defective image is input, it can still be reconstructed into a normal image. The method discriminates between the pixels of the input and output images to determine whether the image contains defects. If the reconstruction effect is good, it can even determine the location and size of the image defects, completing a multi-level task of image defect detection.
[0003] However, current methods based on reconstructed image generation face two major problems: First, anomalous information easily flows into the image's feature space, making it difficult to restore defective images to their normality. Pidhorskyi, Perera, and others have constrained the latent space in an attempt to suppress the expression of anomalous information; however, the powerful generalization ability of autoencoders makes strict spatial constraints difficult to achieve. Subsequently, MemoryAE proposed a memory mechanism, attempting to reorganize image features by establishing a memory pool. This type of method integrates the memory mechanism into anomaly detection, restricting features in the early stages of feature mapping. Second, intra-block features and inter-block relationships are lost. To address this, GANomaly attempts to encode the reconstructed image to achieve feature-assisted image reconstruction. Zhou et al. introduced a pre-trained module to strengthen the correlation between input data and the structural features of the image, attempting to capture the structural information of the image. Summary of the Invention
[0004] The purpose of this invention is to address the problem in image reconstruction tasks where anomalous information easily flows into the image's feature space, leading to difficulties in restoring the normality of defective images and the loss of intra-block features and inter-block relationships. By solving these two problems, the invention aims to achieve efficient representation of normal information and connection between intra-block information and inter-block relationships, thereby enhancing the reconstruction effect of the reconstructed image.
[0005] The technical solution adopted by the present invention to solve the above-mentioned technical problems is as follows:
[0006] S1. Construct a memory tree structure coding network for image coding representation and latent vector generation;
[0007] S2. Construct a latent vector decoding network for latent vector decoding, image information collection during reconstruction, and reconstructed image generation;
[0008] S3. Construct a feature reconstruction network to fuse intra-block and inter-block information in the reconstructed image;
[0009] S4. Combine the memory tree structure encoding network in S1, the latent vector decoding network in S2, and the feature reconstruction network in S3 to construct an image defect detection method architecture based on memory tree structure;
[0010] S5. Training and testing of defect images for an image defect detection method architecture based on memory tree structure.
[0011] 1. The image defect detection method based on memory tree structure according to claim 1, characterized in that the specific process of S1 is as follows:
[0012] The memory tree structure encoding network uses a four-layer convolutional block structure to initially compress the input image. Through a combination of convolution and the LeakyReLU activation function, the input image with 3 channels is compressed into a preliminary compressed representation with feature dimensions H×W×C, denoted as Q. The memory tree structure contains PO memory pools, each with IT memory entries. Reading the memory entries in the memory pools using Q in a tree structure generates a post-compressed representation for each memory pool. The memory pools are updated based on the previous query after each read. Since PO memory pools are used, PO post-compressed representations rooted at Q are generated. The memory tree unfolds as follows: first, using Q as the reading unit, memory pools MP1 and MP2 are used to obtain a memory tree with a height of 2. and .
[0013]
[0014] Subsequently, and These two branch nodes, acting as reading units, respectively read the two post-representations of height 3 from the memory tree structure through the corresponding memory pools:
[0015]
[0016] Then, , , , As a unit of retrieval, the leaf nodes at the end of the memory tree structure are queried through four different memory pools:
[0017]
[0018] Since the reading methods for the PO memory pools are consistent, only the inputs differ, the following section will use Q as an example to detail the reading and updating methods in the memory tree structure.
[0019] Reading: Before reading, Q must first be split along the channel direction, changing it from its original size H×W×C to K=H×W C-dimensional vectors, each vector denoted as query. k During the reading process, each query in Q... k Read IT memory items ITEMS from memory pool MP1 sequentially. Calculate the correlation between Q and ITEMS to obtain a correlation map of size IT×K, and then apply the softmax function to convert the correlation values into matching probabilities.
[0020]
[0021] Q is then re-represented using the matching probability as weighting coefficients; specifically, each vector is transformed into:
[0022]
[0023] According to formula (12), each query k All of them are re-represented by the IT memory items ITEMS in memory pool MP1, thus completing the Q read operation.
[0024] Update: The matching probability calculated using softmax can be used to measure the query. k The relevance of each memory item to the others is used to rank them, and an index is created to indicate this. Then, the query closest to each memory item is selected. k Update each memory entry. In the update operation, continue using the previous correlation plot of size IT×K and normalize it in the horizontal direction.
[0025]
[0026] Finally, the initial compressed representation Q and the PO post-compressed representations are fused by convolution, and the fusion result is a latent vector z with a dimension of 100, which completes the memory tree structure encoding of the input image.
[0027] 2. The image defect detection method based on memory tree structure according to claim 1, wherein the specific process of S2 is as follows:
[0028] A latent vector decoding network was constructed to decode the latent vectors compressed by the memory tree structure encoder into reconstructed images. At the same time, the reconstruction information of the vector decoding process was collected for the discrimination of the discriminator.
[0029] First, the latent vector z is input into the latent vector decoding network. After passing through four stacked deconvolutional upsampling blocks, the latent vector z is decoded into a reconstructed image. During the decoding process, the decoding network generates decoding features of 256×4×4, 128×8×8, and 64×16×16 respectively in the stacked deconvolutional blocks, denoted as Decoder. 256 Decoder 128 Decoder 64 .
[0030]
[0031] Subsequently, It is fed into the fourth deconvolution block, where the latent vector z is finally reconstructed into the reconstructed image.
[0032]
[0033] In a latent vector decoding network, the decoder 256 Decoder 128 Decoder 64 The features will be collected and stored separately to complete feature alignment, and the decoded features will be uniformly adjusted to a size of 64×16×16. Originally, the decoder of this size... 64 No adjustments will be made.
[0034]
[0035] After aligning the features , , The corresponding positions of the discriminator are spliced along the channel direction and integrated into the discriminator network, enabling the discriminator to learn the corresponding reconstruction process information.
[0036] 3. The image defect detection method based on memory tree structure according to claim 1, wherein the specific process of S3 is as follows:
[0037] After constructing the S1 memory tree structure encoding network and the S2 latent vector decoding network, a feature reconstruction network is built to extract features from the reconstructed image. Referring to the latent vector dimension, the intra-block and inter-block information of the reconstructed image is fused to encode the reconstructed image.
[0038] The feature reconstruction network employs a dual-path feature extraction method to extract features from the reconstructed image Recons. One path uses traditional convolutional blocks to divide the reconstructed image Recons into 3×3 image blocks and models the information within each block, denoted as . The other feature is the inter-block information feature extracted by the Hybrid Convolutional Block (MCB), denoted as... The hybrid convolutional block mainly contains three layers of features used to model the Recons of the reconstructed image: pooling and scaling information. Used to reduce invalid information in image patches during reconstruction, 1×1 convolution information Used to fuse information from different channels of the reconstructed image, 3×3 dilated convolution information This is used to model the relationships between different image patches. Finally, the three layers of features from the hybrid convolutional block are fused through convolution, as follows:
[0039]
[0040] After the intra-block features of the traditional convolutional block and the inter-block features of the hybrid convolutional block are extracted, the dual-path features are fused to generate the feature reconstruction result. .
[0041] 4. The image defect detection method based on memory tree structure according to claim 1, wherein the specific process of step S4 is as follows:
[0042] S1, S2, and S3 respectively construct a memory tree structure encoding network, a latent vector decoding network, and a feature reconstruction network. Combining these three network modules, an image defect detection method based on a memory tree structure is constructed.
[0043] This invention uses a GAN as its basic architecture. A memory tree structure encoding network and a latent vector decoding network jointly construct a generator network to perform compressed encoding and decoding of the input image, restoring its normal shape. A feature reconstruction network is used to reconstruct compressed features, serving as a feature supplement to the generator. Simultaneously, a convolutional discriminator is constructed to distinguish the generation patterns of the input image and the memory tree structure generator network, promoting network training.
[0044] Specifically, the training of image defect detection methods based on memory tree structures mainly includes three loss functions.
[0045] Feature matching loss: Completes adversarial training between the generator G and the discriminator D, where x is the input image. The input image x is mapped to an intermediate feature representation of the discriminator.
[0046]
[0047] Generator-based image reconstruction loss: Captures contextual information of the input image to complete its reconstruction.
[0048]
[0049] Feature Reconstruction Loss: Captures the compressed features z of the input image and the compressed features of the reconstructed image. The contextual information is used to optimize the training of the network using feature distance.
[0050]
[0051] Finally, the training objective of the image defect detection method based on the memory tree structure is defined, and each loss function is adjusted by a control factor w:
[0052]
[0053] 5. The image defect detection method based on memory tree structure according to claim 1, wherein the specific process of step S5 is as follows:
[0054] The training method for the image defect detection method based on memory tree structure is as follows:
[0055] This method is an unsupervised defect detection approach in image defect detection, using only normal images as input during the training phase. The input image dimension is set to 32×32. The input image is compressed into a 100-dimensional latent vector by a memory tree-structured encoder network. This latent vector is then fed into a latent vector decoding network for decoding, restoring the 100-dimensional latent vector to a 32×32 reconstructed image. The 32×32 reconstructed image is then fed into a feature reconstruction network for further compression, also resulting in a 100-dimensional image. During training, the input image and the reconstructed image are alternately used by the discriminator, thereby promoting the generator to produce more realistic images. PyTorch 1.0 is used for network construction and implementation, and the Adam optimizer is used for training. The main parameter settings during training are as follows:
[0056] The learning rate is set to 0.002; the training batch size is set to 15; the latent vector dimension is set to 100; the training batch size is set to 64; the number of memory pools is set to 10; the number of memory items in the memory pool is set to 10; and the weight coefficients of the training objective are set to... The primary optimization objective is set to 50, while all other coefficients are set to 1.
[0057] Compared with existing technologies, the beneficial effects of this invention are:
[0058] 1. This invention proposes a novel image defect detection method based on a memory tree structure. The network adopts a memory tree structure and utilizes multi-level memory compression features to fuse input information, thereby realizing multi-level prototype mode to re-represent the image and restricting the inflow of abnormal information.
[0059] 2. This invention proposes a latent vector decoding network and a feature reconstruction network. The former enhances the discriminator's discrimination ability by decoding latent vectors and collecting hierarchical information of the image decoding process; the latter assists in image reconstruction by fusing intra-block and inter-block information of the reconstructed image. Attached Figure Description
[0060] Figure 1 This is a schematic diagram of an image defect detection method based on a memory tree structure.
[0061] Figure 2 and Figure 3 This is a comparison chart of the results of multiple anomaly detection methods based on memory tree structure for image defect detection.
[0062] Figure 4 This is a comparison chart showing the results of image defect detection using an image defect detection method based on a memory tree structure.
[0063] Figure 5 This is a visualization of the image defect detection results of the image defect detection method based on the memory tree structure. Detailed Implementation
[0064] The accompanying drawings are for illustrative purposes only and should not be construed as limiting the scope of this patent.
[0065] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0066] Figure 1 This is a schematic diagram of an image defect detection method based on a memory tree structure. Figure 1 As shown, the entire structure consists of four parts: a memory tree structure encoder network, a latent vector decoding network, a feature reconstruction network, and a discriminator network.
[0067] exist Figure 1In this process, the input image is first fed into a memory tree structure encoder network. After passing through a four-layer convolutional block structure, the input image is initially compressed into Q. Then, Q is used to read the memory entries in the memory pool in a tree structure, generating a post-compressed representation of the corresponding memory pool. Simultaneously, the memory pool is updated based on the previous query after each read. The unfolding method of the memory tree is as follows: first, using Q as the reading unit, the memory pool MP1 and MP2 are used to obtain the memory tree with a height of 2. and .
[0068]
[0069] Subsequently, and These two branch nodes, acting as reading units, respectively read the two post-representations of height 3 from the memory tree structure through the corresponding memory pools:
[0070]
[0071] Then, , , , As a unit of retrieval, the leaf nodes at the end of the memory tree structure are queried through four different memory pools:
[0072]
[0073] Since the reading methods for the PO memory pools are consistent, only the inputs differ, the following section will use Q as an example to detail the reading and updating methods in the memory tree structure.
[0074] Reading: Before reading, Q must first be split along the channel direction, changing it from its original size H×W×C to K=H×W C-dimensional vectors, each vector denoted as query. k During the reading process, each query in Q... k Read IT memory items ITEMS from memory pool MP1 sequentially. Calculate the correlation between Q and ITEMS to obtain a correlation map of size IT×K, and then apply the softmax function to convert the correlation values into matching probabilities.
[0075]
[0076] Q is then re-represented using the matching probability as weighting coefficients; specifically, each vector is transformed into:
[0077]
[0078] According to formula (12), each query k All of them are re-represented by the IT memory items ITEMS in memory pool MP1, thus completing the Q read operation.
[0079] Update: The matching probability calculated using softmax can be used to measure the query. k The relevance of each memory item to the others is used to rank them, and an index is created to indicate this. Then, the query closest to each memory item is selected. k Update each memory entry. In the update operation, continue using the previous correlation plot of size IT×K and normalize it in the horizontal direction.
[0080]
[0081] Finally, the initial compressed representation Q and the PO post-compressed representations are fused by convolution, and the fusion result is a latent vector z with a dimension of 100, which completes the memory tree structure encoding of the input image.
[0082] The latent vector decoding network is used to decode the latent vectors compressed by the memory tree structure encoder into a reconstructed image, and at the same time collect the reconstruction information of the vector decoding process for the discriminator.
[0083] First, the latent vector z is input into the latent vector decoding network. After passing through four stacked deconvolutional upsampling blocks, the latent vector z is decoded into a reconstructed image. During the decoding process, the decoding network generates decoding features of 256×4×4, 128×8×8, and 64×16×16 respectively in the stacked deconvolutional blocks, denoted as Decoder. 256 Decoder 128 Decoder 64 .
[0084]
[0085] Subsequently, It is fed into the fourth deconvolution block, where the latent vector z is finally reconstructed into the reconstructed image.
[0086]
[0087] In a latent vector decoding network, the decoder 256 Decoder 128 Decoder 64 The features will be collected and stored separately to complete feature alignment, and the decoded features will be uniformly adjusted to a size of 64×16×16. Originally, the decoder of this size... 64 No adjustments will be made.
[0088]
[0089] After aligning the features , , The corresponding positions of the discriminator are spliced along the channel direction and integrated into the discriminator network, enabling the discriminator to learn the corresponding reconstruction process information.
[0090] After constructing the S1 memory tree structure encoding network and the S2 latent vector decoding network, a feature reconstruction network is built to extract features from the reconstructed image. Referring to the latent vector dimension, the intra-block and inter-block information of the reconstructed image is fused to encode the reconstructed image.
[0091] The feature reconstruction network employs a dual-path feature extraction method to extract features from the reconstructed image Recons. One path uses traditional convolutional blocks to divide the reconstructed image Recons into 3×3 image blocks and models the information within each block, denoted as . The other feature is the inter-block information feature extracted by the Hybrid Convolutional Block (MCB), denoted as... The hybrid convolutional block mainly contains three layers of features used to model the Recons of the reconstructed image: pooling and scaling information. Used to reduce invalid information in image patches during reconstruction, 1×1 convolution information Used to fuse information from different channels of the reconstructed image, 3×3 dilated convolution information This is used to model the relationships between different image patches. Finally, the three layers of features from the hybrid convolutional block are fused through convolution, as follows:
[0092]
[0093] After the intra-block features of the traditional convolutional block and the inter-block features of the hybrid convolutional block are extracted, the dual-path features are fused to generate the feature reconstruction result. .
[0094] Finally, a discriminator with a convolutional structure was constructed to distinguish the generation patterns of the input image and the memory tree structure generation network, thereby promoting network training.
[0095] Figure 2 and Figure 3 This is a comparison chart of the results of multiple anomaly detection methods based on memory tree structure for image defect detection. Figure 2 This demonstrates the performance of an image defect detection method based on a memory tree structure on the MNIST dataset for detecting multiple anomalies. Figure 3The results demonstrate the effectiveness of this method in multi-class anomaly detection on the CIFAR10 dataset. As can be seen from the figures, this invention achieves significant improvements over current state-of-the-art methods, both in terms of overall performance and the results for each individual class.
[0096] Figure 4 This image comparison chart shows the results of the image defect detection method based on the memory tree structure. Using the MVTec AD dataset, which contains images of 5 texture classes and 10 target classes, the comparison with current state-of-the-art methods demonstrates that this invention surpasses current state-of-the-art methods in both texture and target class overall results.
[0097] Figure 5 This image visualization shows the results of an image defect detection method based on a memory tree structure. Six classes were selected for visualization. The defects on the left are highlighted in boxes, and the reconstruction of these defects by this invention is shown on the right. Figure 5 As can be seen, this invention can repair image defect areas and achieve image defect detection.
[0098] This invention proposes an image defect detection method based on a memory tree structure, which consists of four parts: a memory tree structure encoding network, a latent vector decoding network, a feature reconstruction network, and a discriminator network. The memory tree structure encoding network utilizes the characteristics of the tree structure to control anomaly information, achieving high-quality input image feature mapping. The latent vector decoding network collects and aligns hierarchical features during the reconstruction process and transfers them to the discriminator network for inter-module information flow. The feature reconstruction network focuses on enhancing the fusion of intra-block and inter-block information, using feature comparison to assist image reconstruction, thereby enhancing the robustness of image reconstruction, improving the image reconstruction effect, and ultimately improving the efficiency and quality of image defect detection. Furthermore, this invention has been validated on multiple types of anomaly detection and image defect detection data, demonstrating significant advantages over current state-of-the-art methods.
[0099] Finally, the details of the above examples of the present invention are merely illustrative of the invention. Any modifications, improvements, and substitutions to the above embodiments by those skilled in the art should be included within the scope of protection of the claims of the present invention.
Claims
1. An image defect detection method based on a memory tree structure, characterized in that, The method includes the following steps: S1. Construct a memory tree structure coding network for image encoding representation and latent vector generation. The memory tree structure coding network uses a four-layer convolutional block structure to initially compress the input image. Through a combination of convolution and LeakyReLU activation functions, the input image with 3 channels is compressed into an initial compressed representation of the input image, with a feature dimension of H×W×C, denoted as Q. The memory tree structure contains PO memory pools, each with IT memory items. The memory items in the memory pools are read in a tree structure using Q to generate the corresponding post-compressed representation of the memory pool. The memory pools are updated according to the previous query after each reading. Since PO memory pools are set, PO post-compressed representations with Q as the root node are generated. S2. Construct a latent vector decoding network to decode the latent vectors compressed by the memory tree structure encoder into a reconstructed image, and collect the reconstruction information of the vector decoding process for the discriminator's discrimination. S3. After building the S1 memory tree structure encoding network and the S2 latent vector decoding network, a feature reconstruction network is constructed for feature extraction of the reconstructed image. Referring to the latent vector dimension, the intra-block and inter-block information of the reconstructed image is fused to encode the reconstructed image. S4. Combine the memory tree structure encoding network in S1, the latent vector decoding network in S2, and the feature reconstruction network in S3 to construct an image defect detection method architecture based on memory tree structure; S5. Training and testing of defect images for an image defect detection method architecture based on memory tree structure.
2. The image defect detection method based on memory tree structure according to claim 1, characterized in that, The specific process of S1 is as follows: The memory tree is expanded as follows: First, using Q as the reading unit, the memory tree with a height of 2 is obtained by reading through memory pools MP1 and MP2. and ; Subsequently, and These two branch nodes, acting as reading units, respectively read the two post-representations of height 3 from the memory tree structure through the corresponding memory pools: Then, , , , As a unit of reading, the memory leaf nodes at the end of the memory tree structure are queried through four different memory pools: Since the reading methods for the PO memory pools are consistent, only the inputs differ, the following section will use Q as an example to detail the reading and updating methods in the memory tree structure. Reading: Before reading, Q must first be split along the channel direction, changing it from its original size H×W×C to K=H×W C-dimensional vectors, each vector denoted as query. k During the reading process, each query in Q k Read IT memory items ITEMS from memory pool MP1 sequentially; obtain a correlation map of size IT×K by calculating the correlation between Q and ITEMS, and then apply the softmax function to convert the correlation value into a matching probability; Q is then re-represented using the matching probability as weighting coefficients; specifically, each vector is transformed into: According to formula (12), each query k All of them are re-represented by the IT memory items ITEMS in memory pool MP1. Also known as New_query k This completes the Q read operation; Update: The matching probability calculated using softmax is used to measure the New_query. k The degree of relevance to all ITEMS items, and based on the degree of relevance, all New_queries associated with the ITEMS item. k Sort and create an index. it To give instructions; then select the New_query that is closest to each memory item. k Update each memory item; during the update operation, continue to use the previous correlation graph of size IT×K and normalize it in the horizontal direction; Finally, the initial compressed representation Q and the PO post-compressed representations are fused by convolution, and the fusion result is a latent vector z with a dimension of 100, which completes the memory tree structure encoding of the input image.
3. The image defect detection method based on memory tree structure according to claim 1, characterized in that, The specific process of S2 is as follows: First, the latent vector z is input into the latent vector decoding network. After passing through four stacked deconvolutional upsampling blocks, the latent vector z is decoded into a reconstructed image. During the decoding process, the decoding network generates decoding features of 256×4×4, 128×8×8, and 64×16×16 respectively in the stacked deconvolutional blocks, denoted as Decoder. 256 Decoder 128 Decoder 64 ; Subsequently, It is fed into the fourth deconvolution block, where the latent vector z is finally reconstructed into the reconstructed image; In a latent vector decoding network, the decoder 256 Decoder 128 Decoder 64 The features will be collected and stored separately to complete feature alignment, and the decoded features will be uniformly adjusted to a size of 64×16×16. Originally, the decoder of this size... 64 No adjustments will be made. After aligning the features , , The corresponding positions of the discriminator are spliced along the channel direction and integrated into the discriminator network, enabling the discriminator to learn the corresponding reconstruction process information.
4. The image defect detection method based on memory tree structure according to claim 1, characterized in that, The specific process of S3 is as follows: The feature reconstruction network uses a dual-path feature extraction method to extract features from the reconstructed image Recons. One approach uses traditional convolutional blocks to divide the reconstructed image (Recons) into 3×3 image blocks, and models the information within each block, denoted as . The other feature is the inter-block information feature extracted by the hybrid convolutional block (MCB), denoted as... The hybrid convolutional block mainly contains three layers of features used to model the Recons of the reconstructed image: pooling and scaling information. Used to reduce invalid information in image patches during image reconstruction, 1×1 convolution information Used to fuse information from different channels of the reconstructed image, 3×3 dilated convolution information This is used to model the relationships between different image patches; finally, the three layers of features of the mixed convolutional block are fused through convolution, and the fusion method is as follows: After the intra-block features of the traditional convolutional block and the inter-block features of the hybrid convolutional block are extracted, the dual-path features are fused to generate the feature reconstruction result. .
5. The image defect detection method based on memory tree structure according to claim 1, characterized in that, The specific process of S4 is as follows: S1, S2, and S3 respectively construct a memory tree structure encoding network, a latent vector decoding network, and a feature reconstruction network; combining these three network modules, an image defect detection method based on the memory tree structure is constructed. Using GAN as the basic architecture, a memory tree structure encoding network and a latent vector decoding network jointly construct a generator network to complete the compression encoding and compression decoding of the input image and restore the normal shape of the input image; a feature reconstruction network is used to reconstruct compressed features as a feature supplement to the generator; at the same time, a convolutional discriminator is constructed to complete the discrimination between the input image and the generation pattern of the memory tree structure generator network, which promotes network training. Specifically, the training of image defect detection methods based on memory tree structures mainly includes three loss functions; Feature matching loss: Completes adversarial training between the generator G and the discriminator D, where x is the input image. Map the input image x to the intermediate feature representation of the discriminator; Generator image reconstruction loss: Captures the contextual information of the input image to complete the reconstruction of the input image; Feature Reconstruction Loss: Captures the compressed features z of the input image and the compressed features of the reconstructed image. Contextual information is used to optimize network training using feature distance; Finally, the training objective of the image defect detection method based on the memory tree structure is defined, and each loss function is adjusted by a control factor w: 。 6. The image defect detection method based on memory tree structure according to claim 5, characterized in that, The specific process of S5 is as follows: The training method for the image defect detection method based on memory tree structure is as follows: This method is an unsupervised detection method in image defect detection. During the training phase, only normal images are input. The input image dimension is set to 32×32. The input image is compressed into a 100-dimensional latent vector by an encoder network with a memory tree structure. The latent vector is then input into a latent vector decoding network for decoding, so that the 100-dimensional latent vector is restored to a 32×32 reconstructed image. The 32×32 reconstructed image is then input into a feature reconstruction network for further compression, and the compressed dimension is also 100. During training, the input image and the reconstructed image are used alternately for discrimination by the discriminator, thereby promoting the generator to generate more realistic images. During training, PyTorch 1.0 was used to build and implement the network, and the Adam optimizer was used to train the network. The main parameter settings during training are as follows: The learning rate is set to 0.002; the training batch size is set to 15; the latent vector dimension is set to 100; the training batch size is set to 64; the number of memory pools is set to 10; and the number of memory items in the memory pool is set to 10. The weight coefficients of the training target are The primary optimization objective is set to 50, while all other coefficients are set to 1.