Defect image generation method and device and storage medium

By performing multi-level feature extraction and feature vector fusion on the original defect image, defective images with high realistic and rich details are generated, which solves the problem of insufficient details and authenticity in the prior art, and improves the performance of the defect detection system.

CN119477672AActive Publication Date: 2025-02-18JIHUA LAB
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510075012.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-17
Publication Date
2025-02-18
Estimated Expiration
2045-01-17

AI Technical Summary

Technical Problem

The prior art ignores the details in the image when generating defective images, resulting in insufficient details and authenticity of the generated image. Especially when dealing with complex or minor defects, the generated defective images may be different from the actual situation.

Method used

By extracting the original defect image multi-level image feature, we obtain feature maps at different levels; for any feature map, determine its corresponding feature vectors; after traversing each feature map, each feature vector is fused to obtain the fusion feature Figure; Generate derivative defect images based on fusion feature maps.

Benefits of technology

It realizes the generation of defect images with high reality and rich details when the data samples are limited, which improves the training efficiency and detection accuracy of the defect detection system, and ensures the stability and reliability of defect identification in industrial production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119477672A_ABST
    Figure CN119477672A_ABST
Patent Text Reader

Abstract

The invention discloses a defect image generation method and device and a storage medium, and relates to the technical field of image generation, and the method comprises the steps: carrying out the multi-level image feature extraction of an original defect image, and obtaining feature maps of the original defect image under different levels; for any feature map, determining a feature vector corresponding to the feature map; after traversing the feature maps, fusing the feature vectors to obtain a fused feature map; and generating a derivative defect image corresponding to the original defect image based on the fused feature map. According to the method, multi-level image features are extracted, so that the problems of insufficient authenticity of the generated image, detail missing and inaccurate complex or tiny defect expression caused by neglecting image details and feature diversity in a traditional image generation method are avoided, and the purpose of improving the image generation efficiency under the condition of limited data samples is achieved. And a defect image with high reality and rich details is generated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image generation technology, and in particular to a defect image generation method, device and storage medium. Background Art

[0002] With the emergence of technologies such as Generative Adversarial Network (GAN), Variational Auto-Encoder (VAE), Diffusion Models, and Transformer, the quality and diversity of image generation have reached unprecedented heights. These technologies are widely used in industrial defect image generation to solve the problem of lack of data samples in the production process, thereby improving the accuracy and stability of defect detection systems. However, despite the progress made in these methods, there are still some problems with existing technologies in actual industrial applications. For example, many existing image generation models often ignore details in the image when generating defect images, such as the edges of the defects or some small features, resulting in insufficient details and authenticity of the generated images. Especially when dealing with complex or small defects, the generated defect images may be different from the actual situation.

[0003] Therefore, how to improve the generation quality of defect images to generate more detailed and realistic defect images is a problem that needs to be solved urgently. Summary of the invention

[0004] The main purpose of this application is to provide a defect image generation method, device and storage medium, aiming to solve the technical problem of how to improve the generation quality of defect images to generate more detailed and realistic defect images.

[0005] To achieve the above objectives, the present application proposes a defect image generation method, the defect image generation method comprising: Performing multi-level image feature extraction on the original defect image to obtain feature maps of the original defect image at different levels; For any feature map, determine the feature vector corresponding to the feature map; After traversing each feature map, each feature vector is fused to obtain a fused feature map; A derived defect image corresponding to the original defect image is generated based on the fused feature map.

[0006] In one embodiment, the step of performing multi-level image feature extraction on the original defect image to obtain feature maps of the original defect image at different levels includes: The original defect image is used as a feature map to be encoded, and multiple convolution operations are performed on the feature map to be encoded to obtain a pooled feature map of the feature map to be encoded at the current level; Performing a pooling operation on the feature map to be pooled to obtain a feature map to be encoded at the next level, and returning to the step of performing multiple convolution operations on the feature map to be encoded; After traversing each level, the feature maps of the original defect image at different levels are obtained based on the feature maps to be pooled at each level.

[0007] In one embodiment, the step of obtaining the feature maps of the original defect image at different levels based on the feature maps to be pooled at each level includes: For a feature map to be pooled at any level, weighted averaging is performed on the feature submaps at each depth in the feature map to be pooled to obtain an average feature map; After traversing each feature map to be pooled, each average feature map is used as the feature map of the original defect image at different levels.

[0008] In one embodiment, the step of determining the feature vector corresponding to the feature map comprises: Flattening the feature map to obtain a multidimensional vector corresponding to the feature map, wherein the dimension of the multidimensional vector is determined based on the size of the feature map; The multidimensional vector is sampled at the highest dimension in each level to obtain a feature vector corresponding to the feature map.

[0009] In one embodiment, the step of sampling the multidimensional vector at the highest dimension in each level to obtain the feature vector corresponding to the feature map includes: Inputting the multidimensional vector into a preset fully connected layer to generate a candidate vector corresponding to the highest dimension in each layer through the preset fully connected layer; The generated random noise is obtained, and a feature vector corresponding to the feature map is determined based on the candidate vector and the random noise.

[0010] In one embodiment, the defect image generating method further includes: A loss function is constructed according to the candidate vector, and model parameters in a preset convolutional layer and a preset fully connected layer are trained based on the loss function, wherein the preset convolutional layer is used to perform a convolution operation.

[0011] In one embodiment, the step of fusing the feature vectors to obtain a fused feature map includes: For any feature vector, convert the feature vector into a candidate feature map; After traversing each feature vector, each candidate feature map is concatenated to obtain a fused feature map.

[0012] In one embodiment, the step of generating a derived defect image corresponding to the original defect image based on the fused feature map includes: The fused feature map is used as a feature map to be decoded, and multiple convolution operations are performed on the feature map to be decoded to obtain a feature map to be interpolated at the current level of the feature map to be decoded; Performing a linear interpolation operation on the feature map to be interpolated to obtain a feature map to be decoded at an upper level of the feature map to be interpolated, and returning to the step of performing multiple convolution operations on the feature map to be decoded; After the feature map to be decoded undergoes convolution operations and linear interpolation operations at various levels, a target feature map is obtained, and a derived defect image corresponding to the original defect image is generated based on the target feature map.

[0013] In addition, to achieve the above purpose, the present application also proposes a defect image generation system, the defect image generation system comprising: An encoder is used to perform multi-level image feature extraction on the original defect image to obtain feature maps of the original defect image at different levels; A sampler, for determining, for any feature map, a feature vector corresponding to the feature map; A feature generator is used to fuse each feature vector after traversing each feature map to obtain a fused feature map; A decoder, configured to generate a derivative defect image corresponding to the original defect image based on the fused feature map In addition, to achieve the above-mentioned purpose, the present application also proposes an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the defect image generation method as described above.

[0014] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the defect image generation method described above are implemented.

[0015] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the defect image generating method described above are implemented.

[0016] One or more technical solutions proposed in this application have at least the following technical effects: The present application first performs multi-level image feature extraction on the original defect image to obtain feature maps of the original defect image at different levels, and extracts multi-level features from the data by introducing a hierarchical structure, thereby realizing feature extraction of the original defect image at different scales, thereby capturing local features and global structural information of the image, ensuring that the hierarchy and structure of the original image can be retained when the defect image is subsequently generated, and improving the authenticity of the generated image; for any feature map, determine the feature vector corresponding to the feature map, and simplify the representation of the feature map by converting the feature map into a representative feature vector, which is convenient for subsequent feature fusion and defect image generation, while retaining key feature information; after traversing each feature map, fuse each feature vector to obtain a fused feature map, and integrate feature information at different levels to form a fused feature map containing rich information, ensuring that the generated defect image has diversity and authenticity in details and structure; based on the fused feature map, generate a derived defect image corresponding to the original defect image, and generate a defect image with rich details and high authenticity through a reverse generation process from the fused feature map to the defect image, solving the problem of insufficient details and authenticity when generating defect images in traditional methods.

[0017] In summary, the present application performs multi-level image feature extraction, feature vector conversion and splicing on the original defect image, and generates a defect image based on the spliced ​​fusion feature map, thereby avoiding the problems of insufficient realism, missing details and inaccurate representation of complex or minor defects caused by ignoring image details and feature diversity in traditional image generation methods. It achieves the generation of defect images with high realism and rich details when data samples are limited, so that the defect detection system can be trained based on high-quality defect samples, thereby improving the training efficiency and detection accuracy of the defect detection system, and ensuring the stability and reliability of defect recognition in industrial production. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0019] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0020] Figure 1 A schematic diagram of a process flow provided for the first embodiment of the defect image generation method of the present application; Figure 2A schematic diagram of the fusion process of the defect image generation method provided in Example 1 of the present application; Figure 3 A schematic diagram of a flow chart provided for the second embodiment of the defect image generation method of the present application; Figure 4 A schematic diagram of a sampling process of a defect image generation method provided in Embodiment 2 of the present application; Figure 5 A schematic diagram of a model framework of a defect image generation method provided in Embodiment 2 of the present application; Figure 6 This is a schematic diagram of the module structure of the defect image generation system according to an embodiment of the present application; Figure 7 Schematic diagram of the device structure of the hardware operating environment involved in the defect image generation method in the embodiment of the present application.

[0021] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0022] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0023] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0024] The main solution of the embodiment of the present application is: perform multi-level image feature extraction on the original defect image to obtain feature maps of the original defect image at different levels; for any feature map, determine the feature vector corresponding to the feature map; after traversing each feature map, fuse the feature vectors to obtain a fused feature map; and generate a derived defect image corresponding to the original defect image based on the fused feature map.

[0025] Since the existing technology often ignores the details in the image when generating defect images, such as the edges of the defects or some small features, the details and authenticity of the generated images are insufficient. Especially when dealing with complex or small defects, the generated defect images may be different from the actual situation. Therefore, how to improve the generation quality of defect images to generate more detailed and realistic defect images is a problem that needs to be solved urgently.

[0026] The present application provides a solution, which performs multi-level image feature extraction, feature vector conversion and splicing on the original defect image, and generates the defect image based on the spliced ​​fusion feature map, thereby avoiding the problems of insufficient realism, missing details and inaccurate representation of complex or minor defects caused by ignoring image details and feature diversity in traditional image generation methods, and achieves the generation of defect images with high realism and rich details when data samples are limited, so that the defect detection system can be trained based on high-quality defect samples, thereby improving the training efficiency and detection accuracy of the defect detection system, and ensuring the stability and reliability of defect recognition in industrial production.

[0027] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device that can realize the above functions. The following takes an electronic device as an example to illustrate this embodiment and the following embodiments.

[0028] Based on this, the present application embodiment provides a defect image generation method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the defect image generation method of the present application.

[0029] In this embodiment, the defect image generation method includes steps S10 to S40: Step S10, performing multi-level image feature extraction on the original defect image to obtain feature maps of the original defect image at different levels; It should be noted that the original defect image refers to the original image of the defect image to be generated, which is usually an image of a defective product from an industrial production line. The defect types in the defective product image may include cracks, dents, holes, corrosion, scratches, etc. Each defect type has different visual features, which are gradually extracted and abstracted in different levels of the deep learning network. Among them, the defect types can be divided into three categories: microscopic defects, macroscopic defects and compound defects: microscopic defects are usually small in size and have a limited impact range, such as cracks, scratches, bubbles, etc., and their characteristics are manifested as subtle local changes, usually including edges, corners, and texture mutations; macroscopic defects are usually more obvious and have a larger impact range, such as holes, dents, and larger areas of corrosion. Compared with microscopic defects, macroscopic defects involve a larger range of structural or surface changes, which are usually manifested as large-scale shape changes in the image; compound defects usually involve the superposition of multiple local defects, or manifest as more complex structural changes, such as large-scale surface corrosion and multi-point surface damage. Micro defects can be extracted by simple local features through the low-level convolutional layers of the deep learning network, focusing on details such as edges and textures; macro defects can be extracted by more complex local features through the middle-level convolutional layers of the deep learning network, focusing on a larger range of shape changes and texture distortions; composite defects can be extracted by global features through high-level convolutional layers, integrating multi-level local information to extract more complex and global irregular damage. These defect types are gradually improved in the deep learning network by extracting and combining features at different levels layer by layer, so that the system can effectively extract various industrial defect features from tiny to complex.

[0030] In addition, it should be noted that multi-level image feature extraction refers to the use of convolutional neural networks (CNN) to process the original defect image layer by layer to extract the feature information of the image at different abstract levels; the feature map refers to the two-dimensional data output by each layer in the convolutional neural network, which represents the feature response of the original defect image at that layer.

[0031] It is understandable that since the original defect image has different feature representations at different levels, and the traditional image generation model often ignores the details in the image when generating the defect image, methods such as the generative adversarial network (GAN) may experience mode collapse during training, that is, the model can only generate a limited type of defect images and ignore other possible defect types. Therefore, step S10 is performed to extract image features at different levels, thereby avoiding the loss of image information caused by using only a single level of features, reducing the mode collapse phenomenon, and realizing the extraction of comprehensive image features to enhance the model's ability to express different types of defects.

[0032] Exemplarily, first, the original defect image is input into a pre-trained convolutional neural network, which contains multiple convolutional layers and pooling layers. Each layer performs a convolution operation on the feature map output by the previous layer to extract more abstract and complex features. In this way, from the first convolutional layer to the last convolutional layer of the network, the features of the original defect image are extracted layer by layer to obtain a series of feature maps at different levels, each of which represents the feature response of the original defect image at the corresponding level.

[0033] In a feasible implementation, step S10 may include steps S11 to S13: Step S11, taking the original defect image as a feature map to be encoded, and performing multiple convolution operations on the feature map to be encoded to obtain a pooled feature map of the feature map to be encoded at the current level; It should be noted that the feature map to be encoded refers to the original image or the feature map of the previous layer used as input before the convolution operation, and this feature map is the starting point of the convolution operation at the current layer; the current layer refers to a specific layer in the convolutional neural network, that is, the combination of the convolution layer and the pooling layer currently being processed; the feature map to be pooled refers to the feature map that has not yet undergone the pooling operation after the convolution operation, and this feature map contains the feature information of the current layer and waits for further processing.

[0034] It can be understood that in order to extract a higher-level feature representation from the original defect image, step S11 is performed. By performing multiple convolution operations on the image to expand the receptive field of the feature map, the problem of the receptive field of the feature map being too small can be avoided, thereby processing the image into a feature map that is conducive to extracting higher-level information.

[0035] Exemplarily, first, the original defect image is used as the initial feature map to be encoded. Then, the feature map is sent to the first layer of the convolutional neural network, which contains multiple convolution kernels. Each convolution kernel performs a sliding convolution operation on the feature map to be encoded, and generates a new feature map through, for example, 3x3 convolution, batch normalization and activation function (such as ReLU), which is the feature map to be pooled at the current level. This process is repeated in each layer to extract more complex features.

[0036] Step S12, performing a pooling operation on the feature map to be pooled to obtain a feature map to be encoded at the next level, and returning to perform the step of performing multiple convolution operations on the feature map to be encoded; It is understandable that, since it is necessary to extract features at different levels and reduce the size of the feature map to reduce the computational complexity, performing step S12 can avoid the problem of waste of computing resources caused by excessive feature map size, thereby achieving the effect of feature dimensionality reduction while maintaining feature significance.

[0037] Exemplarily, after obtaining the feature maps to be pooled at the current level, pooling operations (such as maximum pooling or average pooling) are performed on these feature maps. The pooling operation selects a local area on the feature map and outputs a representative value of the area (such as the maximum value or average value), thereby reducing the size of the feature map. In this way, after the original feature map to be interpolated is pooled, a feature map to be encoded at the next level with a smaller size and more concentrated features is generated. After pooling is completed, the network will use this new feature map to be encoded as input, return to the step of performing multiple convolution operations, and continue to extract features at the next level.

[0038] Step S13, after traversing each level, obtaining feature maps of the original defect image at different levels based on the feature maps to be pooled at each level.

[0039] In this embodiment, by using a multi-level CNN to perform layer-by-layer convolution and pooling operations on the original defect image, the problems of insufficient feature extraction and waste of computing resources in traditional image processing methods are avoided, image features are extracted at multiple abstract levels, and the size of the feature map is effectively reduced, thereby achieving the effect of reducing computational complexity, maintaining feature significance, and obtaining comprehensive feature representation. This hierarchical feature extraction method not only improves the richness and representativeness of image features, but also provides a more effective feature basis for subsequent image analysis and processing tasks.

[0040] Step S20, for any feature map, determining a feature vector corresponding to the feature map; It should be noted that the feature vector refers to the result of flattening the feature map into a one-dimensional vector, which contains all the information of the feature map.

[0041] It is understandable that in order to uniformly process the feature information at different levels, step S20 is performed to avoid incompatibility between the feature information, thereby achieving effective integration of the feature information.

[0042] For example, for each feature map extracted from the convolutional neural network, the two-dimensional feature map is converted into a one-dimensional feature vector through the global average pooling (GAP) or global max pooling (GMP) operation. In this way, the size of each feature map is reduced to a vector of a fixed length, which is the feature representation of the feature map.

[0043] In a feasible implementation manner, the step of determining the feature vector corresponding to the feature map in step S20 may include steps S21-S22: Step S21, flattening the feature map to obtain a multidimensional vector corresponding to the feature map, wherein the dimension of the multidimensional vector is determined based on the size of the feature map; It should be noted that a multidimensional vector refers to converting a feature map into a one-dimensional array, in which each element corresponds to a pixel value in the feature map; the flattening process is to convert a two-dimensional or three-dimensional feature map into a one-dimensional vector, the dimension of which is the width of the feature map multiplied by the height (for a two-dimensional feature map) or the width multiplied by the height multiplied by the depth (for a three-dimensional feature map).

[0044] It can be understood that in order to convert the two-dimensional data structure of the feature map into a one-dimensional data structure to facilitate subsequent vector operations and processing, step S21 is performed. This can avoid the inability to apply vectorized machine learning algorithms due to data structure mismatch, and can realize the conversion of feature map information into a format suitable for machine learning model processing, thereby improving the processing efficiency and compatibility of feature information.

[0045] For example, in a convolutional neural network, after a feature map is processed by a convolutional layer, it is converted into a one-dimensional array. For example, each pixel value of the feature map is arranged in a certain order (such as from left to right, from top to bottom) to form a one-dimensional vector. If the size of the feature map is HxW, then the dimension of the flattened multidimensional vector is HW. This process can be achieved through the reshape operation of the matrix, that is, reshaping the original HxW two-dimensional matrix into a one-dimensional matrix with a dimension of HW.

[0046] Step S22, sampling the multidimensional vector at the corresponding highest dimension in each level to obtain a feature vector corresponding to the feature map.

[0047] It should be noted that the highest dimension refers to the layer with the largest dimension (i.e., the size of the feature map) among multiple layers of feature maps. This dimension usually corresponds to the earliest or deepest feature map in the network, because as the network goes deeper, the size of the feature map usually decreases, and the early feature maps may have higher dimensions because they retain more details.

[0048] It is understandable that, since it is necessary to maintain consistent vector dimensions in feature maps at different levels to facilitate feature fusion, step S22 can avoid data processing difficulties caused by inconsistent feature vector dimensions, and extract feature vectors of equal length from feature maps at different levels, thereby facilitating feature fusion, achieving unified feature representation and improving model performance. In addition, sampling based on the corresponding highest dimension in each level can retain as many details in the feature as possible, thereby improving the feature representation quality of the feature vector.

[0049] Exemplarily, after obtaining the flattened multidimensional vector, since the feature maps at different levels may have different sizes, these vectors need to be sampled to maintain a consistent dimension. The specific operation may be that, for each level of the feature map, the multidimensional vector corresponding to the feature map is multiplied by a predefined sampling matrix, the size of the sampling matrix being the size of the highest dimensional feature map. If the dimension of the current feature map is smaller than the highest dimension, the dimension is increased by interpolation (such as nearest neighbor interpolation, linear interpolation, etc.) or by selecting some elements in the multidimensional vector to make it consistent with the highest dimension. Through the above method, the multidimensional vectors of each feature map are sampled to the same dimension to form the corresponding feature vector.

[0050] In this implementation, by flattening the feature map and performing high-dimensional sampling, the problem of data processing difficulties caused by inconsistent feature map sizes is avoided, and the effect of converting feature maps of different levels into feature vectors of uniform dimensionality is achieved. Such processing not only facilitates subsequent feature fusion and model training, but also ensures the effective extraction and utilization of feature information, thereby improving the efficiency and accuracy of the entire image processing system.

[0051] Step S30, after traversing each feature map, fuse each feature vector to obtain a fused feature map; It should be noted that the fused feature map refers to merging all feature vectors into a comprehensive feature representation through some method (such as splicing, weighted summation, etc.).

[0052] It is understandable that in order to combine feature information at different levels, step S30 is performed. By effectively fusing features at different levels, the problem that features at a single level cannot fully reflect the image content can be avoided, thereby achieving richer and more comprehensive feature representation.

[0053] Exemplarily, all the obtained feature vectors can be concatenated to form a long feature vector, which is a fused feature map that integrates feature information at different levels. Alternatively, each feature vector can be weighted and summed, and the weight can be dynamically adjusted according to the importance of the feature map, to finally obtain a fused feature vector, which is a fused feature map.

[0054] In a feasible implementation manner, the step of fusing the feature vectors in step S30 to obtain a fused feature map may include steps S31-S32: Step S31, for any feature vector, convert the feature vector into a candidate feature map; It should be noted that the candidate feature map refers to the feature vector reconverted into a two-dimensional image format to facilitate further image processing operations in the convolutional neural network. This process usually involves reshaping the one-dimensional feature vector into a feature map with a specific height and width.

[0055] It can be understood that in order to convert the feature vector back to the format of the feature map so as to utilize the image processing capabilities of the convolutional layer in the subsequent decoder, step S31 is performed. This can avoid the problem of loss of image structure information that may result from the subsequent decoder directly processing features in the vector space, and achieves the remapping of the feature vector to the image space to retain the local structure and spatial relationship of the image.

[0056] For example, first, a feature vector is obtained, which is a one-dimensional array flattened from the feature map. Then, according to the size information of the original feature map, this one-dimensional array is reshaped into a two-dimensional candidate feature map. When the dimension of the feature vector is In the case of The candidate feature map of the size can be realized by the reshape function in the programming language.

[0057] Step S32, after traversing each feature vector, concatenate each candidate feature map to obtain a fused feature map.

[0058] It can be understood that since it is necessary to integrate feature information at different levels to obtain a richer feature representation, performing step S32 can avoid the problem that the feature information may be incomplete or insufficient to characterize the complex image content due to the use of features at a certain layer alone, and realizes the integration of multi-level feature information to generate a fused feature map containing more comprehensive and rich features, thereby improving the accuracy and robustness of image analysis and recognition.

[0059] Exemplarily, after all feature vectors are converted into candidate feature maps, these candidate feature maps are concatenated along the channel dimension (C dimension). If the size of each candidate feature map is HxWxC_i, where C_i is the number of channels of the i-th candidate feature map, then the concatenation operation merges the channels of all candidate feature maps together to form a new feature map with a size of HxWx∑C_i. This process can be implemented by the concatenate function in the programming language, which can connect multiple arrays along the specified dimension to obtain a fused feature map containing all feature information. Please refer to Figure 2 In the figure, the 256-dimensional feature vectors in the five levels are converted into 16 x 16 candidate feature maps respectively, and then the candidate feature maps are concatenated, where each circle in the feature vector represents each element in the feature vector.

[0060] In this embodiment, by converting feature vectors to feature maps and splicing feature maps, the problem caused by insufficient feature information at a single level in image processing is avoided, and feature information at different levels is fused together to form a richer and more comprehensive feature representation effect. Not only is the structure and detail information of features at each level retained, but the model's ability to understand and express image content is also enhanced through vertical splicing of features.

[0061] Step S40, generating a derived defect image corresponding to the original defect image based on the fused feature map.

[0062] It can be understood that since it is necessary to reversely generate an image with defects from the feature representation, performing step S40 can avoid the technical problems of low image generation quality and unreal defects caused by directly operating the pixel space in the traditional method, and achieve the generation of highly realistic defect images, thereby improving the training quality and detection performance of the defect detection system.

[0063] Exemplarily, a decoder network is used, which can be another convolutional neural network, whose role is to reconstruct the image from the fused feature map. The decoder network gradually increases the size of the image through a series of deconvolution layers and upsampling layers while restoring the details of the image. In this process, some noise or defect generation modules, such as adversarial noise generators, can be introduced to introduce specific defect patterns in the reconstructed image, and finally a derivative defect image with a similar appearance to the original defect image but containing specific defects is obtained.

[0064] In a feasible implementation, step S40 may include steps S41 to S43: Step S41, taking the fused feature map as the feature map to be decoded, and performing multiple convolution operations on the feature map to be decoded to obtain a feature map to be interpolated at the current level of the feature map to be decoded; It should be noted that the feature map to be decoded refers to the feature map that serves as the original feature vector or the next level before the convolution operation. This feature map contains the feature information of the original defect image at different levels and is the starting point of the convolution operation at the current level. The feature map to be interpolated refers to the feature map that needs to be increased in size through interpolation operation after the convolution operation during the decoding process. This feature map is the output of a certain level in the decoder network and is used to restore the feature representation to a higher resolution.

[0065] It can be understood that since it is necessary to gradually restore the details and structure of the image during the decoding process, step S41 is performed. By performing corresponding convolution operations, the problem of losing feature information during image reconstruction can be avoided, thereby achieving the effect of restoring more refined image features from the compressed feature representation.

[0066] For example, first, the fused feature map is passed as input to the first layer of the decoding network, in which the feature map to be decoded is processed through a series of convolution operations of convolution kernels, such as 3x3 convolution, batch normalization, activation functions (such as ReLU, etc.), and each convolution operation is intended to extract or enhance specific properties of the feature map. These convolution operations can be deconvolution or transposed convolution, which are used to gradually build higher resolution feature representations, and finally obtain the feature map to be interpolated at the current level.

[0067] Step S42, performing a linear interpolation operation on the feature map to be interpolated to obtain a feature map to be decoded at an upper level of the feature map to be interpolated, and returning to perform the step of performing multiple convolution operations on the feature map to be decoded; It can be understood that since the size of the feature map needs to be upsampled to a higher resolution, step S42 is performed. By linearly interpolating the feature map at each level, the problem of image blur or distortion caused by direct upsampling can be avoided, thereby achieving smooth and detail-rich feature map reconstruction.

[0068] For example, after obtaining the feature map to be interpolated at the current level, linear interpolation (such as bilinear interpolation or nearest neighbor interpolation) is applied to increase the size of the feature map to make it close to the size of the previous level. This process increases the resolution of the feature map, thereby obtaining the feature map to be decoded at the previous level. After the interpolation is completed, the network will use this new feature map to be decoded as input, return to the step of performing multiple convolution operations, and continue to reconstruct features at a higher level.

[0069] Step S43, after the feature map to be decoded undergoes convolution operations and linear interpolation operations at various levels, a target feature map is obtained, and a derived defect image corresponding to the original defect image is generated based on the target feature map.

[0070] It should be noted that the target feature map refers to the feature map finally obtained after all levels of convolution operations and linear interpolation operations. The feature map has the same size as the original defect image and contains all the necessary information for generating the defect image.

[0071] It can be understood that since the feature information needs to be converted back into pixel space to generate an image with specific defects, performing step S43 can avoid the problem that the generated defective image is inconsistent with the original image or the defects are unnatural, thereby achieving the generation of a highly realistic image with specific defects.

[0072] For example, after all layers of the decoding network have completed the convolution and interpolation operations, a target feature map with the same size as the original defect image is finally obtained. This target feature map contains all the necessary information for generating the defect image. Next, by applying some generative network techniques (such as generative adversarial networks GAN or variational autoencoders VAE), an image with a specific defect is generated based on the target feature map, that is, a derivative defect image corresponding to the original defect image. This process may include converting the feature map to pixel space and performing some post-processing steps to ensure the naturalness of the defect and the overall quality of the image.

[0073] In this implementation, through convolution operations and linear interpolation operations based on each level, the problems of feature information loss, blurred image details and unnatural defects in the image reconstruction process are avoided, and a high-resolution, detail-rich target feature map is gradually restored from the fused feature map, and finally a defect image that matches the original defect image and contains specific defects is generated. This hierarchical decoding process not only retains the key features of the image, but also ensures the authenticity and detail quality of the generated defect image.

[0074] The present embodiment provides a defect image generation method, which performs multi-level image feature extraction, feature vector conversion and splicing on the original defect image, and generates the defect image based on the spliced ​​fusion feature map. This avoids the problems of insufficient realism, missing details, and inaccurate representation of complex or minor defects caused by ignoring image details and feature diversity in traditional image generation methods. It achieves the generation of defect images with high realism and rich details when data samples are limited, so that the defect detection system can be trained based on high-quality defect samples, thereby improving the training efficiency and detection accuracy of the defect detection system and ensuring the stability and reliability of defect recognition in industrial production.

[0075] In a feasible implementation manner, the step of obtaining the feature maps of the original defect image at different levels based on the feature maps to be pooled at each level in step S13 may include steps S131-S132: Step S131, for a feature map to be pooled at any level, weighted average the feature submaps at each depth in the feature map to be pooled to obtain an average feature map; It should be noted that the feature submap refers to each individual image slice divided along the depth dimension (channel dimension) in the feature map to be pooled, and each feature submap represents a specific type of feature information of the original defect image at this level; the average feature map refers to the feature map obtained by performing a weighted average operation on the feature submaps at each depth in the feature map to be pooled. This feature map represents a comprehensive and abstract representation of the feature map at this level, which contains important information of all feature submaps at this level.

[0076] It can be understood that since it is necessary to find a balance point between different feature sub-graphs to retain the most important feature information, performing step S131 can avoid the problem of feature information loss or imbalance in the features of each feature sub-graph caused by directly using the feature map to be pooled as the feature map of the original defect image at different levels, thereby achieving the effect of retaining key features and reducing redundant information.

[0077] For example, at a specific level of the convolutional neural network, a weight is assigned to each channel (i.e., feature subgraph) of the pooled feature map. These weights can be pre-set according to the importance of the feature subgraph or learned. Then, each feature subgraph is multiplied by its corresponding weight and the results are added. Finally, this sum is divided by the sum of the weights (or the number of channels, if the weights are equally weighted) to obtain an average feature map, which represents the weighted average information of all feature subgraphs at this level.

[0078] Step S132, after traversing each feature map to be pooled, each average feature map is used as the feature map of the original defect image at different levels.

[0079] For example, after performing the weighted average operation at each level of the network, a series of average feature maps are obtained. As the network propagates from forward to backward, these average feature maps are collected to form a feature map set. Each average feature map in this set corresponds to the feature representation of the original defect image at different levels. In the subsequent stages of the network, these average feature maps can be used as input.

[0080] In this implementation, by weighted summing and averaging the feature sub-maps at each depth in the pooled feature map, the problem of feature information loss or dilution of important features that may be caused in traditional pooling operations is avoided, and the effect of retaining key feature information and reducing redundancy is achieved. At the same time, by using each average feature map as the feature map of the original defect image at different levels, the comprehensiveness and hierarchy of the feature representation are ensured, thereby improving the quality and accuracy of image analysis and processing tasks.

[0081] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 3 , step S22 may include steps S221~S222: Step S221, inputting the multidimensional vector into a preset fully connected layer, so as to generate a candidate vector corresponding to the highest dimension in each layer through the preset fully connected layer; It should be noted that the preset fully connected layer refers to a layer in a neural network, in which each input has a connection with each output, and these connections have learnable weights; the candidate vector refers to an intermediate vector generated after processing a multidimensional vector through the preset fully connected layer, which contains the feature representation of the input vector after being transformed by the fully connected layer.

[0082] It is understandable that since the flattened high-dimensional feature vector needs to be converted into a low-dimensional vector that is more suitable for subsequent processing, step S221 is performed to avoid the problems of computational complexity and overfitting risk caused by excessively high dimensions, thereby achieving the effect of feature dimensionality reduction and extraction of key information.

[0083] For example, The multidimensional vector of dimension is input into the preset fully connected layer to generate the candidate vector corresponding to the highest dimension in each layer through the preset fully connected layer. and For example, when the dimensions of each level are 256, 128, 64, 32, and 16 respectively, the highest dimension is 256, then the candidate vector and The dimension of is 256.

[0084] Step S222, obtaining the generated random noise, and determining the feature vector corresponding to the feature map based on the candidate vector and the random noise.

[0085] It should be noted that random noise refers to a randomly generated numerical vector, which is usually used to introduce uncertainty and increase the diversity of data.

[0086] It is understandable that due to the high cost and limited number of defect samples in actual industrial production, many traditional methods find it difficult to generate defect images with diversity when data is insufficient. Therefore, step S222 is performed to introduce varying random noise in the process of generating defect images to enhance the generalization ability and the ability to generate diversity of the model, thereby avoiding the generated feature vectors from being too single or stereotyped, thereby achieving the effect of generating feature vectors that are both diverse and realistic.

[0087] For example, please refer to Figure 4 , first, generate a random noise vector with the same dimension as the candidate vector , which corresponds to the highest dimension (e.g., 256 dimensions) in each level. This vector can be created by a random number generator according to a specific distribution (e.g., normal distribution N(0, 1)). Then, this random noise vector Compared with the candidate vector obtained by the fully connected layer and The feature vector corresponding to the feature map is obtained by reparameterized sampling through the following formula :

[0088] The feature vector can then be fed into the feature generator for concatenation to obtain a fused feature map, where the circles represent each element in the feature vector (or each pixel in the feature map), and the connecting lines between the circles represent Each element in the multidimensional vector of dimension 1 generates a candidate vector and The corresponding elements in .

[0089] In this embodiment, by adopting a fully connected layer combined with the injection of random noise, the risks of insufficient model generalization ability and overfitting due to single-dimensional feature representation and the problem of lack of diversity in feature representation are avoided. While maintaining the effectiveness of feature representation, the randomness and diversity of feature vectors are increased, thereby improving the generalization ability of the model and the effect of generating a set of feature vectors with rich variations.

[0090] In a feasible implementation manner, step S221 may further include step S100: Step S100, constructing a loss function according to the candidate vector, and training model parameters in a preset convolutional layer and the preset fully connected layer based on the loss function, wherein the preset convolutional layer is used to perform a convolution operation.

[0091] It should be noted that the model parameters include the weights and biases in the preset convolutional layer and the preset fully connected layer.

[0092] It is understandable that since the convolutional layers and fully connected layers set under default conditions often cannot exert relatively good performance, step S100 is performed. By training the convolutional layers and the fully connected layers, it is possible to avoid the problem that the model performance cannot be better exerted during the image analysis process due to the incompatibility of the model parameters configured in the convolutional layers and the fully connected layers, and achieve real-time optimization of the model parameters to improve the quality of defective images generated by the model.

[0093] Exemplarily, the candidate vector corresponding to the highest dimension in each level generated by the preset fully connected layer and Constructing the loss function as follows:

[0094] Among them, i represents the index value of each level, which means there are five levels; Represents the KL divergence between the distribution generated by the encoder and the normal distribution, which measures the similarity between the two distributions and is calculated as follows:

[0095] It can be seen from the formula that when =0, =1, the loss is minimal. The smaller the item is, the more the feature vector generated by the encoder conforms to the standard normal distribution, so that the generated defect image is more realistic and diverse. represents the reconstruction error, which is calculated as follows:

[0096] in, represents the real sample, represents the generated sample, Represents the height and width of the original defect image, such as . This formula is used to minimize the generated samples and real samples The error means that an autoencoder model has been trained. By constructing the loss function The weights and biases in the preset convolutional layer and the preset fully connected layer are trained and adjusted to minimize the loss function. as the goal.

[0097] For example, in order to help understand the implementation process of the defect image generation method obtained by combining this embodiment with the above-mentioned embodiment 1, please refer to Figure 5 , Figure 5 A model framework schematic diagram of a defect image generation method is provided, specifically: The rectangle in the figure is the feature map. The length of the rectangle indicates the size of the feature map (corresponding to different levels). The number marked on the left side of the rectangle is the specific size, such as 256 indicates that the size of the feature map is 256 x 256, 128 indicates that the size of the feature map is 128 x 128, etc. The height indicates the dimension of the feature map (that is, the depth of the feature map, which can also be called the number of feature sub-maps in the feature map). The bold number marked on the right side of the rectangle is the specific dimension, such as 64 indicates that the dimension of the feature map is 64, 1 indicates that the dimension of the feature map is 1, etc. The internal framework corresponding to the sampler in the figure can be referred to Figure 4 , the corresponding internal framework of the feature generator can be referred to Figure 2, the framework except the sampler and feature generator in the upper part of the figure is the framework corresponding to the encoder, and the framework in the lower part of the figure is the framework corresponding to the decoder. In the entire framework, the original defect image x is subjected to five levels of image feature extraction corresponding to the dimensions of 256, 128, 64, 32, and 16, including three convolution operations (as shown by the solid arrows in the figure, such as 3 x 3 convolution, batch normalization, ReLU activation function, etc.), one flattening (as shown by the dotted hollow arrows in the figure), and one pooling (as shown by the solid hollow arrows in the figure) encoder processing at each level, and then the feature map with a dimension of 1 obtained after each flattening is input into the sampler to determine the feature vector corresponding to the feature map. Then, the feature vectors of each level are converted into 16 x 16 feature maps in the feature generator and spliced ​​to obtain a fused feature map. Then, the fused feature map is processed in each level of the decoder (such as 16, 32, 64, 128, and 256 in the figure), including two convolution operations in each level (as shown by the solid arrows in the figure, such as 3 x 3 convolution, batch normalization, and ReLU activation function), and one linear interpolation operation (as shown by the dotted hollow arrows in the figure). Finally, a target feature map with a size of 256 x 256 and a dimension of 64 is obtained to generate a derived defect image X' corresponding to the original defect image x based on the target feature map.

[0098] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the defect image generation method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.

[0099] This application also provides a defect image generation system, please refer to Figure 6 , the defect image generation system includes: The encoder 10 is used to perform multi-level image feature extraction on the original defect image to obtain feature maps of the original defect image at different levels; A sampler 20, for determining, for any feature map, a feature vector corresponding to the feature map; A feature generator 30 is used to fuse each feature vector after traversing each feature map to obtain a fused feature map; The decoder 40 is used to generate a derived defect image corresponding to the original defect image based on the fused feature map.

[0100] Optionally, the encoder 10 is further used for: The original defect image is used as a feature map to be encoded, and multiple convolution operations are performed on the feature map to be encoded to obtain a pooled feature map of the feature map to be encoded at the current level; Performing a pooling operation on the feature map to be pooled to obtain a feature map to be encoded at the next level, and returning to execute the step of performing multiple convolution operations on the feature map to be encoded; After traversing each level, the feature maps of the original defect image at different levels are obtained based on the feature maps to be pooled at each level.

[0101] Optionally, the encoder 10 is further used for: For a feature map to be pooled at any level, weighted averaging is performed on the feature submaps at each depth in the feature map to be pooled to obtain an average feature map; After traversing each feature map to be pooled, each average feature map is used as the feature map of the original defect image at different levels.

[0102] Optionally, the sampler 20 is further used for: Flattening the feature map to obtain a multidimensional vector corresponding to the feature map, wherein the dimension of the multidimensional vector is determined based on the size of the feature map; The multidimensional vector is sampled at the highest dimension in each level to obtain a feature vector corresponding to the feature map.

[0103] Optionally, the sampler 20 is further used for: Inputting the multidimensional vector into a preset fully connected layer to generate a candidate vector corresponding to the highest dimension in each layer through the preset fully connected layer; The generated random noise is obtained, and a feature vector corresponding to the feature map is determined based on the candidate vector and the random noise.

[0104] Optionally, the training module 50 in the defect image generation system is used to: A loss function is constructed according to the candidate vector, and model parameters in a preset convolutional layer and a preset fully connected layer are trained based on the loss function, wherein the preset convolutional layer is used to perform a convolution operation.

[0105] Optionally, the feature generator 30 is further used for: For any feature vector, convert the feature vector into a candidate feature map; After traversing each feature vector, each candidate feature map is concatenated to obtain a fused feature map.

[0106] Optionally, the decoder 40 is further configured to: The fused feature map is used as a feature map to be decoded, and multiple convolution operations are performed on the feature map to be decoded to obtain a feature map to be interpolated at the current level of the feature map to be decoded; Performing a linear interpolation operation on the feature map to be interpolated to obtain a feature map to be decoded at an upper level of the feature map to be interpolated, and returning to the step of performing multiple convolution operations on the feature map to be decoded; After the feature map to be decoded undergoes convolution operations and linear interpolation operations at various levels, a target feature map is obtained, and a derived defect image corresponding to the original defect image is generated based on the target feature map.

[0107] The defect image generation system provided by the present application adopts the defect image generation method in the above embodiment, which can solve the technical problem of how to improve the generation quality of defect images to generate more detailed and realistic defect images. Compared with the prior art, the beneficial effects of the defect image generation system provided by the present application are the same as the beneficial effects of the defect image generation method provided by the above embodiment, and other technical features in the defect image generation system are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0108] The present application provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the defect image generation method in the above-mentioned embodiment one.

[0109] Reference below Figure 7 , which shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present application. The electronic devices in the embodiments of the present application may include but are not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions: tablet computers), PMPs (Portable Media Players: portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0110] like Figure 7As shown, the electronic device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the electronic device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows an electronic device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0111] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0112] The electronic device provided by the present application adopts the defect image generation method in the above embodiment, which can solve the technical problem of how to improve the generation quality of defect images to generate more detailed and realistic defect images. Compared with the prior art, the beneficial effects of the electronic device provided by the present application are the same as the beneficial effects of the defect image generation method provided by the above embodiment, and the other technical features in the electronic device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0113] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0114] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0115] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the defect image generating method in the above-mentioned embodiment.

[0116] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM: Random Access Memory), a read-only memory (ROM: Read Only Memory), an erasable programmable read-only memory (EPROM: Erasable Programmable Read Only Memory or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM: CD-Read Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency: Radio Frequency), etc., or any suitable combination of the above.

[0117] The computer-readable storage medium may be included in the electronic device, or may exist independently without being installed in the electronic device.

[0118] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by an electronic device, the electronic device: performs multi-level image feature extraction on the original defect image to obtain feature maps of the original defect image at different levels; for any feature map, determines the feature vector corresponding to the feature map; after traversing each feature map, fuses each feature vector to obtain a fused feature map; and generates a derived defect image corresponding to the original defect image based on the fused feature map.

[0119] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0120] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0121] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0122] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned defect image generation method, and can solve the technical problem of how to improve the generation quality of defect images to generate more detailed and realistic defect images. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the defect image generation method provided in the above-mentioned embodiment, and will not be repeated here.

[0123] The present application also provides a computer program product, including a computer program, which implements the steps of the defect image generation method as described above when executed by a processor.

[0124] The computer program product provided by the present application can solve the technical problem of how to improve the quality of defect image generation to generate more detailed and realistic defect images. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the defect image generation method provided by the above embodiment, which will not be described in detail here.

[0125] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A defect image generation method, characterized in that: The defect image generating method comprises: Performing multi-level image feature extraction on the original defect image to obtain feature maps of the original defect image at different levels; For any feature map, determine the feature vector corresponding to the feature map; After traversing each feature map, each feature vector is fused to obtain a fused feature map; A derived defect image corresponding to the original defect image is generated based on the fused feature map.

2. The defect image generating method according to claim 1, characterized in that: The step of performing multi-level image feature extraction on the original defect image to obtain feature maps of the original defect image at different levels comprises: The original defect image is used as a feature map to be encoded, and multiple convolution operations are performed on the feature map to be encoded to obtain a pooled feature map of the feature map to be encoded at the current level; Performing a pooling operation on the feature map to be pooled to obtain a feature map to be encoded at the next level, and returning to execute the step of performing multiple convolution operations on the feature map to be encoded; After traversing each level, the feature maps of the original defect image at different levels are obtained based on the feature maps to be pooled at each level.

3. The defect image generating method according to claim 2, characterized in that: The step of obtaining the feature maps of the original defect image at different levels based on the feature maps to be pooled at each level includes: For a feature map to be pooled at any level, weighted averaging is performed on the feature submaps at each depth in the feature map to be pooled to obtain an average feature map; After traversing each feature map to be pooled, each average feature map is used as the feature map of the original defect image at different levels.

4. The defect image generating method according to claim 1, characterized in that: The step of determining the feature vector corresponding to the feature map comprises: Flattening the feature map to obtain a multidimensional vector corresponding to the feature map, wherein the dimension of the multidimensional vector is determined based on the size of the feature map; The multidimensional vector is sampled at the highest dimension in each level to obtain a feature vector corresponding to the feature map.

5. The defect image generating method according to claim 4, characterized in that: The step of sampling the multidimensional vector corresponding to the highest dimension in each level to obtain the feature vector corresponding to the feature map comprises: Inputting the multidimensional vector into a preset fully connected layer to generate a candidate vector corresponding to the highest dimension in each layer through the preset fully connected layer; The generated random noise is obtained, and a feature vector corresponding to the feature map is determined based on the candidate vector and the random noise.

6. The defect image generating method according to claim 5, characterized in that: The defect image generating method further comprises: A loss function is constructed according to the candidate vector, and model parameters in a preset convolutional layer and a preset fully connected layer are trained based on the loss function, wherein the preset convolutional layer is used to perform a convolution operation.

7. The defect image generating method according to claim 1, characterized in that: The step of fusing the feature vectors to obtain a fused feature map comprises: For any feature vector, convert the feature vector into a candidate feature map; After traversing each feature vector, each candidate feature map is concatenated to obtain a fused feature map.

8. The defect image generating method according to claim 1, characterized in that: The step of generating a derived defect image corresponding to the original defect image based on the fused feature map comprises: The fused feature map is used as a feature map to be decoded, and multiple convolution operations are performed on the feature map to be decoded to obtain a feature map to be interpolated at the current level of the feature map to be decoded; Performing a linear interpolation operation on the feature map to be interpolated to obtain a feature map to be decoded at an upper level of the feature map to be interpolated, and returning to the step of performing multiple convolution operations on the feature map to be decoded; After the feature map to be decoded undergoes convolution operations and linear interpolation operations at various levels, a target feature map is obtained, and a derived defect image corresponding to the original defect image is generated based on the target feature map.

9. An electronic device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the defect image generating method according to any one of claims 1 to 7.

10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the defect image generation method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Image processing method and apparatus, equipment, and storage medium

    CN108830322A

  • Industrial defect image generation method and device, equipment and storage medium

    CN117671431A

  • Method, device and equipment for expanding defect sample and storage medium

    CN117710371A

  • Image processing method and device based on multi-level feature extraction, equipment and storage medium

    CN118691845A