An industrial image change anomaly detection method and system based on artificial intelligence
By using dual-source image acquisition and frequency domain saliency fusion, combined with CNN and Transformer models, the problems of insufficient accuracy and inadequate feature representation in industrial image anomaly detection are solved, achieving efficient anomaly detection and visualization in complex scenes.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-08
- Publication Date
- 2026-03-24
AI Technical Summary
Existing industrial image anomaly detection methods suffer from problems such as insufficient anomaly detection accuracy, inadequate feature representation, information loss due to uneven illumination and reflection interference in complex scenes, failure to effectively integrate frequency domain information, and insufficient model perception ability for small or hidden anomaly areas.
The system employs dual-source image acquisition, frequency domain saliency-guided fusion and color mapping enhancement, and combines CNN convolutional networks and Transformer models to extract multi-scale feature maps and perform feature reconstruction. Anomaly detection reports are generated using dual error metrics.
It improves the accuracy and feature representation capabilities of anomaly detection, enhances the identification of abnormal regions in complex scenarios, improves the robustness and interpretability of the model, and supports image-level and region-level visualization.
Smart Images

Figure CN120876941B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image recognition, and in particular to an industrial image change anomaly detection method and system based on artificial intelligence. BACKGROUND
[0002] With the continuous improvement of industrial automation and intelligent manufacturing level, machine vision technology has been widely applied in product quality control, surface defect detection, equipment operation monitoring and other fields, especially in image change anomaly detection tasks, the non-destructive detection means based on image information gradually replaces the traditional manual inspection method due to its non-contact, high efficiency, easy integration and other advantages, in the prior art, the main anomaly detection methods include unsupervised learning method based on image reconstruction, image comparison method based on pixel difference and feature extraction method based on deep neural network, etc., among them, the convolutional neural network (CNN) is widely used in industrial image analysis and feature extraction tasks due to its excellent image expression ability, at the same time, the introduction of Transformer architecture in the field of vision in recent years further enhances the ability of the model in global modeling and self-attention mechanism, providing a new idea for anomaly detection in complex scenes.
[0003] Although the above-mentioned technology improves the automation level and detection accuracy of industrial image anomaly detection to some extent, there are still many deficiencies, on the one hand, the industrial images collected under single light source are easy to cause information loss under complex working conditions such as uneven illumination and glare interference, affecting the comprehensiveness of feature extraction, on the other hand, the frequency domain information in the existing method is often not effectively fused, and the multi-scale structure and high-frequency change characteristics of the image are not fully utilized, resulting in insufficient perception ability of the model to small or hidden abnormal areas, in addition, most deep learning methods only rely on reconstruction error or single dimension index for anomaly discrimination, which is easy to cause false alarm or missed detection problem. SUMMARY
[0004] In view of the above existing problems, the present application is proposed.
[0005] Therefore, the present application provides an industrial image change anomaly detection method and system based on artificial intelligence, which solves the problems of insufficient anomaly change detection accuracy and insufficient feature expression of industrial images in complex scenes.
[0006] To solve the above technical problems, the present application provides the following technical solutions:
[0007] In a first aspect, the present application provides an industrial image change anomaly detection method based on artificial intelligence, which comprises,
[0008] Dual-light source industrial images were acquired, and a saliency-weighted fusion strategy guided by frequency domain saliency was used for fusion. Contrast enhancement was then performed through color mapping and edge enhancement to obtain an enhanced image.
[0009] The enhanced image is input into a CNN convolutional network to generate multi-scale feature maps. Multi-scale high-pass residual maps are extracted through two-dimensional fast Fourier transform and high-pass filtering template. Local attention guides the fusion of multi-scale feature maps and multi-scale high-pass residual maps. Finally, all scales are stitched together to obtain a unified feature map and encoded to generate a token sequence.
[0010] By combining the self-inductive feature reconstruction mechanism with Transformer, a self-inductive visual model is constructed to reconstruct the features of the token sequence and generate a reconstructed feature map.
[0011] A dual error index is adopted to fuse the unified feature map and the reconstructed feature map into a reconstruction error score map. The reconstruction error score map is sampled by bilinear interpolation and Gaussian filtering to obtain an anomaly smoothing map. Anomaly regions are segmented based on the anomaly smoothing map.
[0012] Generate anomaly detection reports to locate and visualize abnormal images.
[0013] As a preferred embodiment of the artificial intelligence-based industrial image anomaly detection method of the present invention, the method involves: acquiring dual-light source industrial images, performing saliency-weighted fusion using a frequency domain saliency-guided fusion strategy, and performing contrast visual enhancement processing through color mapping and edge enhancement to obtain an enhanced image, including:
[0014] Acquiring white light industrial images I white Industrial images with blue light oblique illumination I blue Both images are H×W in size and undergo grayscale conversion to obtain a grayscale image G. white and G blue ;
[0015] For grayscale image G white and G blue Perform a 2D Fourier transform and calculate the frequency domain amplitude spectrum to obtain the white light frequency domain amplitude spectrum F. white (u,v) and the frequency domain amplitude spectrum of blue light oblique illumination F blue (u,v);
[0016] A saliency spectrum is constructed based on the frequency domain amplitude spectrum, and the saliency spectrum is smoothed by low-pass Gaussian filtering.
[0017] The smoothed saliency spectrum M s (u,v) is remapped to grayscale using bilinear interpolation. Figure One Spatial diagram M of size s(x,y), the spatial graph M s Using (x, y) as the fusion weights, the images are fused through saliency-weighted fusion to obtain fused image I. fused ;
[0018] Merge Figure I fused Mapping to the RGB pseudo-color space, we get I pseudo ;
[0019] to I pseudo Perform a DoG high-pass filter operation, calculate the edge response, and then... pseudo The enhanced image I is obtained by linearly superimposing the edge response map and normalizing it. final .
[0020] As a preferred embodiment of the artificial intelligence-based industrial image anomaly detection method of the present invention, the method includes: inputting the enhanced image into a CNN convolutional network to generate a multi-scale feature map; extracting a multi-scale high-pass residual map through a two-dimensional fast Fourier transform and a high-pass filter template; and guiding the fusion of the multi-scale feature map and the multi-scale high-pass residual map through local attention.
[0021] The enhanced image is input into the pre-trained EfficientNet-B4 backbone network to extract multi-scale feature maps at different depths. i It includes the bottom texture feature map f1, the middle structure feature map f2, the high semantic feature map f3, and the top abstract feature map f4;
[0022] For multi-scale feature maps f i Each feature channel c is independently subjected to a two-dimensional fast Fourier transform;
[0023] Let a constant r0 be defined, and for each position in the frequency domain, define a high-pass filter template H(u,v)∈{0,1}. When the condition is met, H(u,v) is 1; otherwise, H(u,v) is 0.
[0024] The Fourier transform result is filtered in the frequency domain using a high-pass filter template. A two-dimensional inverse fast Fourier transform is then performed on the filtered result, and the absolute value of the real part is taken to obtain the high-pass residual plot.
[0025] For each channel c, calculate the average response of the high-pass residual map on that channel to obtain the channel weights, and apply a nonlinear mapping to the channel weights to obtain the attention weights;
[0026] Multiply the attention weights point-by-point in each channel of the multi-scale feature map to generate a weighted feature map.
[0027] The weighted feature map and the high-pass residual map are concatenated along the channel dimension, and a 1×1 convolutional layer with a fixed output channel is used for feature compression and fusion, outputting a compressed feature map F. i .
[0028] As a preferred embodiment of the artificial intelligence-based industrial image anomaly detection method of the present invention, wherein: the final concatenation of all scales to obtain a unified feature map and encoding it to generate a token sequence includes,
[0029] Compressed image F of all scale features i By unifying the data to the same spatial size through bilinear upsampling and then concatenating them, a unified feature map F is obtained;
[0030] Divide F into non-overlapping patches of size P×P, with a total of N. Flatten each patch into a token to obtain the token sequence X.
[0031] As a preferred embodiment of the artificial intelligence-based industrial image anomaly detection method of the present invention, the step of constructing a self-inductive visual model by combining a self-inductive feature reconstruction mechanism with Transformer, reconstructing features of the token sequence, and generating a reconstructed feature map includes,
[0032] Construct a set of learnable auxiliary inductive token sequences X with the same dimension as the token sequence X. * Each inductive token parameter is a learnable vector, initialized with a zero-mean Gaussian distribution;
[0033] X * Randomly divided into M non-overlapping subsets Construct a combination sequence Φ for each subset i This includes summarizing token subsets. and X in Non-overlapping patch tokens;
[0034] Combined sequence φ i The Transformer encoder portion, which shares input parameters, includes an Encoder layer, a multi-head attention mechanism, a feedforward network, and residual connections, to obtain the encoded result Z. i For each encoding result Z i Based on the position index, discard all outputs from the input at the patch token positions, and only extract the encoded result corresponding to the summarized token.
[0035] Concatenate all the inductively encoded token results into a complete sequence Z induced ;
[0036] The total loss function is constructed using Euclidean distance loss and cosine similarity loss;
[0037] The model is trained using normal industrial images as the training set, constrained by the total loss function, optimized by gradient descent using the Adam optimizer, and the model parameters are updated. If the model loss no longer decreases significantly during continuous iteration, the iteration is stopped and the model is output.
[0038] Using a trained model, input the newly extracted unified feature map and output the reconstructed feature map.
[0039] As a preferred embodiment of the artificial intelligence-based industrial image anomaly detection method of the present invention, the method employs a dual error index to fuse a unified feature map and a reconstructed feature map into a reconstruction error score map. The reconstruction error score map is then sampled using bilinear interpolation and Gaussian filtering to obtain an anomaly smoothing map. Anomaly regions are segmented based on this anomaly smoothing map, including...
[0040] Based on the Euclidean reconstruction error and the orientation error, the reconstruction error score is calculated, and a reconstruction error score map is generated;
[0041] The reconstructed error score map is restored to size H×W through bilinear interpolation upsampling and Gaussian filtering, resulting in the abnormal smooth map A. final ;
[0042] Calculate A final The standard deviation is used as the image-level anomaly score. A threshold T is set. If the image-level anomaly score is greater than the threshold T, it is judged as an abnormal image; otherwise, it is normal.
[0043] If it is an abnormal image, then for the abnormal smoothing map A final An initial mask is generated using a statistical adaptive threshold, which in turn generates a binary image G.
[0044] Extract all connected regions from the binary graph G and output the set of outlier regions R. G .
[0045] As a preferred embodiment of the artificial intelligence-based industrial image anomaly detection method of the present invention, wherein: the generation of the anomaly detection report, which performs anomaly localization and visualization of the anomaly image, includes,
[0046] Anomalies in industrial images are marked and the boundaries of anomalies are drawn with lines. Heatmaps are generated based on the reconstruction error score of each pixel in the anomaly smoothing map.
[0047] Generate anomaly detection reports, including dual-light source industrial images and thermal maps depicting the boundaries of the anomaly areas.
[0048] Secondly, the present invention provides an industrial image anomaly detection system based on artificial intelligence, comprising,
[0049] The dual-light source enhancement module is used to acquire industrial images from dual light sources that complement each other in terms of surface texture and structural information. It generates a fused image through a frequency domain saliency-guided fusion strategy and performs contrast visual enhancement processing through color mapping and edge enhancement to obtain an enhanced image.
[0050] The residual feature fusion module is used to extract deep feature maps of the enhanced image at different scales, perform two-dimensional fast Fourier transform on the multi-scale feature maps, and extract high-frequency residual information of the image by combining high-pass filter templates. The local attention mechanism is used to guide the fusion of multi-scale features and high-pass residual information, and the multi-scale fused feature maps are spliced and encoded into a unified token sequence for subsequent modeling and reconstruction.
[0051] The self-inductive visual reconstruction module builds a self-inductive model based on the Transformer architecture, performs global modeling and feature reconstruction on the token sequence, and generates a reconstructed feature map.
[0052] The anomaly scoring module compares the unified feature map with the reconstructed feature map, generates a reconstruction error scoring map based on dual error indicators, quantifies the degree of image anomaly, and segments out accurate anomaly region maps.
[0053] The report generation module locates abnormal image regions and generates detection result reports, supporting the visualization and judgment of image-level and region-level anomalies.
[0054] Thirdly, the present invention provides a computer device including a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program is executed by the processor, it implements any step of the artificial intelligence-based industrial image change anomaly detection method described in the first aspect of the present invention.
[0055] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program is executed by a processor, it implements any step of the artificial intelligence-based industrial image change anomaly detection method as described in the first aspect of the present invention.
[0056] The beneficial effects of this invention are as follows: by using dual-source frequency domain saliency fusion, the joint response capability of abnormal regions under multiple light sources is enhanced; by using DoG edge enhancement processing, the image edge texture is strengthened, and the structural contour expression of abnormal regions is improved; by using channel weighting and residual fusion, the model's ability to perceive fine-grained anomalies is improved; by using the self-inductive Transformer feature reconstruction mechanism, the model is forced to summarize the original feature semantics from an incomplete subset, which improves the generalization and robustness of reconstruction and enhances the model's sensitivity to changes in anomaly semantics; by fusing pixel-level reconstruction errors and directional errors, the robustness and discriminative power of anomaly scoring are improved; and by automatically drawing boundaries and heatmaps of anomaly images, the interpretability and spatial perception of anomalies are improved. Attached Figure Description
[0057] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0058] Figure 1 This is a flowchart of the artificial intelligence-based industrial image anomaly detection method in Example 1.
[0059] Figure 2 This is a structural diagram of the artificial intelligence-based industrial image change anomaly detection system in Example 1. Detailed Implementation
[0060] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0061] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.
[0062] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.
[0063] Example 1, referring to Figure 1 and Figure 2This is the first embodiment of the present invention, which provides an artificial intelligence-based method for detecting anomalies in industrial images, including the following steps:
[0064] S1. Acquire industrial images from dual light sources, perform saliency-weighted fusion using a frequency domain saliency-guided fusion strategy, and perform contrast visual enhancement processing through color mapping and edge enhancement to obtain an enhanced image;
[0065] Specifically, acquiring white light industrial images I white Industrial images with blue light oblique illumination I blue Both images are H×W in size and undergo grayscale conversion to obtain a grayscale image G. white and G blue ;
[0066] For grayscale image G white and G blue Perform a 2D Fourier transform and calculate the frequency domain amplitude spectrum to obtain the white light frequency domain amplitude spectrum F. white (u,v) and the frequency domain amplitude spectrum of blue light oblique illumination F blue (u,v);
[0067] A saliency spectrum is constructed based on the frequency domain amplitude spectrum, and then smoothed by a low-pass Gaussian filter, as shown below:
[0068] S f (u,v)=|F blue (u,v)-F white (u,v)|;
[0069]
[0070] M s (u,v)=G σ (u,v)*M(u,v);
[0071] Among them, S f (u,v) represents the saliency matrix, used to measure the intensity of the local response difference between two light source images in the frequency domain, and M(u,v) represents the saliency spectrum, derived from S. f (u,v) is obtained by normalization, M s (u,v) represents the smoothed significance spectrum, G σ (u,v) represents the Gaussian kernel;
[0072] The smoothed saliency spectrum M s (u,v) is remapped to grayscale using bilinear interpolation. Figure One Spatial diagram M of size s (x, y), the spatial graph M sUsing (x, y) as the fusion weights, the images are fused through saliency-weighted fusion to obtain fused image I. fused , is represented as:
[0073] I fused (x, y) = M s (x, y)·G blue (x, y) + (1-M) s (x, y))·G white (x, y);
[0074] Among them, I fused (x, y) represents the fusion graph, M s (x, y) represents the pixel fusion weight, G blue (x, y) and G white (x, y) represent the grayscale images of blue light oblique illumination and white light, respectively;
[0075] Merge Figure I fused Mapping to the RGB pseudo-color space, we get I pseudo ;
[0076] to I pseudo Perform a DoG high-pass filter operation, calculate the edge response, and then... pseudo The enhanced image I is obtained by linearly superimposing the edge response map and normalizing it. final .
[0077] By acquiring industrial images under white light and blue light oblique illumination, and performing grayscale conversion, multi-source image information input under complementary illumination conditions is provided, thereby enhancing the ability to capture the different illumination response characteristics of the target area. By performing a two-dimensional Fourier transform on the dual-source grayscale images and calculating the frequency domain amplitude spectrum, explicit expression of the image's frequency domain information is achieved. This is accomplished by bilinearly interpolating the smoothed saliency spectrum with the original... Figure OneA spatial weight map of equal size is constructed, and saliency-weighted fusion is performed based on this weight map. This achieves fine fusion of images from different light sources in the spatial domain, which is driven by saliency. This strengthens the comprehensive expression of complementary information under two lighting conditions, and ultimately improves the visual perceptibility of image details and abnormal structures. By mapping the fused image to the RGB pseudo-color space, the visual layering ability of the fused image is enhanced, making potential structural change areas more prominent and distinguishable in the color dimension. This facilitates subsequent model or manual observation and recognition, and ultimately improves the visual interactivity and front-end data quality of the entire system. By performing DoG high-pass filtering to extract edge responses and performing linear superposition and normalization processing with the fused image, the response intensity of edge and texture structures is further enhanced. This achieves high-sensitivity enhancement of the expression of small boundary perturbations or crack-like anomalies. The final enhanced image has higher structural contrast and visual clarity, providing a better input foundation for subsequent deep feature extraction models.
[0078] S2. Input the enhanced image into the CNN convolutional network to generate multi-scale feature maps. Extract multi-scale high-pass residual maps through two-dimensional fast Fourier transform and high-pass filter template. Guide the fusion of multi-scale feature maps and multi-scale high-pass residual maps through local attention. Finally, stitch together all scales to obtain a unified feature map and encode it to generate a token sequence.
[0079] Specifically, the enhanced image input is used to pre-train the EfficientNet-B4 backbone network to extract multi-scale feature maps from different depth layers. i It includes the bottom texture feature map f1, the middle structure feature map f2, the high semantic feature map f3, and the top abstract feature map f4;
[0080] For multi-scale feature maps f i Each feature channel c is independently subjected to a two-dimensional fast Fourier transform, represented as:
[0081]
[0082] in, The result represents the Fourier transform, (u,v) represents the frequency domain coordinates, and FFT2D represents the two-dimensional fast Fourier transform;
[0083] Let a constant r0 be defined, and for each position in the frequency domain, define a high-pass filter template H(u,v)∈{0,1}. When the condition is met, H(u,v) is 1; otherwise, H(u,v) is 0.
[0084] The Fourier transform result is filtered in the frequency domain using a high-pass filter template. A two-dimensional inverse fast Fourier transform is then performed on the filtered result, and the absolute value of the real part is taken to obtain the high-pass residual plot. Represented as:
[0085]
[0086] Among them, R i (u,v,c) represents the filtering result, and · represents pointwise complex multiplication. Represents the high-pass residual plot, Re represents the real part extraction operation, and IFFT2D represents the two-dimensional inverse fast Fourier transform;
[0087] For each channel c, the average response of the high-pass residual map on that channel is calculated to obtain the channel weights. A nonlinear mapping is then applied to the channel weights to obtain the attention weights, expressed as:
[0088]
[0089] Among them, w i (c) represents the high-pass residual plot. The channel weight of the c-th channel, H i and W i α represents the size of the high-pass residual plot. i (c) represents the attention weights, and σ represents the Sigmoid function, which maps the attention weights to [0,1].
[0090] Multiply the attention weights point-by-point in each channel of the multi-scale feature map to generate a weighted feature map. Represented as:
[0091]
[0092] in, This represents the weighted characteristic of channel c;
[0093] The weighted feature map and the high-pass residual map are concatenated along the channel dimension, and a 1×1 convolutional layer with a fixed output channel is used for feature compression and fusion, outputting a compressed feature map F. i , is represented as:
[0094]
[0095] Among them, g i F represents a mosaic image. i (x,y) represents the feature compression map, C i Represents weighted feature map Qualcomm residual plot The number of channels, θ k represents the 1×1 convolution kernel weight corresponding to the k-th channel, and b represents the bias term;
[0096] Furthermore, compress all scale features into map F. iBy unifying the data to the same spatial size through bilinear upsampling and then concatenating them, a unified feature map F is obtained;
[0097] Divide F into non-overlapping patches of size P×P, with a total of N patches. Flatten each patch into a token, resulting in a token sequence X, represented as:
[0098] X = {x1, x2, ..., x} N};
[0099] Where X represents the token sequence, x i This represents the token obtained by flattening the i-th non-overlapping patch, and N represents the total number of patches.
[0100] By inputting enhanced images into a pre-trained EfficientNet-B4 backbone network, multi-scale feature maps are extracted from the bottom to the top layers, achieving progressive feature encoding from fine-grained texture to global semantics. This comprehensively captures the structural and variation patterns that may exist in the image at various scales. By independently performing a two-dimensional fast Fourier transform on each feature channel, its frequency domain representation is obtained, enabling global modeling of structural information in the frequency domain. This effectively identifies periodic, marginal, or interfering signal features hidden in local space, ultimately improving the model's ability to separate complex backgrounds from subtle changes. The system can filter Fourier transform results by setting a high-pass filter template and applying it in the frequency domain, further highlighting high-frequency components in the frequency domain. By statistically analyzing the channel responses of the high-pass residual map and applying nonlinear mapping, it obtains attention weights with strong discriminative power, realizing adaptive estimation of the importance of channel-level information. By concatenating the weighted feature map with the high-pass residual map and applying a unified convolution compression operation, it achieves the unification of multi-dimensional feature fusion and redundancy suppression, thereby enhancing the compactness and expression efficiency of the fused map. Finally, it outputs a feature compression map with advantages in structural mutation expression and semantic recognition capabilities.
[0101] By bilinearly upsampling all scale feature maps to the same spatial resolution and then stitching them together, the alignment and fusion of multi-scale feature information in the spatial dimension are achieved. This solves the problem of information fragmentation caused by resolution differences in different feature maps, thereby achieving semantically consistent spatial combination expression. Ultimately, this improves the integrity and contextual relevance of the unified feature expression. Through tokenization, the spatial independence of each local region is maintained, while enhancing the model's ability to locate local anomalies. This allows anomalies to be expressed independently in the sequence with patches as the smallest unit, thereby improving the controllability and interpretability of the subsequent Transformer model in the spatial feature modeling process.
[0102] S3. By combining the self-inductive feature reconstruction mechanism with Transformer, a self-inductive visual model is constructed to reconstruct the features of the token sequence and generate a reconstructed feature map.
[0103] Specifically, construct a set of learnable auxiliary inductive token sequences X with the same dimension as the token sequence X. * Each inductive token parameter is a learnable vector, initialized with a zero-mean Gaussian distribution;
[0104] X * Randomly divided into M non-overlapping subsets Construct a combination sequence Φ for each subset i This includes summarizing token subsets. and X in Non-overlapping patch tokens are represented as:
[0105]
[0106] in, Indicates X and Non-overlapping sequence of patchtokens;
[0107] The combined sequence Φ i The Transformer encoder portion, which shares input parameters, includes an Encoder layer, a multi-head attention mechanism, a feedforward network, and residual connections, to obtain the encoded result Z. i For each encoding result Z i Based on the position index, discard all outputs from the input at the patch token positions, and only extract the encoded result corresponding to the summarized token.
[0108] Concatenate all the inductively encoded token results into a complete sequence Z induced , is represented as:
[0109]
[0110] Using the Transformer decoder, input Z induced The original features are reconstructed and reorganized into a spatial structure to obtain the reconstructed feature map.
[0111] The total loss function is constructed using Euclidean distance loss and cosine similarity loss, and is expressed as follows:
[0112]
[0113] Where L represents the total loss function, and H' and W' represent the dimensions of the uniform feature map. The Euclidean distance loss represents the "pixel-level accuracy" after inductive reconstruction, and λ represents the weighting factor, which can be customized. This represents the cosine similarity loss. Let ||F|| represent the global inner product of the feature maps and ||F|| represent the sum of the sums of the sum This represents the overall modulus of the unified feature map and the reconstructed feature map;
[0114] The model is trained using normal industrial images as the training set, constrained by the total loss function, optimized by gradient descent using the Adam optimizer, and the model parameters are updated. If the model loss no longer decreases significantly during continuous iteration, the iteration is stopped and the model is output.
[0115] Using a trained model, input the newly extracted unified feature map and output the reconstructed feature map.
[0116] By constructing a set of learnable auxiliary inductive token sequences of the same dimension as the token sequence and initializing them with a zero-mean Gaussian distribution, the traditional autoencoder's identity mapping limitation is broken, forcing the Transformer encoder to learn the overall semantic representation of the object. This enables the model to actively adapt to and inductively represent the data feature distribution during the training phase, thereby enhancing the model's ability to aggregate key features and providing a more robust representation foundation for anomaly detection tasks. Through random subset partitioning and the introduction of learnable inductive token sequences, only the encoding results of the inductive tokens are extracted and concatenated into a unified sequence, significantly improving the generalization efficiency in feature reconstruction. This provides a high-density inductive representation carrier for the reconstruction model, enhancing its sensitivity to structural anomalies and texture deviations. The self-supervised task of feature reconstruction forces the model to summarize the original feature semantics from an incomplete subset, improving the generalization and robustness of the reconstruction and enhancing the model's sensitivity to abnormal semantic changes. By constructing a composite loss function that integrates Euclidean distance loss and cosine similarity loss, it not only ensures accurate restoration of the reconstructed image at the pixel level (Euclidean distance) but also strengthens the consistency with the original features in the overall feature direction (cosine similarity), realizing joint constraints on structure and directionality, thereby improving the stability and reliability of abnormal reconstruction detection. By training the self-inductive model using normal samples, it ensures that the model achieves weakly supervised learning without abnormal prior labels, effectively reducing the dependence on manual annotation costs and making the invention more engineering deployable and adaptable to large-scale industrial image applications.
[0117] S4. Using dual error indices, the unified feature map and the reconstructed feature map are fused into a reconstruction error score map. The reconstruction error score map is then sampled using bilinear interpolation and Gaussian filtering to obtain an anomaly smoothing map. Anomaly regions are then segmented based on the anomaly smoothing map.
[0118] Specifically, based on the Euclidean reconstruction error and the orientation error, a reconstruction error score is calculated, and a reconstruction error score map is generated, represented as follows:
[0119]
[0120] Where A(x,y) represents the reconstruction error score at position (x,y). Indicates element-wise multiplication;
[0121] The reconstructed error score map is restored to size H×W through bilinear interpolation upsampling and Gaussian filtering, resulting in the abnormal smooth map A. final ;
[0122] Calculate A final The standard deviation is used as the image-level anomaly score. A threshold T is set. If the image-level anomaly score is greater than the threshold T, it is judged as an abnormal image; otherwise, it is normal.
[0123] If it is an abnormal image, then for the abnormal smoothing map A final An initial mask is generated using a statistical adaptive threshold, which in turn generates a binary image G.
[0124] Extract all connected regions from the binary graph G and output the set of outlier regions R. G .
[0125] By fusing Euclidean reconstruction error and orientation error (cosine distance) to generate a reconstruction error scoring map, a joint expression of structural reconstruction deviation and semantic orientation deviation is achieved. By performing bilinear interpolation upsampling and Gaussian filtering on the reconstruction error scoring map, a more continuous anomaly smoothing map is constructed. This not only restores the information correspondence of the original image size but also suppresses local noise and boundary breaks, thereby enhancing the clustering expression of anomaly regions in the image space. By calculating the standard deviation of the anomaly smoothing map as an image-level anomaly score, an anomaly metric based on the discreteness of the residual distribution is constructed, avoiding single-point anomalies. The risk of misjudgment caused by constant values is eliminated, and the abnormal fluctuation of the entire image is quantified statistically to achieve a highly robust distinction between abnormal and normal images. When an image is judged to be abnormal, a statistical adaptive threshold is applied to the abnormal smooth map to generate an initial binary mask. The threshold boundary can be dynamically determined according to the abnormal distribution characteristics of the image itself, which enhances the adaptability and accuracy of region-level detection. By extracting all connected regions in the binary map, an abnormal region set is output, realizing the spatial localization and morphological reconstruction of abnormal structures. Finally, a dual anomaly detection system of image-level judgment and region-level recognition is constructed.
[0126] S5. Generate an anomaly detection report to locate and visualize abnormal images;
[0127] Specifically, abnormal images in industrial images are marked and the boundaries of abnormal regions are drawn with lines. A heat map is generated based on the reconstruction error score of each pixel in the abnormal region of the abnormal smoothing map.
[0128] Generate anomaly detection reports, including dual-light source industrial images and heat maps depicting the boundaries of the anomaly area;
[0129] By automatically marking images identified as abnormal in industrial images and drawing lines at the boundaries of abnormal areas, the system achieves a visual representation of the detection results and an interpretable expression of the boundaries. By generating pseudo-color heatmaps, a thermal expression mechanism for the internal structure and severity of abnormal areas is constructed, enhancing the quantitative visualization capability of the "strength" of anomalies. By generating detection reports that include the original images, the boundaries of abnormal areas, and heatmaps, a complete detection archive system for industrial quality management is constructed, effectively supporting subsequent abnormal image archiving, quality traceability, production accountability, and process optimization, ultimately achieving seamless integration between the detection system and the industrial system.
[0130] This embodiment also provides an artificial intelligence-based industrial image anomaly detection system, including:
[0131] The dual-light source enhancement module is used to acquire industrial images from dual light sources that complement each other in terms of surface texture and structural information. It generates a fused image through a frequency domain saliency-guided fusion strategy and performs contrast visual enhancement processing through color mapping and edge enhancement to obtain an enhanced image.
[0132] The residual feature fusion module is used to extract deep feature maps of the enhanced image at different scales, perform two-dimensional fast Fourier transform on the multi-scale feature maps, and extract high-frequency residual information of the image by combining high-pass filter templates. The local attention mechanism is used to guide the fusion of multi-scale features and high-pass residual information, and the multi-scale fused feature maps are spliced and encoded into a unified token sequence for subsequent modeling and reconstruction.
[0133] The self-inductive visual reconstruction module builds a self-inductive model based on the Transformer architecture, performs global modeling and feature reconstruction on the token sequence, and generates a reconstructed feature map.
[0134] The anomaly scoring module compares the unified feature map with the reconstructed feature map, generates a reconstruction error scoring map based on dual error indicators, quantifies the degree of image anomaly, and segments out accurate anomaly region maps.
[0135] The report generation module locates abnormal image regions and generates detection result reports, supporting the visualization and judgment of image-level and region-level anomalies.
[0136] This embodiment also provides a computer device applicable to the case of an artificial intelligence-based industrial image change anomaly detection method, including: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the artificial intelligence-based industrial image change anomaly detection method proposed in the above embodiment.
[0137] The computer device can be a terminal, comprising a processor, memory, communication interface, display screen, and input devices 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 the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad on the computer device's casing, or an external keyboard, touchpad, or mouse.
[0138] This embodiment also provides a storage medium storing a computer program, which, when executed by a processor, implements the artificial intelligence-based industrial image change anomaly detection method proposed in the above embodiments. The storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read Only Memory (EPROM), Programmable Red-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0139] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. An artificial intelligence-based method for detecting anomalies in industrial images, characterized in that: include, Dual-light source industrial images were acquired, and a saliency-weighted fusion strategy guided by frequency domain saliency was used for fusion. Contrast enhancement was then performed through color mapping and edge enhancement to obtain an enhanced image. The enhanced image is input into a CNN convolutional network to generate multi-scale feature maps. Multi-scale high-pass residual maps are extracted through two-dimensional fast Fourier transform and high-pass filtering template. Local attention guides the fusion of multi-scale feature maps and multi-scale high-pass residual maps. Finally, all scales are stitched together to obtain a unified feature map and encoded to generate a token sequence. By combining the self-inductive feature reconstruction mechanism with Transformer, a self-inductive visual model is constructed to reconstruct the features of the token sequence and generate a reconstructed feature map. The process involves constructing a self-inductive visual model using a self-inductive feature reconstruction mechanism combined with Transformer, reconstructing features from the token sequence, and generating a reconstructed feature map. This includes... Construct a set of token sequences Same-dimensional learnable auxiliary inductive token sequence Each inductive token parameter is a learnable vector, initialized with a zero-mean Gaussian distribution; Will Randomly divided into M non-overlapping subsets Construct a combination sequence for each subset. This includes summarizing token subsets. and Zhongyu Non-overlapping patch tokens; Combined sequences The Transformer encoder part, which shares input parameters, includes an Encoder layer, a multi-head attention mechanism, a feedforward network, and residual connections, to obtain the encoded result. For each encoding result Based on the position index, discard all outputs from the input at the patch token positions, and only extract the encoded result corresponding to the summarized token. ; Concatenate all the inductive token encoding results into a complete sequence ; The total loss function is constructed using Euclidean distance loss and cosine similarity loss; The model is trained using normal industrial images as the training set, constrained by the total loss function, optimized by gradient descent using the Adam optimizer, and the model parameters are updated. If the model loss no longer decreases significantly during continuous iteration, the iteration is stopped and the model is output. Using the trained model, input the newly extracted unified feature map and output the reconstructed feature map; A dual error index is adopted to fuse the unified feature map and the reconstructed feature map into a reconstruction error score map. The reconstruction error score map is sampled by bilinear interpolation and Gaussian filtering to obtain an anomaly smoothing map. Anomaly regions are segmented based on the anomaly smoothing map. The dual error index includes Euclidean reconstruction error and orientation error; Generate anomaly detection reports to locate and visualize abnormal images.
2. The artificial intelligence-based industrial image anomaly detection method as described in claim 1, characterized in that: The acquired dual-light-source industrial images are subjected to saliency-weighted fusion using a frequency domain saliency-guided fusion strategy, and contrast enhancement is performed through color mapping and edge enhancement to obtain an enhanced image, including... Acquiring white light industrial images Industrial images illuminated by blue light All sizes Then perform grayscale conversion to obtain a grayscale image. and ; grayscale image and Perform a 2D Fourier transform and calculate the frequency domain amplitude spectrum to obtain the white light frequency domain amplitude spectrum. and the frequency domain amplitude spectrum of blue light oblique illumination ; A saliency spectrum is constructed based on the frequency domain amplitude spectrum, and the saliency spectrum is smoothed by low-pass Gaussian filtering. Smoothed saliency spectrum Remapped to a spatial map of the same size as the grayscale image using bilinear interpolation. , spatial map As the fusion weight, the images are fused by saliency weighting to obtain the fused image. ; fusion diagram Mapping to the RGB pseudo-color space yields ; right Perform a DoG high-pass filter operation, calculate the edge response, and then... The enhanced image is obtained by linearly superimposing the edge response map and normalizing it. .
3. The artificial intelligence-based industrial image anomaly detection method as described in claim 2, characterized in that: The process involves inputting the enhanced image into a CNN convolutional network to generate multi-scale feature maps, extracting multi-scale high-pass residual maps through a two-dimensional fast Fourier transform and a high-pass filter template, and guiding the fusion of the multi-scale feature maps and multi-scale high-pass residual maps through local attention. The enhanced image is input into the pre-trained EfficientNet-B4 backbone network to extract multi-scale feature maps from different depth layers. Including underlying texture feature maps Mid-layer structure feature diagram High-level semantic feature map and top-level abstract feature map ; Multi-scale feature maps Each feature channel c is independently subjected to a two-dimensional fast Fourier transform; Set a constant Define a high-pass filter template for each position in the frequency domain. ,when hour, If it is 1, otherwise, =0; The Fourier transform result is filtered in the frequency domain using a high-pass filter template. A two-dimensional inverse fast Fourier transform is then performed on the filtered result, and the absolute value of the real part is taken to obtain the high-pass residual plot. ; For each channel c, calculate the average response of the high-pass residual map on that channel to obtain the channel weights, and apply a nonlinear mapping to the channel weights to obtain the attention weights; Multiply the attention weights point-by-point in each channel of the multi-scale feature map to generate a weighted feature map. ; The weighted feature map and the high-pass residual map are concatenated along the channel dimension, using a fixed output channel. Convolutional layers perform feature compression and fusion, outputting a compressed feature map. .
4. The artificial intelligence-based industrial image anomaly detection method as described in claim 3, characterized in that: The final concatenation of all scales yields a unified feature map, which is then encoded to generate a token sequence, including: Compressed map of all scale features By unifying the data to the same spatial size through bilinear upsampling and then concatenating them, a unified feature map F is obtained; Divide F into parts of size There are N non-overlapping patches. Each patch is flattened into a token, resulting in a token sequence. .
5. The artificial intelligence-based industrial image anomaly detection method as described in claim 4, characterized in that: The method employs a dual error index, fusing the unified feature map and the reconstructed feature map into a reconstruction error score map. This score map is then sampled using bilinear interpolation and Gaussian filtering to obtain an anomaly smoothing map. Anomaly regions are segmented based on this smoothing map, including... Based on the Euclidean reconstruction error and the orientation error, the reconstruction error score is calculated, and a reconstruction error score map is generated; The reconstructed error score map was restored using bilinear interpolation upsampling and Gaussian filtering. Size, to obtain an abnormal smoothing map ; calculate The standard deviation is used as the image-level anomaly score. A threshold T is set. If the image-level anomaly score is greater than the threshold T, it is judged as an abnormal image; otherwise, it is normal. If it is an abnormal image, then apply the abnormal smoothing map. An initial mask is generated using a statistical adaptive threshold, which in turn generates a binary image G. Extract all connected components from the binary graph G and output the set of abnormal regions. .
6. The artificial intelligence-based industrial image anomaly detection method as described in claim 5, characterized in that: The generated anomaly detection report performs anomaly localization and visualization of the abnormal images, including: Anomalies in industrial images are marked and the boundaries of anomalies are drawn with lines. Heatmaps are generated based on the reconstruction error score of each pixel in the anomaly smoothing map. Generate anomaly detection reports, including dual-light source industrial images and thermal maps depicting the boundaries of the anomaly areas.
7. An artificial intelligence-based industrial image anomaly detection system, based on the artificial intelligence-based industrial image anomaly detection method according to any one of claims 1 to 6, characterized in that: include, The dual-light source enhancement module is used to acquire industrial images from dual light sources that complement each other in terms of surface texture and structural information. It generates a fused image through a frequency domain saliency-guided fusion strategy and performs contrast visual enhancement processing through color mapping and edge enhancement to obtain an enhanced image. The residual feature fusion module is used to extract deep feature maps of the enhanced image at different scales, perform two-dimensional fast Fourier transform on the multi-scale feature maps, and extract high-frequency residual information of the image by combining high-pass filter templates. The local attention mechanism is used to guide the fusion of multi-scale features and high-pass residual information, and the multi-scale fused feature maps are spliced and encoded into a unified token sequence for subsequent modeling and reconstruction. The self-inductive visual reconstruction module builds a self-inductive model based on the Transformer architecture, performs global modeling and feature reconstruction on the token sequence, and generates a reconstructed feature map. The anomaly scoring module compares the unified feature map with the reconstructed feature map, generates a reconstruction error scoring map based on dual error indicators, quantifies the degree of image anomaly, and segments out accurate anomaly region maps. The report generation module locates abnormal image regions and generates detection result reports, supporting the visualization and judgment of image-level and region-level anomalies.
8. 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-based industrial image change anomaly detection method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the processor, it implements the steps of the artificial intelligence-based industrial image change anomaly detection method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Industrial surface defect detection method and device based on improved variational auto-encoder
CN118037678A
Image detection method and apparatus, and computer device, storage medium and program product
WO2023207743A1