Axial space-based defect detection method
By constructing an axial feature space and a Manhattan distance metric, the problems of high computational complexity and large memory consumption in existing methods are solved, achieving efficient defect detection and model iteration, and improving the adaptability of training data and detection accuracy.
Patent Information
- Application Number
- CN202410492236.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-23
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2044-04-23
AI Technical Summary
Existing defect detection methods have high computational complexity and large memory consumption during training, and cannot be effectively iterated, making them difficult to adapt to multi-tasking and automation requirements. Furthermore, the memory bank built by the PatchCore solution after training cannot effectively include information from newly added training data.
By constructing an axial feature space, training with positive sample images, using Manhattan distance to measure feature difference, and combining data augmentation and normalization, an axial feature space is constructed to describe all sample information, reducing computational cost and supporting model iteration.
It achieves efficient defect detection, reduces computational complexity and memory usage, supports model iteration, and improves the versatility of training data and detection accuracy.
Smart Images

Figure CN118351085B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of industrial product defect detection technology, and specifically provides a defect detection method based on axial space. Background Technology
[0002] Automated detection of defective parts has always been a challenging problem in large-scale industrial manufacturing. Traditional methods mainly rely on manually designed rules or the knowledge of domain experts, which have limitations in dealing with diverse and large-scale production. With the development of deep learning, many successful methods have emerged in the field of computer vision; however, in some cases, only normal samples are available for training, which introduces the so-called cold start problem.
[0003] Following the approach described by Karsten Roth et al. in their paper "Towards Total Recall in Industrial Anomaly Detection," researchers have attempted various methods to address the cold start problem. Some of these methods are hand-designed, customizing rules for each category, but their generality is limited, making them difficult to adapt to the demands of multi-tasking and automation. One of the most successful methods combines embeddings from ImageNet models with anomaly detection models. The core idea of this approach is to extract feature embeddings using pre-trained ImageNet models and then combine them with anomaly detection models to identify potential defects.
[0004] The PatchCore approach introduces a K-center greedy algorithm, using a highly representative repository of normal patch features, called a memory bank. The key innovation lies in constructing a memory bank embedded with normal image patch features, which helps the model better understand image content under normal conditions. During testing, PatchCore first extracts image features using a deep network, then measures the distance between the extracted features and the memory bank to determine whether defects exist in the region of the image. This technique achieves excellent detection and localization performance while maintaining inference time. However, the PatchCore approach constructs a feature space during training using a K-center greedy method. This training process is highly limited, computationally intensive, memory-intensive, and restricts the number of images used for training. Furthermore, after training, PatchCore calculates a memory bank, which represents the set of correct samples using Euclidean distance. This memory bank is difficult to understand and describe. Therefore, PatchCore approximates this space using core points. The drawback of this approach is that during model iteration, even with the addition of effective training data, the final memory bank derived through the K-center greedy search may not contain the newly added effective training data, leading to model iteration failure. During testing, PatchCore first extracts image features and then compares these features with the trained memory bank, a process that is extremely time-consuming. Summary of the Invention
[0005] To address the aforementioned problems, this invention provides a defect detection method based on axial space. It trains a defect detection model using positive sample images to construct an axial feature space. By comparing the feature dimension of the test image with the zero Manhattan distance of the axial feature space, it determines whether the test image is a defective image. This effectively solves the problems of existing methods, such as difficulty in describing the feature space, high computational complexity, large memory consumption, and inability to perform model iteration.
[0006] The defect detection method based on axial space provided by this invention includes:
[0007] S1: Label the images in the training dataset as positive sample images and defect images, and all positive sample images constitute the positive sample set;
[0008] S2: Perform data augmentation on the positive sample images in the positive sample set;
[0009] S3: Normalize the positive sample images in the positive sample set;
[0010] S4: Use positive sample images from the positive sample set for training. Input the positive sample images into the feature extractor and output the feature cube. The feature cube is represented as [length, width, feature dimension];
[0011] The feature cube is divided into sub-feature cubes with length x width per pixel. The sub-feature cube is represented as [1, 1, feature dimension]. Each feature dimension of each sub-feature cube corresponds to a feature vector value.
[0012] All feature cubes are represented as: a two-dimensional space with the feature dimension as the first coordinate axis and the feature vector value as the second coordinate axis. The interval from the minimum feature vector value to the maximum feature vector value of each feature dimension is the axial feature space. The axial feature spaces of all feature dimensions are obtained by statistics.
[0013] S5: Perform data augmentation and normalization on the test images in the test dataset, and input them into the feature extractor to obtain the feature cube of the test image. Calculate the Manhattan distance between the feature vector value corresponding to each feature dimension of each pixel of the test image and the axial feature space.
[0014] S6: Calculate the distance representation value corresponding to each pixel in the test image. The method for calculating the distance representation value is as follows:
[0015] Calculate the sum of all Manhattan distances across all feature dimensions for each pixel, and use this sum as the distance representation value;
[0016] Alternatively, calculate the average of the non-zero Manhattan distances across all feature dimensions for each pixel, and use this as the distance representation value;
[0017] Alternatively, sort the non-zero Manhattan distances of all feature dimensions of each pixel, and calculate the sum of n consecutive non-zero Manhattan distances according to the sorting, as the distance representation value;
[0018] Alternatively, the largest Manhattan distance among all feature dimensions of each pixel can be used as the distance representation value;
[0019] S7: Based on the distance representation value corresponding to each pixel in the test image, determine whether the test image is a defective image, and output a distance heatmap representing the distance representation value corresponding to each pixel.
[0020] Preferably, in S2, data augmentation includes increasing the contrast of the positive sample image, changing the size of the positive sample image, and / or cropping the positive sample image.
[0021] Preferably, in S3, the normalization process is a batch normalization method, a layer normalization method, a group normalization method, or an instance normalization method.
[0022] Preferably, the normalization process is a sample normalization method, and the sample normalization process is as follows:
[0023] Set the parameter range to calculate the pixel mean of the positive sample image. Subtract the pixel mean from each pixel of the positive sample image and then divide by the parameter range.
[0024] Preferably, the Manhattan distance between the feature vector value corresponding to each feature dimension of each pixel in the test image and the axial feature space is calculated as follows:
[0025] Determine the feature vector value y corresponding to the feature dimension. i The maximum eigenvector value y in the axial feature space i-max and the minimum eigenvector value y i-min ;
[0026] If y i-min ≤y i ≤y i-max Manhattan is far from dist i =0;
[0027] If y i-max ≤y i Manhattan is far from dist i =y i -y max ;
[0028] If y i ≤y i-min Manhattan is far from dist i =y i-min -y i .
[0029] Preferably, the method for determining whether a test image is a defective image is as follows:
[0030] Calculate the sum of the distance representation values corresponding to all pixels in the test image, set a judgment threshold, and if the sum is greater than the threshold, the test image is judged as a defective image; if the sum is less than or equal to the threshold, the test image is judged as a normal image.
[0031] Alternatively, calculate the average distance representation value corresponding to all pixels in the test image, set a judgment threshold, and if the average value is greater than the threshold, the test image is judged as a defective image; if the average value is less than or equal to the threshold, the test image is judged as a normal image.
[0032] Alternatively, sort the distance representation values corresponding to all pixels in the test image, calculate the average of n consecutive distance representation values according to the sorting, set a judgment threshold, and if the average value is greater than the threshold, the test image is judged as a defective image; if the average value is less than or equal to the threshold, the test image is judged as a normal image.
[0033] Alternatively, determine the maximum value among all distance representation values corresponding to all pixels in the test image, set a judgment threshold, and if the maximum value is greater than the threshold, the test image is judged as a defective image; if the maximum value is less than or equal to the threshold, the test image is judged as a normal image.
[0034] Preferred options also include:
[0035] S8: Statistically analyze test images that were judged as defective images in S7 but are actually normal images. Incorporate the misjudged test images into the positive sample set and re-execute S2 to S4; or, incorporate the misjudged test images into the training dataset and re-execute S1 to S4.
[0036] Compared with the prior art, the present invention can achieve the following beneficial effects:
[0037] Compared to the existing PatchCore approach, this invention performs data augmentation and normalization on the original data during the training phase, enriching data diversity while making the data distribution more concentrated and reducing the degree of difference between data, which facilitates subsequent feature extraction and defect identification. By constructing an axial feature space from all positive sample images, this invention can effectively integrate all sample information into the space, making the training iteration process more efficient. This invention uses Manhattan distance to measure feature difference, reducing the amount of computation. In actual execution, the system memory space usage is small, there is no limit to the number of images in the training dataset, and the training time is much shorter than existing methods. Attached Figure Description
[0038] Figure 1 This is a flowchart of a defect detection method based on axial space provided according to an embodiment of the present invention;
[0039] Figure 2 It is a superimposed diagram of axial feature spaces with multiple feature dimensions provided in the embodiments of the present invention;
[0040] Figure 3 This is a distance heatmap provided according to an embodiment of the present invention. Detailed Implementation
[0041] In the following description, embodiments of the invention will be described with reference to the accompanying drawings. In the description below, the same modules are denoted by the same reference numerals. Where the same reference numerals are used, their names and functions are also the same. Therefore, their detailed description will not be repeated.
[0042] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and do not constitute a limitation thereof.
[0043] like Figure 1 As shown, the defect detection method based on axial space proposed in this embodiment of the invention mainly includes two parts: model training and testing, specifically including the following steps:
[0044] S1: Before training the model, it is necessary to collect data and create a training dataset. The data in the training dataset are images of industrial products, including but not limited to images of different products or the same product under different angles, positions, poses, backgrounds and / or lighting conditions. Variations in the training set can be artificially increased to improve the model's generalization ability to different positions and angles.
[0045] The training dataset is manually labeled with positive and defective images. All normal, defect-free images are selected and designated as positive images, forming the positive sample set. To ensure the training accuracy of the subsequent defect detection model, the positive sample set has the following requirements:
[0046] 1. First, the number of positive sample images in the positive sample set needs to be of a certain scale. Depending on the complexity of the products to be identified, the number of positive sample images can be tens to thousands. In order to further improve accuracy and versatility, the number of positive sample images can be further increased.
[0047] 2. Positive sample images in a positive sample set typically cover variations of the same object in multiple aspects, including different angles, shapes, light intensities, placement positions, and background environments. Positive sample images can also be uniform bright-field or dark-field images captured by the chip, with the focus on identifying specific regions with different noise levels, where row and column noise exhibit significant differences.
[0048] S2: After manually calibrating the positive sample set, data preprocessing of the positive sample images in the set is required. First, data augmentation of the positive sample images enriches data diversity and improves the generality and training accuracy of the training model. The data augmentation process can be implemented by building modules or networks. The data augmentation methods that modules or networks can use include, but are not limited to, increasing the contrast of positive sample images, resizing positive sample images, and cropping positive sample images. One or more of the above methods can be selected.
[0049] S3: After data augmentation of the positive sample images, normalization processing is required for the positive sample images in the positive sample set. The normalization process can be implemented by building modules or networks. The normalization methods that can be used include, but are not limited to, batch normalization, layer normalization, group normalization, or instance normalization. One or more of these methods can be selected. All of these normalization methods are existing methods. The basic idea of batch normalization is to perform a normalization operation on the input of each layer, that is, subtract the mean from the input and divide by the standard deviation. The basic idea of layer normalization is to normalize the output of each neuron on all samples, so that the output distribution of each neuron has a similar mean and variance. Group normalization is a normalization method between batch normalization and layer normalization. It divides each layer into several groups and performs normalization operations within each group. Furthermore, considering the data processing requirements, this embodiment of the invention also provides a sample normalization method. In actual operation, a parameter `range` needs to be manually set, and then the pixel mean of each positive sample image is calculated. The mean pixel value is subtracted from each pixel of the positive sample image, and then divided by the set parameter `range` to complete the normalization process. The parameter `range` is a manually set parameter used for normalization. This parameter is obtained by calculating the average of the standard deviations of all positive sample images. Its purpose is to ensure that the result obtained after subtracting the pixel mean from each pixel of the positive sample image and dividing by the set parameter `range` is within a small range, ensuring that the input positive sample images are of the same order of magnitude and avoiding disproportionate influence of certain features on model training due to different image scales. Typically, this small range can be 0 to 1.
[0050] S4: After completing the labeling and preprocessing of the positive sample set, the positive sample set is used as training data and input into the feature extractor. The feature extractor is trained using the positive sample images in the positive sample set. The feature extractor can be based on the following feature extraction methods:
[0051] 1. Traditional image feature extraction methods are mainly used to extract color features, texture features, shape features, etc.
[0052] 2. Deep network feature extraction methods typically refer to feature extraction using convolutional neural networks. For example, ResNet18 and WideResNet50 are two deep neural network architectures, belonging to the ResNet and WideResNet series respectively. These two architectures perform well in computer vision tasks such as image classification, have different design characteristics, and offer numerous variations in their network architecture.
[0053] 3. Deep feature extraction network based on transformer self-attention mechanism.
[0054] Multiple feature extractors can be selected simultaneously, or a single feature extractor with multiple feature extraction methods can be used to extract features from different dimensions of the image. After selecting a feature extractor or feature extraction method, a positive sample image is input into the feature extractor, resulting in features with multiple dimensions, primarily length, width, and feature dimension. Each feature extractor produces a three-dimensional feature cube. Taking a deep network feature extractor as an example, using WideResNet50 to output the features of layer 2 and layer 3 respectively will yield two feature cubes. Concatenating these two feature cubes along their feature dimensions completes the feature concatenation operation. For example, feature cube a has dimensions [length h, width w, feature dimension m], and feature cube b has dimensions [length h, width w, feature dimension n]. The concatenated feature cube c has dimensions [length h, width w, feature dimension m + feature dimension n]. Feature cube c can be considered to effectively contain the features of both feature cubes a and b, facilitating subsequent calculations.
[0055] Furthermore, during feature stitching, feature cubes a and b may have inconsistent lengths and widths. To ensure successful stitching, upsampling or downsampling methods can be used to unify the feature sizes. Upsampling methods include nearest neighbor interpolation, bilinear interpolation, bicubic interpolation, bilateral interpolation, and trilinear interpolation. Downsampling methods mainly include average pooling, stride convolution, subsampling, and max pooling.
[0056] The resulting feature cube after stitching is represented as [length, width, feature dimension]. The feature cube is then divided into sub-feature cubes (length x width) for each pixel. Each sub-feature cube is represented as [1, 1, feature dimension]. Each feature dimension of each sub-feature cube corresponds to a feature vector value, and each sub-feature cube corresponds to a pixel in the input positive sample image. All feature cubes are represented as a two-dimensional space with the feature dimension as the first coordinate axis and the feature vector value as the second coordinate axis, i.e., the coordinate space of the X and Y axes. The interval from the minimum to the maximum feature vector value of each feature dimension is the axial feature space. The axial feature space is iteratively updated for each pixel. Features of all dimensions of all positive sample images are superimposed in the same attached image. For example, if the feature dimension is 1500, then the x-axis represents dimension 0-1500, and the y-axis represents the magnitude of the feature vector value. By continuously superimposing, a feature cube can be obtained as shown below. Figure 2 The axial feature space is shown.
[0057] Constructing the axial feature space for each dimension requires the use of a completion method, as each axial feature space consists of multiple points. The axial feature space for this dimension is defined by the minimum to maximum y-value among these points, i.e., the minimum to maximum eigenvector value. This space describes the set of all positive sample images in this dimension. By traversing from the minimum to the maximum eigenvector value in each dimension, the axial feature spaces for all dimensions are statistically calculated, thus completing the training of the defect detection model composed of the data augmentation module, normalization module, and feature processor.
[0058] S5: In the entire defect identification process, each independent project only needs to be trained once. After training and building the model, the training effect needs to be tested. During the testing process, this defect detection model is repeatedly applied.
[0059] During testing, the first step is to determine the test dataset, which typically consists of a portion of the training dataset. First, the test images in the test dataset undergo the same data augmentation and normalization processes as during training. These normalized test images are then input into a feature extractor, which is consistent with the feature extractor used during training. The feature extractor obtains the feature cube [length, width, feature dimension] of the test image, which can be transformed into [length x width, feature dimension]. Then, iterates through the product of the length and width of all test images, independently calculating the distance between the features of each region of the test image and its axial space. This region can be measured in pixels, or, when lower precision is required, in n×n pixel regions. In this embodiment, pixels are used as an example. The distance between each region and its corresponding axial feature space is calculated separately. The axial feature space has multiple feature dimensions, and the distance for each feature dimension needs to be calculated independently. Specifically, the Manhattan distance between the feature vector value corresponding to each feature dimension of each pixel in the test image and the axial feature space is calculated. Using the Manhattan distance as a metric not only accurately reflects the deviation between the feature vector value of the test image and the axial feature space, but also significantly reduces computational complexity and space consumption. The present invention provides a specific calculation method for calculating the Manhattan distance between the feature vector value corresponding to each feature dimension of each pixel in the test image and the axial feature space:
[0060] First, find the feature vector value y corresponding to the feature dimension. i Find the largest eigenvector value y corresponding to this feature dimension in the axial feature space. i-max and the minimum eigenvector value y i-min ;
[0061] If y i-min ≤y i ≤y i-maxAt this time, Manhattan is far from dist i =0;
[0062] If y i-max ≤y i At this time, Manhattan is far from dist i =y i -y max ;
[0063] If y i ≤y i-min At this time, Manhattan is far from dist i =y i-min -y i .
[0064] S6: Calculate the Manhattan distance between the feature vector value corresponding to each feature dimension of each pixel and the axial feature space using S5. Then define a distance representation value for each pixel in the test image to represent the deviation between the feature vector value corresponding to each feature dimension of each pixel and the axial feature space, for subsequent defect judgment. The distance representation value can be calculated using one of the following methods:
[0065] 1. Calculate the sum of all Manhattan distances across all feature dimensions for each pixel, and use this sum as the distance representation value;
[0066] 2. Calculate the average of the non-zero Manhattan distances across all feature dimensions for each pixel, and use this as the distance representation value;
[0067] 3. Sort the non-zero Manhattan distances of all feature dimensions of each pixel, and calculate the sum of n consecutive non-zero Manhattan distances according to the sorting, as the distance representation value; usually, the sum of the first n larger non-zero Manhattan distances is selected as the distance representation value.
[0068] 4. Use the largest Manhattan distance among all feature dimensions of each pixel as the distance representation value.
[0069] The above results in a distance equal to the length multiplied by the width of the image. Each distance represents the Manhattan distance of a specific region of the image from the axial feature space of the positive sample. The larger the distance value, the higher the probability that the physical meaning of the test image is abnormal; the smaller the distance value, the lower the probability that the physical meaning of the test image is abnormal.
[0070] S7: Based on the distance representation value corresponding to each pixel in the test image, determine whether the test image is a defective image. The following methods can typically be used to determine whether an image is defective:
[0071] 1. Calculate the sum of the distance representation values corresponding to all pixels in the test image, set a judgment threshold, if the sum is greater than the threshold, the test image is judged as a defective image; if the sum is less than or equal to the threshold, the test image is judged as a normal image.
[0072] 2. Calculate the average distance representation value corresponding to all pixels in the test image, and set a judgment threshold. If the average value is greater than the threshold, the test image is judged as a defective image; if the average value is less than or equal to the threshold, the test image is judged as a normal image.
[0073] 3. Sort the distance representation values corresponding to all pixels in the test image, and calculate the average of n consecutive distance representation values according to the sorting. Typically, the average of the first n consecutive larger distance representation values is chosen, or the average of all distance representation values greater than a certain distance representation value is selected. A judgment threshold is set; if the average value is greater than the threshold, the test image is judged as a defective image; if the average value is less than or equal to the threshold, the test image is judged as a normal image.
[0074] 4. Determine the maximum value among the distance representation values corresponding to all pixels in the test image, and set a judgment threshold. If the maximum value is greater than the threshold, the test image is judged as a defective image; if the maximum value is less than or equal to the threshold, the test image is judged as a normal image.
[0075] The threshold in the above method can be set using existing evaluation methods, typically determined based on the accuracy score of the judgment results. Specifically, during testing, possible thresholds are set, and for each possible threshold, the F1 Score (harmonic mean of precision and recall) of the judgment results is calculated. The F1 Score corresponding to all possible thresholds is iterated through, and the threshold corresponding to the optimal F1 Score is obtained. This threshold is used as the threshold for judging defective images during testing. This threshold ensures that the model achieves optimal performance on the test dataset.
[0076] The final output consists of two parts: a label indicating whether the input image is defective, and a distance heatmap representing the distance representation value for each pixel. This visualizes the output set [length, width, distance representation value] for each region of the image. After contrast adjustment, the result is as follows: Figure 3 The distance heatmap shown makes it easy to see which areas in the image have defects, and to judge the degree of defects by color saturation or brightness.
[0077] S8: After the testing process in S7, there may be erroneous outputs that classify normal images as defective images. Therefore, in defect detection of industrial products, the training and testing process will not be performed only once. Through continuous industrial practice, iterative optimization of the model is necessary. Iterating the model involves repeated training. Compared to the existing Patchcore defect detection scheme, the method proposed in this invention has no limit on the amount of training data and can repeatedly train the data to iteratively update the model. The existing Patchcore scheme has strict limitations on the amount of training data and is difficult to describe in terms of feature space. Even if the effective number of training data is increased, the memory bank of points obtained by the K-center greedy search may not contain the information from the increased training data, leading to model iteration failure.
[0078] The model iteration process in this embodiment of the invention is as follows:
[0079] During statistical testing, test images that are actually normal images are judged as defective images in S7. These misjudged test images are integrated into the positive sample set, and S2 to S4 are re-executed for training. Testing is then performed again after training is complete. Alternatively, the misjudged test images can be added to the training dataset, and S1 to S4 are re-executed. Testing is then performed again after training is complete. This invention not only effectively describes data characteristics in axial feature space, but the process of calculating the axial feature space is also simple, requires very little memory, and even with repeated iterations, the ever-expanding training set does not affect the feasibility of training.
[0080] Although embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.
[0081] The specific embodiments of the present invention described above do not constitute a limitation on the scope of protection of the present invention. Any other corresponding changes and modifications made in accordance with the technical concept of the present invention should be included within the scope of protection of the claims of the present invention.
Claims
1. A defect detection method based on axial space, characterized in that, include: S1: Label the images in the training dataset as positive sample images and defect images, and all positive sample images constitute the positive sample set; S2: Perform data augmentation on the positive sample images in the positive sample set; S3: Normalize the positive sample images in the positive sample set; S4: Use the positive sample images in the positive sample set for training, input the positive sample images into the feature extractor and output the feature cube, the feature cube being represented as [length, width, feature dimension]; The feature cube is divided into length-width sub-feature cubes with each pixel as the unit. The sub-feature cube is represented as [1, 1, feature dimension]. Each feature dimension of each sub-feature cube corresponds to a feature vector value. All feature cubes are represented as: a two-dimensional space with the feature dimension as the first coordinate axis and the feature vector value as the second coordinate axis. The interval from the minimum feature vector value to the maximum feature vector value of each feature dimension is the axial feature space. The axial feature spaces of all feature dimensions are obtained by statistics. S5: Perform data augmentation and normalization on the test images in the test dataset, and input them into the feature extractor to obtain the feature cube of the test image. Calculate the Manhattan distance between the feature vector value corresponding to each feature dimension of each pixel of the test image and the axial feature space. S6: Calculate the distance representation value corresponding to each pixel in the test image. The method for calculating the distance representation value is as follows: Calculate the sum of all Manhattan distances across all feature dimensions for each pixel, and use this sum as the distance representation value; Alternatively, calculate the average of the non-zero Manhattan distances across all feature dimensions for each pixel, and use this as the distance representation value; Alternatively, sort the non-zero Manhattan distances of all feature dimensions of each pixel, and calculate the sum of n consecutive non-zero Manhattan distances according to the sorting, as the distance representation value; Alternatively, the largest Manhattan distance among all feature dimensions of each pixel can be used as the distance representation value; S7: Based on the distance representation value corresponding to each pixel in the test image, determine whether the test image is a defective image, and output a distance heatmap representing the distance representation value corresponding to each pixel.
2. The defect detection method based on axial space as described in claim 1, characterized in that, In S2, the data enhancement includes increasing the contrast of the positive sample image, changing the size of the positive sample image, and / or cropping the positive sample image.
3. The defect detection method based on axial space as described in claim 1, characterized in that, In S3, the normalization process is a batch normalization method, a layer normalization method, a group normalization method, or an instance normalization method.
4. The defect detection method based on axial space as described in claim 1, characterized in that, The normalization process is a sample normalization method, and the process of the sample normalization method is as follows: Set the parameter range to calculate the pixel mean of the positive sample image. Subtract the pixel mean from each pixel of the positive sample image and then divide by the parameter range.
5. The defect detection method based on axial space as described in claim 1, characterized in that, The Manhattan distance between the feature vector value corresponding to each feature dimension of each pixel in the test image and the axial feature space is calculated as follows: Determine the feature vector value y corresponding to the feature dimension. i The maximum eigenvector value y in the axial feature space i-max and the minimum eigenvector value y i-min ; If y i-min ≤y i ≤y i-max Manhattan is far from dist i =0; If y i-max ≤y i Manhattan is far from dist i =y i -y max ; If y i ≤y i-min Manhattan is far from dist i =y i-min -y i .
6. The defect detection method based on axial space as described in claim 1, characterized in that, The method for determining whether a test image is a defect image is as follows: Calculate the sum of the distance representation values corresponding to all pixels in the test image, set a judgment threshold, and if the sum is greater than the threshold, the test image is judged as a defective image; if the sum is less than or equal to the threshold, the test image is judged as a normal image. Alternatively, calculate the average distance representation value corresponding to all pixels in the test image, set a judgment threshold, and if the average value is greater than the threshold, the test image is judged as a defective image; if the average value is less than or equal to the threshold, the test image is judged as a normal image. Alternatively, sort the distance representation values corresponding to all pixels in the test image, calculate the average of n consecutive distance representation values according to the sorting, set a judgment threshold, and if the average value is greater than the threshold, the test image is judged as a defective image; if the average value is less than or equal to the threshold, the test image is judged as a normal image. Alternatively, determine the maximum value among all distance representation values corresponding to all pixels in the test image, set a judgment threshold, and if the maximum value is greater than the threshold, the test image is judged as a defective image; if the maximum value is less than or equal to the threshold, the test image is judged as a normal image.
7. The defect detection method based on axial space as described in claim 6, characterized in that, Also includes: S8: Count the test images that were judged as defective images in S7 but are actually normal images, and add the misjudged test images to the positive sample set, and re-execute S2 to S4; or, add the misjudged test images to the training dataset, and re-execute S1 to S4.
Citation Information
Patent Citations
Medical image organ recognition method and segmentation method
CN105389813A
Defect detection method and device, equipment and storage medium
CN115239672A
