Product quality inspection artificial intelligence identification method and system
Patent Information
- Application Number
- CN202611022722.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-10
- Publication Date
- 2026-10-30
AI Technical Summary
[0002]在工业制造领域,产品表面质量检测是保障出厂合格率的关键环节,传统的人工目视检测方法效率低下、标准不一且成本高昂,因此基于机器视觉与人工智能的自动光学检测技术已成为行业主流发展方向
本申请提供的产品质检的人工智能识别方法及系统中,首先,获取待检产品的表面图像,提取所述表面图像的多尺度深度特征,并将所述多尺度深度特征与预设的标准深度特征进行比对,生成表征语义级异常可能性的特征异常置信图,该步骤可对待检图像的无监督深度语义分析,通过与正常特征原型比对,量化其在特征空间上的语义偏离,从而提高了对复杂、与上下文不符的语义级异常,如结构畸变、错误部件的感知与发现能力;其次,对所述表面图像进行多通道的低级图像信号分析,得到信号残差图,并对所述信号残差图进行后处理,生成表征物理信号级异常可能性的像素级异常指示图,该步骤可对待检图像多维度物理信号,如梯度、纹理、对比度的鲁棒分析与精确定位,有效抑制光照、噪声等非相关干扰,从而提高了对划痕、污渍、凹坑等物理缺陷的检出率与定位精度;随后,确定所述特征异常置信图与所述像素级异常指示图中各个候选异常区域的异常互相关值,该步骤可对每个可疑区域内语义异常线索与物理异常信号空间分布一致性的客观量化,为双重验证提供可计算的协同度指标,从而提高了后续融合决策环节的依据可靠性与自动化水平;然后,对于每个异常候选区域,若异常互相关值高于预设的第一阈值,则依据所述特征异常置信图对对应的异常候选区域进行缺陷判定,若异常互相关值低于所述第一阈值,但对应的候选异常区域在所述特征异常置信图和所述像素级异常指示图中有任一对应的异常分数高于第二阈值,则依据对应候选异常区域的局部上下文信息进行综合缺陷判定,该步骤可基于证据一致性高低的差异化智能决策,即证据一致时快速采纳高置信结果,证据矛盾但单边强烈时启动上下文仲裁,从而提高了在处理明确缺陷与边缘疑难案例时的综合准确性与稳健性;最后,基于所有候选异常区域的缺陷判定结果生成最终的缺陷分割图,该步骤可将所有分散的判定结果整合、优化并转化为一张标准化的缺陷位置标注图,直观呈现所有被确认缺陷的精确形状与位置,从而提高了检测结果的可视化程度及与后续自动化分拣、统计环节的衔接效率;综上所述,本申请的方案可基于像素级精确感知与特征级语义理解对待检测产品进行缺陷识别。
Smart Images

Figure CN123015384A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent recognition technology, and in particular to an artificial intelligence recognition method and system for product quality inspection. Background Technology
[0002] In the industrial manufacturing sector, product surface quality inspection is a key step in ensuring the pass rate of products leaving the factory. Traditional manual visual inspection methods are inefficient, inconsistent in standards, and expensive. Therefore, automated optical inspection technology based on machine vision and artificial intelligence has become the mainstream development direction in the industry.
[0003] Currently, intelligent quality inspection methods can be mainly divided into two categories: supervised learning-based defect classification and detection methods, and unsupervised or weakly supervised anomaly detection methods. However, existing technologies still have significant limitations. For example, methods relying solely on deep semantic features may be insensitive to minor physical scratches, while methods relying solely on low-level pixel signals are easily affected by unrelated changes such as uneven lighting and background texture, resulting in a large number of false alarms. Furthermore, when attempting to fuse pixel-level and feature-level information to improve robustness, existing fusion strategies are often rather crude, such as simple weighted averaging or logical AND / OR operations. These strategies lack a quantitative assessment of the credibility of the two heterogeneous pieces of evidence and their consistency, and cannot adaptively adjust according to specific detection scenarios, such as defect type and image signal-to-noise ratio. Therefore, how to identify defects in products under inspection based on pixel-level accurate perception and feature-level semantic understanding has become a challenge for the industry. Summary of the Invention
[0004] Based on this, this application provides an artificial intelligence identification method and system for product quality inspection that identifies defects in products to be inspected based on pixel-level precise perception and feature-level semantic understanding.
[0005] In a first aspect, this application provides an artificial intelligence recognition method for product quality inspection, comprising the following steps: Obtain a surface image of the product to be inspected; Extract multi-scale depth features from the surface image and compare the multi-scale depth features with preset standard depth features to generate a feature anomaly confidence map representing the possibility of semantic-level anomalies. Multi-channel low-level image signal analysis is performed on the surface image to obtain a signal residual map, and the signal residual map is post-processed to generate a pixel-level anomaly indicator map characterizing the possibility of physical signal-level anomalies. Determine the cross-correlation value of each candidate anomaly region in the feature anomaly confidence map and the pixel-level anomaly indicator map; For each candidate region of anomaly, if the cross-correlation value of anomaly is higher than a preset first threshold, then the corresponding candidate region of anomaly is judged for defect based on the feature anomaly confidence map. If the cross-correlation value of anomaly is lower than the first threshold, but the corresponding candidate region of anomaly has any corresponding anomaly score higher than the second threshold in the feature anomaly confidence map and the pixel-level anomaly indicator map, then the corresponding candidate region of anomaly is judged for defect based on the local context information of the corresponding candidate region of anomaly. The final defect segmentation map is generated based on the defect determination results of all candidate abnormal regions.
[0006] In some embodiments, extracting multi-scale depth features from the surface image specifically includes: Load a pre-trained multi-scale feature extraction network; The surface image is input into the multi-scale feature extraction network for forward propagation; From the outputs of different specified intermediate layers of the multi-scale feature extraction network, feature maps corresponding to different abstraction levels and spatial scales are extracted to obtain multi-scale deep features.
[0007] In some embodiments, comparing the multi-scale depth features with preset standard depth features to generate a feature anomaly confidence map representing the possibility of semantic-level anomalies specifically includes: Obtain the standard depth features corresponding to the multi-scale depth features; Determine the feature distance between different feature maps and corresponding standard depth features in the multi-scale depth features; All feature distances are upsampled to the original spatial dimensions of the surface image and then fused. The fused distance map is normalized to a preset numerical range to generate a feature anomaly confidence map representing the probability of semantic-level anomalies.
[0008] In some embodiments, performing multi-channel low-level image signal analysis on the surface image to obtain a signal residual map specifically includes: Select multiple low-level image analysis channels related to the physical properties of surface defects; Determine the characteristic response map of the surface image in each low-level image analysis channel; Each feature response map is compared with the corresponding baseline response map pre-established based on normal samples to generate preliminary residual maps for each low-level image analysis channel. By fusing all the preliminary residual maps, the signal residual map is obtained.
[0009] In some embodiments, post-processing the signal residual map to generate a pixel-level anomaly indication map characterizing the probability of physical signal-level anomalies specifically includes: Adaptive threshold segmentation is performed on the signal residual map to obtain the initial binarized outlier region; A morphological opening operation is performed on the initial binarized outlier region to filter out isolated noise points; A morphological closing operation is performed on the abnormal regions after the morphological opening operation to connect adjacent fragmented abnormal regions and form connected candidate abnormal patches. Based on connected candidate anomalous patches, a pixel-level anomalous indication map is generated to characterize the probability of physical signal-level anomalousness.
[0010] In some embodiments, determining the cross-correlation value of each candidate anomaly region in the feature anomaly confidence map and the pixel-level anomaly indication map specifically includes: Based on the pixel-level anomaly indication map, connected candidate anomaly patches are identified and located to determine the spatial range of multiple candidate anomaly regions. Extract the pixel value matrix of the region corresponding to each candidate anomaly region from the feature anomaly confidence map and the pixel-level anomaly indicator map, respectively; Determine the normalized cross-correlation coefficient between the two pixel value matrices corresponding to each candidate anomaly region, and then use the normalized cross-correlation coefficient as the anomaly cross-correlation value of the corresponding candidate anomaly region.
[0011] In some embodiments, generating the final defect segmentation map based on the defect determination results of all candidate anomaly regions specifically includes: Read the global list of defect determination results; Initialize a blank image with the same size as the surface image as the base segmentation map; Traverse the defect judgment result list, and draw the corresponding defect area on the basic segmentation map according to the judgment result and area location information of each record in the defect judgment result list; The completed basic segmentation map is post-processed and optimized to generate and output the final defect segmentation map.
[0012] Secondly, this application provides an artificial intelligence recognition system for product quality inspection, comprising: The acquisition module is used to acquire surface images of the product to be inspected. The processing module is used to extract multi-scale depth features from the surface image and compare the multi-scale depth features with preset standard depth features to generate a feature anomaly confidence map representing the possibility of semantic-level anomalies. The processing module is also used to perform multi-channel low-level image signal analysis on the surface image to obtain a signal residual map, and to perform post-processing on the signal residual map to generate a pixel-level anomaly indication map characterizing the possibility of physical signal-level anomalies. The processing module is further configured to determine the cross-correlation value of each candidate anomaly region in the feature anomaly confidence map and the pixel-level anomaly indication map; The processing module is further configured to, for each abnormal candidate region, if the abnormal cross-correlation value is higher than a preset first threshold, then perform defect determination on the corresponding abnormal candidate region based on the feature abnormality confidence map; if the abnormal cross-correlation value is lower than the first threshold, but the corresponding candidate abnormal region has any corresponding abnormal score higher than the second threshold in the feature abnormality confidence map and the pixel-level abnormality indicator map, then perform comprehensive defect determination based on the local context information of the corresponding candidate abnormal region. The execution module is used to generate the final defect segmentation map based on the defect determination results of all candidate abnormal regions.
[0013] Thirdly, this application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described artificial intelligence identification method for product quality inspection.
[0014] Fourthly, this application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described artificial intelligence identification method for product quality inspection.
[0015] The technical solutions provided by the embodiments disclosed in this application have the following beneficial effects: The product quality inspection artificial intelligence recognition method and system provided in this application first acquires a surface image of the product to be inspected, extracts multi-scale depth features from the surface image, and compares the multi-scale depth features with preset standard depth features to generate a feature anomaly confidence map representing the possibility of semantic-level anomalies. This step enables unsupervised deep semantic analysis of the image to be inspected, quantifying its semantic deviation in the feature space by comparing it with normal feature prototypes, thereby improving the ability to perceive and detect complex, context-inconsistent semantic-level anomalies, such as structural distortions and faulty parts. Secondly, multi-channel low-level image signal analysis is performed on the surface image to obtain... The signal residual map is post-processed to generate a pixel-level anomaly indication map characterizing the probability of physical signal-level anomalies. This step enables robust analysis and precise localization of multi-dimensional physical signals in the image under inspection, such as gradient, texture, and contrast, effectively suppressing irrelevant interferences such as illumination and noise, thereby improving the detection rate and localization accuracy of physical defects such as scratches, stains, and dents. Subsequently, the cross-correlation values of the anomaly confidence map and the pixel-level anomaly indication map for each candidate anomaly region are determined. This step objectively quantifies the consistency between semantic anomaly clues and the spatial distribution of physical anomaly signals within each suspicious region, providing calculable data for dual verification. The synergy index improves the reliability and automation of subsequent fusion decision-making processes. Then, for each candidate anomaly region, if the anomaly cross-correlation value is higher than a preset first threshold, a defect determination is made based on the feature anomaly confidence map. If the anomaly cross-correlation value is lower than the first threshold, but the corresponding candidate anomaly region has an anomaly score higher than a second threshold in either the feature anomaly confidence map or the pixel-level anomaly indicator map, a comprehensive defect determination is made based on the local context information of the corresponding candidate anomaly region. This step allows for differentiated intelligent decision-making based on the consistency of evidence, i.e., when the evidence is consistent, high-consistency evidence is quickly adopted. When the evidence is contradictory but one side is strongly supported, contextual arbitration is initiated, thereby improving the overall accuracy and robustness in handling clear defects and marginal, difficult cases. Finally, based on the defect judgment results of all candidate abnormal regions, a final defect segmentation map is generated. This step integrates, optimizes, and transforms all scattered judgment results into a standardized defect location annotation map, intuitively presenting the precise shape and location of all confirmed defects, thereby improving the visualization of the detection results and the efficiency of connection with subsequent automated sorting and statistical processes. In summary, the solution of this application can identify defects in the product to be inspected based on pixel-level precise perception and feature-level semantic understanding. Attached Figure Description
[0016] Figure 1 This is an exemplary flowchart of an artificial intelligence recognition method for product quality inspection according to some embodiments of this application; Figure 2This is a schematic diagram illustrating an application scenario of a quality inspection intelligent identification data processing system according to some embodiments of this application; Figure 3 This is a schematic flowchart illustrating the generation of feature anomaly confidence maps according to some embodiments of this application; Figure 4 This is a schematic diagram of the structure of an artificial intelligence recognition system for product quality inspection according to some embodiments of this application; Figure 5 This is a schematic diagram of the structure of a computer device for implementing an artificial intelligence recognition method for product quality inspection according to some embodiments of this application. Detailed Implementation
[0017] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific implementation methods.
[0018] refer to Figure 1 The figure is an exemplary flowchart of an artificial intelligence recognition method for product quality inspection according to some embodiments of this application. The artificial intelligence recognition method for product quality inspection mainly includes the following steps: In step 101, a surface image of the product to be inspected is obtained.
[0019] In specific implementation, the surface image of the product to be inspected can be obtained in the following way: one or more high-resolution industrial area array cameras with global shutters are installed above the fixed inspection station on the production line, facing the surface of the product to be inspected, and a ring of LED diffused light sources is arranged around the camera to provide a uniform and stable lighting environment; when the product to be inspected on the conveyor belt arrives at the inspection station, the photoelectric sensor triggers the industrial area array camera to take a synchronous picture, thereby obtaining an original image containing the complete surface of the product to be inspected; subsequently, the original image is subjected to standardized preprocessing, which includes: first, uniformly scaling or cropping the image size to a preset standard resolution, then performing white balance and brightness correction based on a standard whiteboard image placed at the shooting site to eliminate the influence of light color deviation and intensity unevenness, and finally using a Gaussian filter to smooth the image to suppress random noise; the image obtained after the above standardized preprocessing is the surface image with consistent specifications and quality input to subsequent steps. Other methods can also be used in other embodiments, which are not limited here.
[0020] In some embodiments, reference Figure 2As shown in the figure, this figure is a schematic diagram of the application scenario of the quality inspection intelligent identification data processing system shown in some embodiments of this application. The figure includes three main components: acquisition device, server and data storage device. The acquisition device is responsible for collecting surface images of the products to be inspected and sending the collected surface images to the server through the communication network. The quality inspection intelligent identification data processing system runs on the server. The server stores the processing results in the data storage device and visualizes them.
[0021] In step 102, multi-scale depth features of the surface image are extracted, and the multi-scale depth features are compared with preset standard depth features to generate a feature anomaly confidence map representing the possibility of semantic-level anomalies.
[0022] In some embodiments, extracting multi-scale depth features from the surface image can be achieved using the following steps: Load a pre-trained multi-scale feature extraction network; The surface image is input into the multi-scale feature extraction network for forward propagation; From the outputs of different specified intermediate layers of the multi-scale feature extraction network, feature maps corresponding to different abstraction levels and spatial scales are extracted to obtain multi-scale deep features.
[0023] It should be noted that the multi-scale deep features in this application are a set of deep neural network features extracted from product surface images that can simultaneously represent different levels of abstract information such as local details, component structure and global semantics. Their role is to serve as the input basis for semantic-level anomaly perception.
[0024] In specific implementation, the multi-scale feature extraction network can be preset in the following manner: First, a large-scale dataset of normal product surface images is collected as training data; then, a deep convolutional neural network, such as ResNet or VGG, is selected as the basic network architecture; next, on the large-scale normal product surface image dataset, a self-supervised learning task is used to train the basic network architecture, enabling it to learn to extract feature representations that are robust to normal appearance changes on product surfaces and sensitive to anomalies. The self-supervised learning task is, for example, an image restoration task based on context prediction or a contrastive learning task based on invariant features; finally, the trained network is used as the pre-trained multi-scale feature extraction network. In other embodiments, a model pre-trained on a general large-scale image dataset, such as ImageNet, can also be directly used as the basis, and fine-tuned using normal product surface images. This application does not limit this approach.
[0025] In specific implementation, the surface image is input into the multi-scale feature extraction network for forward propagation in the following manner: First, the surface image after standardization preprocessing is converted to the input format required by the multi-scale feature extraction network, for example, by adjusting the image channel order and normalizing the mean and standard deviation; then, the surface image after data format conversion is used as an input tensor and fed into the multi-scale feature extraction network; the multi-scale feature extraction network performs convolution, pooling, nonlinear activation and other operations in sequence according to its inherent connection and calculation relationship between layers to complete the calculation process from the input layer to the output layer, that is, to complete the forward propagation. Other methods can also be used in other embodiments, which are not limited here.
[0026] In specific implementation, feature maps corresponding to different abstraction levels and spatial scales are extracted from the outputs of different specified intermediate layers of the multi-scale feature extraction network to obtain multi-scale depth features. This can be achieved in the following way: during the forward propagation of the multi-scale feature extraction network, the output tensors of its three pre-specified intermediate convolutional layers are simultaneously accessed and truncated. The three intermediate convolutional layers are located near the middle, middle-to-late, and end sections of the network, respectively. This results in the first extracted feature map having high spatial resolution and low semantic abstraction level, mainly encoding local texture details; the second extracted feature map having medium spatial resolution and semantic abstraction level, mainly encoding component-level structural information; and the third extracted feature map having low spatial resolution and high semantic abstraction level, mainly encoding global semantic information. Finally, the feature maps output by the three intermediate convolutional layers are used together as the multi-scale depth features. Other methods can also be used in other embodiments, which are not limited here.
[0027] In some embodiments, reference Figure 3 As shown in the figure, this is a flowchart illustrating the generation of feature anomaly confidence maps in some embodiments of this application. In this embodiment, the multi-scale depth features are compared with preset standard depth features to generate feature anomaly confidence maps representing the possibility of semantic-level anomalies. This can be achieved through the following steps: In step 1031, standard depth features corresponding to the multi-scale depth features are obtained; In step 1032, the feature distance between different feature maps and corresponding standard depth features in the multi-scale depth features is determined; In step 1033, all feature distances are upsampled to the original spatial size of the surface image and then fused. In step 1034, the fused distance map is normalized to a preset numerical range to generate a feature anomaly confidence map representing the possibility of semantic-level anomalies.
[0028] It should be noted that the standard depth features in this application are used to represent the ideal depth feature prototypes that normal products should possess at various scales. Their function is to serve as a comparison benchmark to quantify the deviation of the image under test in the feature space. The feature distance is a scalar value used to quantify the degree of deviation between the local region of the image under test and the normal feature prototype in the depth feature space. The feature anomaly confidence map represents a two-dimensional image of the probability of semantic-level anomalies at the corresponding image location. Its function is to provide anomaly clues based on deep semantic understanding.
[0029] In specific implementation, the corresponding standard depth features can be preset in the following way: First, the pre-trained multi-scale feature extraction network is used to extract features from a large number of defect-free normal product surface images to obtain the multi-scale depth features of each normal image corresponding to the different specified intermediate layers; then, for each scale, i.e., each specified intermediate layer, the mean value of the feature vectors of all normal images extracted at each spatial location in that layer is calculated; finally, the set of the mean values of the feature vectors calculated at each scale is used to construct the standard depth features of that scale, which is used to represent the distribution prototype of normal product features at that scale in terms of probability statistics. Other methods can also be used in other embodiments, which are not limited here.
[0030] In specific implementation, determining the feature distance between different feature maps in the multi-scale depth features and the corresponding standard depth features can be achieved in the following way: For each scale feature map in the multi-scale depth features, traverse every spatial position on the feature map; at each spatial position, extract the feature vector of that position and obtain the feature mean vector of the corresponding scale in the standard depth features; then, calculate the Mahalanobis distance between the feature vector of that position and the corresponding feature mean vector, which is the feature distance of that spatial position at the corresponding scale; after traversal, a feature distance map with the same spatial size as the input feature map can be obtained at each scale. This feature distance map quantifies the degree of deviation of each local region of the image to be inspected from the normal prototype in the feature space. Other methods can also be used in other embodiments, which are not limited here.
[0031] In specific implementation, upsampling all feature distances to the original spatial size of the surface image and fusing them can be achieved in the following way: First, using a bilinear interpolation algorithm, the feature distance maps calculated at each scale are upsampled to the same spatial size as the surface image obtained in step 101; then, the feature distance maps at multiple scales after upsampling are fused at the pixel level; as a preferred embodiment, the pixel-level fusion can be performed by weighted summation, that is, assigning lower weights to the low-scale feature distance maps representing local details and higher weights to the high-scale feature distance maps representing global semantics, and then adding the distance maps at each scale according to their weights to obtain a fused distance map. Other methods can also be used in other embodiments, which are not limited here.
[0032] In specific implementation, the normalization of the fused distance map to a preset numerical range to generate a feature anomaly confidence map representing the possibility of semantic-level anomalies can be achieved in the following way: First, the preset numerical range is a closed interval from 0 to 1, where 0 represents no difference from normal features and 1 represents a significant difference from normal features; then, the max-min normalization method is used to linearly map the distance values of all pixels in the fused comprehensive distance map to the interval from 0 to 1; specifically, each pixel value in the distance map is subtracted from the minimum value among all pixel values, and then divided by the difference between the maximum and minimum values; finally, the image obtained after mapping, where all pixel values are within the range of 0 to 1, is the feature anomaly confidence map representing the possibility of semantic-level anomalies. The numerical range from 0 to 1 is a general interval preset based on the convenience of probabilistic interpretation and subsequent threshold determination. In other embodiments, the interval range can also be dynamically preset based on the statistical distribution of historical normal sample distance values, such as taking the mean plus three times the standard deviation as the upper bound. This application does not limit this.
[0033] It should be noted that the above steps can perform unsupervised deep semantic analysis on the image to be inspected. By comparing it with normal feature prototypes, the semantic deviation of the image in the feature space can be quantified, thereby improving the ability to perceive and detect complex semantic-level anomalies that are inconsistent with the context, such as structural distortions and faulty parts.
[0034] In step 103, multi-channel low-level image signal analysis is performed on the surface image to obtain a signal residual map, and the signal residual map is post-processed to generate a pixel-level anomaly indication map characterizing the possibility of physical signal-level anomalies.
[0035] In some embodiments, performing multi-channel low-level image signal analysis on the surface image to obtain a signal residual map can be achieved by the following steps: Select multiple low-level image analysis channels related to the physical properties of surface defects; Determine the characteristic response map of the surface image in each low-level image analysis channel; Each feature response map is compared with the corresponding baseline response map pre-established based on normal samples to generate preliminary residual maps for each low-level image analysis channel. By fusing all the preliminary residual maps, the signal residual map is obtained.
[0036] It should be noted that the low-level image analysis channel in this application is based on the physical imaging characteristics of defects, such as edge abrupt changes, texture breaks, and contrast differences. It is a pre-defined image signal analysis path with different dimensions, and its function is to separate and highlight possible abnormal signals from different physical perspectives. The feature response map is an image obtained by calculating the original image under a certain low-level image analysis channel. Its pixel values reflect the local intensity of the physical attributes of interest in that channel, such as gradient, texture, and contrast. Its function is to convert the original image into an intermediate representation that facilitates physical signal comparison. The preliminary residual map is an image used to characterize the degree of deviation from the normal state in a single low-level signal dimension. Its function is to provide the original abnormal signals of each channel without fusion. The signal residual map is an image generated by fusing multiple preliminary residual maps, integrating the physical signals of multiple channels. Its pixel values comprehensively characterize the probability intensity of physical signal-level anomalies at the corresponding positions. Its function is to serve as direct input for generating pixel-level anomaly indicator maps.
[0037] In specific implementation, the selection of multiple low-level image analysis channels related to the physical manifestations of surface defects can be achieved in the following way: based on the physical imaging characteristics of common surface defects such as scratches, stains, pits, and protrusions, three analysis channels can be selected, namely, the gradient amplitude channel, the local texture channel, and the local contrast channel; wherein, the gradient amplitude channel is used to respond to edge abrupt defects, the local texture channel is used to respond to texture breakage or contamination defects, and the local contrast channel is used to respond to defects with brightness differences from the background. These three channels together constitute the multiple low-level image analysis channels related to the physical manifestations of surface defects. In other embodiments, channels can also be added or reduced according to specific defect types, such as adding a color space channel to detect color differences. This application does not limit this.
[0038] In specific implementation, the feature response map of the surface image under each low-level image analysis channel can be determined in the following way: For the gradient magnitude channel, the Sobel operator is used to convolve the surface image in the horizontal and vertical directions, and the square root of the sum of the squares of the two gradient maps is calculated to obtain the gradient magnitude feature response map; for the local texture channel, the grayscale image of the surface image is encoded using the local binary mode operator, and the texture mode in the local neighborhood of each pixel is statistically analyzed to obtain the local texture feature response map; for the local contrast channel, the difference between the maximum and minimum brightness values in the local neighborhood (e.g., a 5x5 window) of the surface image of each pixel is calculated to obtain the local contrast feature response map. Finally, feature response maps corresponding to the three low-level image analysis channels are obtained respectively. Other methods can also be used in other embodiments, which are not limited here.
[0039] In specific implementation, the preliminary residual map of each low-level image analysis channel is generated by comparing each feature response map with the corresponding baseline response map pre-established based on normal samples. This can be achieved in the following way: the corresponding baseline response map pre-established based on normal samples is obtained in advance by calculating the gradient magnitude, local texture, and local contrast feature response maps of a large number of historical defect-free product surface images, and calculating the statistical mean of each feature response map at each pixel position; during comparison, the feature response map of the current image to be inspected in a certain low-level image analysis channel is subtracted pixel by pixel from the baseline response map of the corresponding low-level image analysis channel, and the absolute value of the difference is taken. The resulting absolute value map is the preliminary residual map of that low-level image analysis channel; wherein, the preliminary residual map represents the deviation of the image to be inspected from the normal baseline in the corresponding low-level signal dimension. Other methods can also be used in other embodiments, which are not limited here.
[0040] In specific implementation, the signal residual map obtained by fusing all preliminary residual maps can be achieved in the following way: First, the three preliminary residual maps corresponding to the gradient magnitude channel, local texture channel, and local contrast channel are normalized to make their pixel value range uniform; then, the maximum value method at the pixel level is used for fusion, that is, for each pixel position, the maximum value of that position in the three normalized preliminary residual maps is taken as the residual value of that position after fusion; after traversing all pixels, a comprehensive signal residual map that fuses multi-channel abnormal signals is generated. In other embodiments, weighted average or median methods can also be used for fusion, and this application does not limit this.
[0041] In some embodiments, post-processing the signal residual map to generate a pixel-level anomaly indication map characterizing the probability of physical signal-level anomalies can be achieved through the following steps: Adaptive threshold segmentation is performed on the signal residual map to obtain the initial binarized outlier region; A morphological opening operation is performed on the initial binarized outlier region to filter out isolated noise points; A morphological closing operation is performed on the abnormal regions after the morphological opening operation to connect adjacent fragmented abnormal regions and form connected candidate abnormal patches. Based on connected candidate anomalous patches, a pixel-level anomalous indication map is generated to characterize the probability of physical signal-level anomalousness.
[0042] It should be noted that the initial binarized anomaly region in this application is the foreground connected region in the binary image obtained after preliminary thresholding of the signal residual map. Its function is to perform preliminary localization of physical signal anomalies, which may contain noise. The candidate anomaly patch is a relatively complete connected region with obvious noise removed, formed after morphological filtering of the initial binarized anomaly region. Its function is to serve as the basic spatial unit for refined analysis and judgment in subsequent steps. The pixel-level anomaly indicator map is a binary image in which the white connected regions, i.e., the candidate anomaly patches, clearly indicate the spatial location of all suspicious defects found based on physical signal analysis. Its function is to provide a precise location indicator of anomaly regions based on low-level image signal analysis.
[0043] In specific implementation, adaptive threshold segmentation of the signal residual map to obtain the initial binarized abnormal region can be achieved in the following way: A local adaptive threshold segmentation algorithm is used to divide the signal residual map into multiple non-overlapping local image blocks, such as 16x16 pixel blocks. For each local image block, the mean and standard deviation of all pixel values within the local image block are calculated. The local threshold of the local image block is set to "mean plus K times the standard deviation," where K is a preset empirical coefficient, such as 1.5. Then, pixels with pixel values greater than the local threshold within the local image block are marked as foreground (abnormal), otherwise marked as background (normal). After traversing all local image blocks, an initial binarized image is obtained, and the foreground connected region is the initial binarized abnormal region. Other methods can also be used in other embodiments, which are not limited here.
[0044] In specific implementation, performing a morphological opening operation on the initial binarized anomalous region to filter out isolated noise points can be achieved in the following way: First, a small circular or square structuring element, such as a disk with a radius of 2 pixels, is used to erode the initial binarized anomalous region. This erosion operation eliminates all isolated foreground points or small protrusions smaller than the structuring element. Then, a structuring element of the same size and shape is used to dilate the eroded result to restore the approximate original size of the larger anomalous regions that are retained, while ensuring that the eliminated noise points are not restored. After this morphological opening operation, only anomalous regions with a size significantly larger than the noise are retained in the image. Here, the morphological opening operation is defined as a sequence of operations of erosion followed by dilation. Other methods can also be used in other embodiments, which are not limited here.
[0045] In specific implementation, performing a morphological closing operation on the abnormal region after the morphological opening operation to connect adjacent fragmented abnormal regions and form connected candidate abnormal patches can be achieved in the following way: using a structuring element slightly larger than the morphological opening operation structuring element, such as a disk with a radius of 3 pixels, to perform an expansion operation on the abnormal region after the morphological opening operation. This operation expands the boundary of the existing region, merging closely spaced independent regions into a connected region. Then, using a structuring element of the same size and shape to perform an erosion operation on the expanded result to smooth the boundary of the merged region and roughly restore it to the size level before expansion. After this morphological closing operation, the fragmented regions belonging to the same physical defect that were originally broken due to incomplete detection are connected to form complete and connected candidate abnormal patches. Here, the morphological closing operation is defined as a sequence operation of expansion followed by erosion. Other methods can also be used in other embodiments, which are not limited here.
[0046] In specific implementation, the generation of a pixel-level anomaly indicator map representing the probability of physical signal-level anomalies based on connected candidate anomaly patches can be achieved in the following way: On the binary image after morphological closing operation, a connected component analysis algorithm is executed to assign a unique label to each connected candidate anomaly patch; then, a blank image with the same size as the original surface image is created as the output image; the initial value of all pixels in the output image is set to 0, representing the background; next, all labeled connected candidate anomaly patches are traversed, and the pixel value corresponding to the pixel position covered by each patch in the output image is set to 1, representing the foreground or anomaly; finally, the resulting binary image is the pixel-level anomaly indicator map, wherein the connected regions with a value of 1 in the pixel-level anomaly indicator map intuitively represent the possible defect locations discovered based on physical signal analysis. Other methods can also be used in other embodiments, which are not limited here.
[0047] It should be noted that the above steps can robustly analyze and accurately locate multi-dimensional physical signals of the image under inspection, such as gradient, texture, and contrast, effectively suppressing irrelevant interferences such as illumination and noise, thereby improving the detection rate and positioning accuracy of physical defects such as scratches, stains, and dents.
[0048] In step 104, the cross-correlation values of each candidate anomaly region in the feature anomaly confidence map and the pixel-level anomaly indication map are determined.
[0049] In some embodiments, determining the cross-correlation value of each candidate anomaly region in the feature anomaly confidence map and the pixel-level anomaly indication map can be achieved by the following steps: Based on the pixel-level anomaly indication map, connected candidate anomaly patches are identified and located to determine the spatial range of multiple candidate anomaly regions. Extract the pixel value matrix of the region corresponding to each candidate anomaly region from the feature anomaly confidence map and the pixel-level anomaly indicator map, respectively; Determine the normalized cross-correlation coefficient between the two pixel value matrices corresponding to each candidate anomaly region, and then use the normalized cross-correlation coefficient as the anomaly cross-correlation value of the corresponding candidate anomaly region.
[0050] It should be noted that the abnormal cross-correlation value in this application is a scalar indicator used to quantify the consistency and synergy between the probability of feature-level anomalies and the probability of physical signal-level anomalies in the spatial distribution within a certain candidate anomaly region. Its role is to serve as a key diversion basis in the decision fusion process.
[0051] In specific implementation, based on the pixel-level anomaly indicator map, identifying and locating connected candidate anomaly patches to determine the spatial range of multiple candidate anomaly regions can be achieved in the following way: A connected component analysis algorithm is executed on the pixel-level anomaly indicator map, traversing all foreground points with a pixel value of 1 in the map; the algorithm groups adjacent foreground pixels into the same connected component, where an 8-neighborhood or 4-neighborhood connection rule can be used, and a unique identifier is assigned to each independent connected component; subsequently, the bounding rectangle of each labeled connected component is calculated, the bounding rectangle being determined by its minimum row coordinate, maximum row coordinate, minimum column coordinate, and maximum column coordinate, and this bounding rectangle area is defined as the spatial range of a candidate anomaly region; finally, a list of labels for all connected components and their bounding rectangle coordinates is obtained, thereby completing the determination of the spatial range of multiple candidate anomaly regions. In other embodiments, a minimum enclosing circle or a precise contour polygon can also be used to define the spatial range, which is not limited in this application.
[0052] In specific implementation, the pixel value matrix of each candidate anomaly region can be extracted from the feature anomaly confidence map and the pixel-level anomaly indicator map in the following way: For each candidate anomaly region, based on its determined spatial range, i.e., the coordinates of the circumscribed rectangle, region clipping is performed on both the feature anomaly confidence map and the pixel-level anomaly indicator map; specifically, based on the coordinate boundary of the circumscribed rectangle, a matrix containing all pixel values within the circumscribed rectangle is extracted from the feature anomaly confidence map, denoted as the feature matrix; simultaneously, a pixel value matrix within the same coordinate range is extracted from the pixel-level anomaly indicator map, denoted as the indicator matrix; to ensure that the two matrices are strictly aligned in space, the extraction operation uses the same coordinate parameters; finally, a pair of feature matrices and indicator matrices with completely corresponding spatial positions are obtained for each candidate anomaly region. Other methods can also be used in other embodiments, which are not limited here.
[0053] In specific implementation, the normalized cross-correlation coefficient between the two pixel value matrices corresponding to each candidate anomaly region can be determined and then used as the anomaly cross-correlation value of the corresponding candidate anomaly region. This can be achieved in the following way: For each pair of feature matrices and indicator matrices, firstly, the two matrices are flattened into one-dimensional vectors; then, the Pearson correlation coefficient between the two vectors is calculated. The specific calculation process is as follows: first, the covariance of the two vectors is calculated, and then divided by the product of the standard deviations of the two vectors respectively. The resulting scalar value is the normalized cross-correlation coefficient, and its value range is [-1, 1]. Finally, the absolute value of the coefficient is usually taken or it is linearly mapped to the interval [0, 1]. The final value is recorded as the anomaly cross-correlation value of the corresponding candidate anomaly region. The anomaly cross-correlation value quantifies the degree of linear correlation between the probability of feature-level anomalies and the probability of physical signal-level anomalies in the distribution pattern within the corresponding region space. The higher the value, the stronger the consistency between the two pieces of evidence. In other embodiments, other similarity measures, such as cosine similarity or mutual information, can also be used. This application does not limit this.
[0054] It should be noted that the above steps can objectively quantify the consistency of the spatial distribution of semantic anomaly clues and physical anomaly signals in each suspicious area, providing a calculable synergy index for dual verification, thereby improving the reliability and automation level of the subsequent fusion decision-making process.
[0055] In step 105, for each candidate region of anomaly, if the cross-correlation value of the anomaly is higher than a preset first threshold, then the corresponding candidate region of anomaly is judged for defect based on the feature anomaly confidence map. If the cross-correlation value of the anomaly is lower than the first threshold, but the corresponding candidate region of anomaly has any corresponding anomaly score higher than the second threshold in the feature anomaly confidence map and the pixel-level anomaly indicator map, then the comprehensive defect is judged based on the local context information of the corresponding candidate region of anomaly.
[0056] In some embodiments, if the abnormal cross-correlation value is higher than a preset first threshold, the defect determination of the corresponding abnormal candidate region based on the feature anomaly confidence map can be achieved by the following steps: The average confidence level of the corresponding anomaly candidate region is extracted from the feature anomaly confidence map and used as the defect confidence score of the corresponding anomaly candidate region. Determine whether the defect confidence score exceeds a preset defect presence threshold; If the number of defects exceeds the limit, the corresponding abnormal candidate region is determined to have a defect, and the preliminary defect category of the corresponding abnormal candidate region is determined based on the response pattern of the feature anomaly confidence map in the abnormal candidate region. The determination results, including the location, the defect confidence score, and the preliminary defect category, are recorded.
[0057] It should be noted that the first threshold in this application is an abnormal cross-correlation threshold used to determine whether the evidence of feature flow and signal flow is highly consistent. The defect confidence score represents the confidence level of the existence of semantic defects in the corresponding region and serves as the main quantitative basis for determining whether defects exist. The defect existence threshold is a preset defect confidence score threshold used to finally decide whether a suggested abnormal region should be identified as a real defect.
[0058] In specific implementation, the average confidence level of the corresponding anomaly candidate region is extracted from the feature anomaly confidence map and used as the defect confidence score of the corresponding anomaly candidate region. This can be achieved in the following way: based on the determined spatial range of the anomaly candidate region, i.e., the coordinates of the circumscribed rectangle, the corresponding rectangular region is cropped from the feature anomaly confidence map; then, the arithmetic mean of all pixel values within the corresponding rectangular region is calculated, and this arithmetic mean is used as the defect confidence score of the anomaly candidate region. In other embodiments, the median or weighted average of the region pixel values can also be used, and this application does not limit this.
[0059] In specific implementation, the defect presence threshold can be preset in the following way: during the model deployment stage, a set of sample images of known normal and known defects are collected, and the same method of the present invention is run to obtain the defect confidence score of each region; by analyzing the statistical distribution of the defect confidence scores of normal regions and real defect regions, a value that can balance the false alarm rate and the false negative rate is selected as the defect presence threshold; for example, the defect presence threshold can be set to the 99th percentile of the defect confidence score distribution of normal samples. In other embodiments, the threshold can also be dynamically adjusted according to the sensitivity requirements of the actual production line, which is not limited in this application.
[0060] In specific implementation, the preliminary defect category of the corresponding anomaly candidate region can be determined based on the response pattern of the feature anomaly confidence map in the anomaly candidate region in the following manner: First, extract the regions corresponding to the anomaly candidate region on the low, medium, and high scale feature distance maps generated in step 102, i.e., the feature distance maps before fusion, and calculate the average response value of each region; then, combine these three average response values into a three-dimensional feature vector; finally, match the three-dimensional feature vector with a predefined defect category prototype library, which stores typical response pattern vectors of various typical defects, such as scratches, stains, and dents, on feature distance maps at different scales; by calculating the cosine similarity between the feature vector of the region to be judged and each prototype vector, the defect category corresponding to the prototype with the highest similarity is determined as the preliminary defect category of the region. In other embodiments, a trained multi-classifier can also be used for judgment, which is not limited in this application.
[0061] In specific implementation, recording the determination result including location, the defect confidence score, and the preliminary defect category can be achieved in the following way: create a data structure for each abnormal candidate region determined to have a defect. The data structure should contain at least the following fields: region location, represented by the coordinates of the upper left and lower right corners of the bounding rectangle of the region; defect confidence score; preliminary defect category, the corresponding string or enumeration value; then, add the data structure to a global defect determination result list. In other embodiments, the results can also be directly written to a database or sent to a message queue. This application does not limit this.
[0062] In specific implementation, the first threshold can be preset in the following way: during the model deployment stage, a set of known defect sample images are collected. These samples should contain typical defect areas with high consistency in dual verification, that is, obvious correlation between features and pixel evidence; the same method as in this invention is run to calculate the abnormal cross-correlation value of each region; by analyzing the distribution of abnormal cross-correlation values of these typical defect areas, a lower quantile, such as the 5th percentile, is selected as the first threshold to ensure that the vast majority of defect areas with high consistency in dual verification can be covered. In other embodiments, cross-validation can also be used to optimize the selection on the validation set, which is not limited in this application.
[0063] In some embodiments, if the abnormal cross-correlation value is lower than the first threshold, but the corresponding candidate abnormal region has an abnormal score higher than the second threshold in either the feature abnormality confidence map or the pixel-level abnormality indication map, then the comprehensive defect determination based on the local context information of the corresponding candidate abnormal region can be achieved by the following steps: The average confidence score of the corresponding candidate anomaly region in the feature anomaly confidence map is extracted as the first anomaly score, and the maximum residual value of the corresponding candidate anomaly region in the original signal residual region in the pixel-level anomaly indicator map is extracted as the second anomaly score. When either the first abnormal score or the second abnormal score is higher than the second threshold, local context information of the corresponding candidate abnormal region is extracted. The local context information is input into a preset arbitration classification model for matching, and a comprehensive arbitration judgment result is output. The arbitration decision result is associated with and recorded with the information of the corresponding candidate abnormal region.
[0064] It should be noted that the second threshold in this application is an anomaly score threshold used to determine whether the strength of a single piece of evidence is high enough to warrant initiating a complex arbitration mechanism when there is inconsistency between the two pieces of evidence; the first anomaly score is a scalar value characterizing the overall anomaly strength of the candidate anomaly region in the semantic anomaly dimension, and its function is to serve as the basis for evaluating the strength of feature flow evidence in the arbitration process; the second anomaly score is a scalar value characterizing the maximum anomaly strength of the candidate anomaly region in the physical signal anomaly dimension, and its function is to serve as the basis for evaluating the strength of signal flow evidence in the arbitration process.
[0065] In specific implementation, extracting the average confidence level of the corresponding candidate anomaly region in the feature anomaly confidence map as the first anomaly score, and extracting the maximum residual value of the corresponding candidate anomaly region in the original signal residual region of the pixel-level anomaly indication map as the second anomaly score, can be achieved in the following way: For the first anomaly score, based on the spatial range of the candidate anomaly region, the corresponding region is cropped from the feature anomaly confidence map, and the average value of all pixel values in the region is calculated as the first anomaly score; For the second anomaly score, based on the same spatial range, the corresponding region is cropped from the signal residual map generated in step 103, that is, from the original signal residual map before post-processing, and the maximum value of all pixel values in the cropped region is found as the second anomaly score. In other embodiments, the median or other statistical measures can also be used, and this application does not limit this.
[0066] In specific implementation, the extraction of local context information of the corresponding candidate anomaly region can be achieved in the following way: the local context information includes the following three parts: the first part is the multi-scale depth feature of the candidate anomaly region itself, that is, the average value of the depth feature vector of the region at the low, medium and high scales extracted from step 102; the second part is the surrounding context background feature of the candidate anomaly region, which is obtained by expanding outward by a certain proportion, such as 1.5 times, from the bounding rectangle of the candidate anomaly region to form a larger rectangular region, extracting the average confidence of the larger rectangular region from the feature anomaly confidence map, and subtracting it from the average confidence of the region itself; the third part is the relative position coordinates of the region in the entire product surface image, which is obtained by normalizing the horizontal and vertical coordinates of the region center point by the image width and height, respectively. Finally, these three parts of information are concatenated into a context feature vector; in other embodiments, more features may be included, such as region shape features, which are not limited in this application.
[0067] In specific implementation, the local context information is input into a preset arbitration classification model for matching, and the output of a comprehensive arbitration judgment result can be achieved in the following way: the preset arbitration classification model is a binary random forest model, whose input is the context feature vector, and whose output is the label of true defect or pseudo-anomaly and the corresponding confidence probability; the extracted context feature vector is input into the model, the model performs inference and outputs the classification label and confidence probability; if the output label is true defect, the arbitration judgment result is that a defect exists, and the defect type can be further inferred based on the feature components in the context feature vector; if the output label is pseudo-anomaly, the arbitration judgment result is normal. In other embodiments, classifiers such as support vector machines and neural networks can also be used, and this application does not limit this.
[0068] In specific implementation, associating the arbitration judgment result with the information of the corresponding candidate abnormal region can be achieved in the following way: update the data structure of each candidate abnormal region that has undergone arbitration judgment, and add the following fields: arbitration judgment result, a boolean value or string indicating whether it is a defect; arbitration confidence probability, and if there is a defect type inference, also add the arbitration defect category; then, add the updated data structure to the global defect judgment result list, or merge it with the previously recorded information of the region. In other embodiments, an arbitration result list can also be established separately. This application does not limit this, and other methods can also be used in other embodiments.
[0069] In specific implementation, the second threshold can be preset in the following way: during the model deployment phase, a set of known difficult example sample images are collected. These samples contain regions with low double-validation consistency but with defects, such as weak defects and normal regions that are prone to false alarms. The same method of the present invention is run to calculate the first abnormal score and the second abnormal score of each region. By analyzing the distribution of the two abnormal scores of these regions, thresholds are set for the first abnormal score and the second abnormal score respectively, so as to cover real defects as much as possible while filtering out most false alarms. For example, the second threshold of the first abnormal score can be set to the 99.5th percentile of the distribution of the first abnormal score in the normal region, and the second threshold of the second abnormal score can be set to the 99.5th percentile of the distribution of the second abnormal score in the normal region. In other embodiments, the two thresholds can be the same or different, and this application does not limit this.
[0070] In specific implementation, the arbitration classification model can be pre-configured in the following manner: First, historical detection data is collected to construct a training dataset containing a large number of candidate abnormal region samples, each sample containing its local context feature vector and manually labeled real labels; then, a random forest classifier is trained using the training dataset, and hyperparameters are adjusted through cross-validation to optimize performance; finally, the trained random forest classifier is serialized into a model file, and the model file is loaded during system initialization, thus completing the pre-configuration of the arbitration classification model. In other embodiments, other machine learning algorithms or deep learning models can also be used, and this application does not limit them.
[0071] It should be noted that the above steps can be based on differentiated intelligent decision-making based on the degree of consistency of evidence. That is, when the evidence is consistent, a high-confidence result is quickly adopted, and when the evidence is contradictory but one side is strong, contextual arbitration is initiated, thereby improving the overall accuracy and robustness in handling cases with clear defects and marginal difficult cases.
[0072] In step 106, the final defect segmentation map is generated based on the defect determination results of all candidate abnormal regions.
[0073] In some embodiments, generating the final defect segmentation map based on the defect determination results of all candidate anomaly regions can be achieved by the following steps: Read the global list of defect determination results; Initialize a blank image with the same size as the surface image as the base segmentation map; Traverse the defect judgment result list, and draw the corresponding defect area on the basic segmentation map according to the judgment result and area location information of each record in the defect judgment result list; The completed basic segmentation map is post-processed and optimized to generate and output the final defect segmentation map.
[0074] It should be noted that the defect segmentation map in this application is an output image that clearly and completely marks the precise location and range of all regions identified as defects in the original image. Its purpose is to intuitively present the detection results and can be directly used for subsequent positioning, sorting or statistics.
[0075] In specific implementation, initializing a blank image with the same size as the surface image as the base segmentation map can be achieved in the following way: First, obtain the height and width pixel values of the surface image; then, create a new image matrix with the same size based on the height and width pixel values, and set the initial value of all pixels in the image matrix to 0, representing background or no defects; this image matrix with all pixel values of 0 is the initialized base segmentation map. In other embodiments, other background identifier values can also be used, and this application does not limit this.
[0076] In specific implementation, the defect judgment result list is traversed, and the corresponding defect area is drawn on the basic segmentation map according to the judgment result and area location information of each record in the defect judgment result list. This can be achieved in the following way: sequentially read each record in the global defect judgment result list; for each record, first check its arbitration judgment result to see if it has been judged to have a defect. If it is judged to have a defect, extract the area location field in the record. The area location field contains the coordinates of the upper left and lower right corners of the bounding rectangle of the defect area; then, on the basic segmentation map, modify all pixel values within the closed area defined by the coordinates of this rectangle from the background value 0 to a preset defect identifier value, such as setting it to 1, or setting it to a different integer number according to different preliminary defect categories; in this way, all records in the list are traversed, and all areas judged to be defective are marked and drawn on the basic segmentation map. In other embodiments, the pixel value can also be assigned a gray level according to the defect confidence level. This application does not limit this.
[0077] In specific implementation, the post-processing optimization of the drawn basic segmentation map to generate and output the final defect segmentation map can be achieved in the following way: First, perform morphological closing operation on the basic segmentation map using a small circular structuring element, such as a disk with a radius of 2 pixels, to smooth the boundaries of the defect region and fill the tiny gaps that may be generated during drawing; then, perform connected component analysis on the image after the closing operation to identify and calculate the pixel area of each connected defect region; next, filter out extremely small isolated regions with pixel areas smaller than a preset minimum defect area threshold, such as 20 pixels, and reset the pixel values of these regions to the background value of 0 to eliminate possible noise points; finally, output the image matrix after the above smoothing and filtering as the final defect segmentation map. This defect segmentation map is a binary map or a multi-valued label map, which can be directly stored as an image file or passed to a subsequent vision system for defect visualization and sorting control. In other embodiments, edge smoothing or defect contour fitting optimization steps can also be added, which are not limited in this application.
[0078] It should be noted that the above steps can integrate, optimize and transform all the scattered judgment results into a standardized defect location annotation map, which intuitively presents the precise shape and location of all confirmed defects, thereby improving the visualization of the detection results and the efficiency of the connection with subsequent automated sorting and statistical processes.
[0079] Furthermore, in another aspect of this application, in some embodiments, this application provides an artificial intelligence recognition system for product quality inspection, with reference to... Figure 4 The figure is a schematic diagram of the structure of an artificial intelligence recognition system for product quality inspection according to some embodiments of this application. The artificial intelligence recognition system for product quality inspection includes: an acquisition module 401, a processing module 402, and an execution module 403, which are described below: The acquisition module 401 in this application is mainly used to acquire the surface image of the product to be inspected; Processing module 402, in this application, is mainly used to extract multi-scale depth features of the surface image, compare the multi-scale depth features with preset standard depth features, and generate a feature anomaly confidence map representing the possibility of semantic-level anomalies. The processing module 402 described in this application is further used to perform multi-channel low-level image signal analysis on the surface image to obtain a signal residual map, and to perform post-processing on the signal residual map to generate a pixel-level anomaly indication map characterizing the possibility of physical signal-level anomalies. The processing module 402 described in this application is also used to determine the cross-correlation value of each candidate anomaly region in the feature anomaly confidence map and the pixel-level anomaly indication map; The processing module 402 described in this application is further configured to, for each abnormal candidate region, if the abnormal cross-correlation value is higher than a preset first threshold, perform defect determination on the corresponding abnormal candidate region based on the feature abnormality confidence map; if the abnormal cross-correlation value is lower than the first threshold, but the corresponding candidate abnormal region has any corresponding abnormal score higher than the second threshold in the feature abnormality confidence map and the pixel-level abnormality indicator map, perform comprehensive defect determination based on the local context information of the corresponding candidate abnormal region. The execution module 403 in this application is mainly used to generate the final defect segmentation map based on the defect determination results of all candidate abnormal regions.
[0080] Each module in the aforementioned artificial intelligence recognition system for product quality inspection can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.
[0081] In another embodiment, this application provides a computer device, which may be a server, and its internal structure diagram may be as follows. Figure 5 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database stores artificial intelligence recognition data for product quality inspection. The network interface communicates with external terminals via a network connection. When the computer program is executed by the processor, it implements an artificial intelligence recognition method for product quality inspection.
[0082] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0083] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described embodiment of the artificial intelligence identification method for product quality inspection.
[0084] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above-described embodiment of the artificial intelligence identification method for product quality inspection.
[0085] In one embodiment, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the steps in the above-described embodiment of the artificial intelligence identification method for product quality inspection.
[0086] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0087] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0088] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. An artificial intelligence recognition method for product quality inspection, characterized in that, Includes the following steps: Obtain a surface image of the product to be inspected; Extract multi-scale depth features from the surface image and compare the multi-scale depth features with preset standard depth features to generate a feature anomaly confidence map representing the possibility of semantic-level anomalies. Multi-channel low-level image signal analysis is performed on the surface image to obtain a signal residual map, and the signal residual map is post-processed to generate a pixel-level anomaly indicator map characterizing the possibility of physical signal-level anomalies. Determine the cross-correlation value of each candidate anomaly region in the feature anomaly confidence map and the pixel-level anomaly indicator map; For each candidate region of anomaly, if the cross-correlation value of anomaly is higher than a preset first threshold, then the corresponding candidate region of anomaly is judged for defect based on the feature anomaly confidence map. If the cross-correlation value of anomaly is lower than the first threshold, but the corresponding candidate region of anomaly has any corresponding anomaly score higher than the second threshold in the feature anomaly confidence map and the pixel-level anomaly indicator map, then the corresponding candidate region of anomaly is judged for defect based on the local context information of the corresponding candidate region of anomaly. The final defect segmentation map is generated based on the defect determination results of all candidate abnormal regions.
2. The method as described in claim 1, characterized in that, Extracting the multi-scale depth features of the surface image specifically includes: Load a pre-trained multi-scale feature extraction network; The surface image is input into the multi-scale feature extraction network for forward propagation; From the outputs of different specified intermediate layers of the multi-scale feature extraction network, feature maps corresponding to different abstraction levels and spatial scales are extracted to obtain multi-scale deep features.
3. The method as described in claim 1, characterized in that, The process of comparing the multi-scale depth features with preset standard depth features to generate a feature anomaly confidence map representing the likelihood of semantic-level anomalies specifically includes: Obtain the standard depth features corresponding to the multi-scale depth features; Determine the feature distance between different feature maps and corresponding standard depth features in the multi-scale depth features; All feature distances are upsampled to the original spatial dimensions of the surface image and then fused. The fused distance map is normalized to a preset numerical range to generate a feature anomaly confidence map representing the probability of semantic-level anomalies.
4. The method as described in claim 1, characterized in that, Performing multi-channel low-level image signal analysis on the surface image to obtain the signal residual map specifically includes: Select multiple low-level image analysis channels related to the physical properties of surface defects; Determine the characteristic response map of the surface image in each low-level image analysis channel; Each feature response map is compared with the corresponding baseline response map pre-established based on normal samples to generate preliminary residual maps for each low-level image analysis channel. By fusing all the preliminary residual maps, the signal residual map is obtained.
5. The method as described in claim 1, characterized in that, Post-processing the signal residual map to generate a pixel-level anomaly indicator map characterizing the probability of physical signal-level anomalies specifically includes: Adaptive threshold segmentation is performed on the signal residual map to obtain the initial binarized outlier region; A morphological opening operation is performed on the initial binarized outlier region to filter out isolated noise points; A morphological closing operation is performed on the abnormal regions after the morphological opening operation to connect adjacent fragmented abnormal regions and form connected candidate abnormal patches. Based on connected candidate anomalous patches, a pixel-level anomalous indication map is generated to characterize the probability of physical signal-level anomalousness.
6. The method as described in claim 1, characterized in that, Determining the cross-correlation values of each candidate anomaly region in the feature anomaly confidence map and the pixel-level anomaly indication map specifically includes: Based on the pixel-level anomaly indication map, connected candidate anomaly patches are identified and located to determine the spatial range of multiple candidate anomaly regions. Extract the pixel value matrix of the region corresponding to each candidate anomaly region from the feature anomaly confidence map and the pixel-level anomaly indicator map, respectively; Determine the normalized cross-correlation coefficient between the two pixel value matrices corresponding to each candidate anomaly region, and then use the normalized cross-correlation coefficient as the anomaly cross-correlation value of the corresponding candidate anomaly region.
7. The method as described in claim 1, characterized in that, The final defect segmentation map is generated based on the defect determination results of all candidate anomaly regions, specifically including: Read the global list of defect determination results; Initialize a blank image with the same size as the surface image as the base segmentation map; Traverse the defect judgment result list, and draw the corresponding defect area on the basic segmentation map according to the judgment result and area location information of each record in the defect judgment result list; The completed basic segmentation map is post-processed and optimized to generate and output the final defect segmentation map.
8. An artificial intelligence recognition system for product quality inspection, characterized in that, include: The acquisition module is used to acquire surface images of the product to be inspected. The processing module is used to extract multi-scale depth features from the surface image and compare the multi-scale depth features with preset standard depth features to generate a feature anomaly confidence map representing the possibility of semantic-level anomalies. The processing module is also used to perform multi-channel low-level image signal analysis on the surface image to obtain a signal residual map, and to perform post-processing on the signal residual map to generate a pixel-level anomaly indication map characterizing the possibility of physical signal-level anomalies. The processing module is further configured to determine the cross-correlation value of each candidate anomaly region in the feature anomaly confidence map and the pixel-level anomaly indication map; The processing module is further configured to, for each abnormal candidate region, if the abnormal cross-correlation value is higher than a preset first threshold, then perform defect determination on the corresponding abnormal candidate region based on the feature abnormality confidence map; if the abnormal cross-correlation value is lower than the first threshold, but the corresponding candidate abnormal region has any corresponding abnormal score higher than the second threshold in the feature abnormality confidence map and the pixel-level abnormality indicator map, then perform comprehensive defect determination based on the local context information of the corresponding candidate abnormal region. The execution module is used to generate the final defect segmentation map based on the defect determination results of all candidate abnormal regions.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the artificial intelligence recognition method for product quality inspection as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the artificial intelligence identification method for product quality inspection as described in any one of claims 1 to 7.