A Machine Learning-Based Defect Detection Method for Automotive Stamped Parts

By constructing a dual-stream DRAE model for feature fusion and anomaly detection, the accuracy and stability issues of defect detection in automotive stamping parts in existing technologies have been resolved, achieving high-precision defect detection and online detection.

CN122134694APending Publication Date: 2026-06-02CHONGQING JIHU ELECTROMECHANICAL CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHONGQING JIHU ELECTROMECHANICAL CO LTD
Filing Date
2026-03-02
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing technologies struggle to distinguish between reflections, texture disturbances, and actual defects in automotive stamping defect detection. They also lack consistency constraints between appearance residuals and geometric residuals, resulting in insufficient stability in anomaly localization and low accuracy in defect classification.

Method used

A dual-stream DRAE model is constructed. By inputting the standardized detection area image and the enhanced geometric feature map into the appearance branch and the geometric branch respectively for feature extraction, and by realizing feature fusion guided by structural partitioning through the geometric gated cross-flow coupling module, a composite anomaly feature map is generated by combining the appearance residual map and the geometric residual map. Pixel-level anomaly discrimination and connected component analysis are performed, and the category is determined by combining the defect region parameters.

Benefits of technology

It improves the accuracy of anomaly location, reduces the probability of misjudgment caused by changes in lighting, achieves high-precision defect classification and online detection, and improves the automation level and data traceability of detection results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122134694A_ABST
    Figure CN122134694A_ABST
Patent Text Reader

Abstract

This invention discloses a machine learning-based method for detecting defects in automotive stamping parts, comprising the following steps: acquiring surface images of automotive stamping parts using an industrial camera and preprocessing them; constructing and processing a geometric feature map based on standardized detection area images to obtain an enhanced geometric feature map; obtaining a reconstructed appearance image and a reconstructed geometric feature map using a two-stream DRAE model; obtaining a composite anomaly feature map based on the standardized detection area image, the reconstructed appearance image, and the reconstructed geometric feature map; inputting the composite anomaly feature map into a discriminant branch to obtain a pixel-level anomaly heatmap; performing connected component analysis on the anomaly region map to obtain a set of defect candidate regions; determining the defect category and generating defect location coordinates and defect category information; and generating a detection record based on the defect location coordinates, defect category information, and quality judgment results. This invention employs a two-stream DRAE model to achieve defect detection in stamping parts.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image analysis and machine vision inspection technology, and in particular to a machine learning-based method for detecting defects in automotive stamping parts. Background Technology

[0002] As the automotive manufacturing industry places increasing demands on product appearance quality and structural precision, the inspection of surface defects in automotive stamping parts is gradually shifting from manual visual inspection to automated inspection methods based on image processing.

[0003] Existing technologies typically use industrial cameras to capture images of the surface of stamped parts, and then identify defects through image preprocessing, feature extraction, and classification models.

[0004] In some schemes, convolutional neural networks are introduced to learn features of the image and generate anomaly response maps based on reconstruction errors or classification results. Then, defect regions are determined through threshold segmentation and connected component analysis.

[0005] However, existing technologies mostly rely on single appearance images for anomaly detection, failing to collaboratively model surface geometry and structural region information, making it difficult to distinguish between reflections, texture disturbances, and actual defects. While some methods employ deep learning models for reconstruction or segmentation, they lack a consistency constraint mechanism for appearance and geometric residuals, resulting in insufficient stability in anomaly localization. Furthermore, in the process of defect category and quality determination, the area parameters, morphological parameters, and anomaly intensity parameters are not structurally combined and analyzed, affecting the accuracy of defect classification.

[0006] Therefore, how to provide a machine learning-based method for detecting defects in automotive stamping parts is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0007] One objective of this invention is to propose a machine learning-based defect detection method for automotive stamping parts. This invention constructs a dual-stream DRAE model, inputting standardized detection area images and enhanced geometric feature maps into appearance and geometry branches respectively for feature extraction. A geometrically gated cross-flow coupling module enables feature fusion guided by structural partitioning. Simultaneously, a composite anomaly feature map is constructed by combining appearance and geometry residual maps, performing pixel-level anomaly discrimination in the discrimination branch. Defect category and quality assessment are achieved through connected component analysis and defect region parameter calculation. This invention fully integrates appearance texture information and geometric morphology information to achieve adaptive anomaly detection in structural regions, possessing advantages such as high anomaly localization accuracy, strong anti-reflective interference capability, good defect classification stability, and applicability to online inspection on industrial production lines.

[0008] A machine learning-based defect detection method for automotive stamping parts according to an embodiment of the present invention includes the following steps:

[0009] The surface images of automotive stamping parts are acquired by an industrial camera, preprocessed to obtain standardized inspection area images, and structural partition masks are generated based on the structural contour of the stamping parts.

[0010] Geometric feature maps are constructed based on standardized detection region images. These geometric feature maps are then processed to obtain enhanced geometric feature maps, which are then aligned with structural partitioning masks.

[0011] The standardized detection region image and the enhanced geometric feature map are input into the dual-stream DRAE model to obtain the reconstructed appearance image and the reconstructed geometric feature map.

[0012] The appearance residual map is calculated based on the standardized detection region image and the reconstructed appearance image. The geometric residual map is calculated based on the enhanced geometric feature map and the reconstructed geometric feature map, and a composite anomaly feature map is obtained.

[0013] Input the composite anomaly feature map into the discrimination branch, perform pixel-level anomaly discrimination on the composite anomaly feature map, and obtain a pixel-level anomaly heatmap;

[0014] Threshold segmentation is performed on the pixel-level anomaly heatmap to obtain an anomaly region map, and connected component analysis is performed on the anomaly region map to obtain a set of defect candidate regions.

[0015] Based on the defect candidate region set, defect region parameters are obtained, defect category is determined, defect category information and quality judgment results are obtained, and defect location coordinates and defect category information are generated.

[0016] The system outputs the defect location coordinates, defect category information, and quality judgment results to the production line control system and generates inspection records.

[0017] Optionally, the preprocessing includes distortion correction, brightness normalization, and pose alignment.

[0018] Optionally, the step of constructing a geometric feature map based on the standardized detection region image, processing the geometric feature map to obtain an enhanced geometric feature map, and aligning the enhanced geometric feature map with the structural partition mask specifically includes:

[0019] Geometric feature maps are constructed based on standardized detection region images. The geometric feature maps are then smoothed and filtered. Finally, a pre-defined convolution kernel is used to perform convolution operations on the geometric feature maps to obtain smoothed geometric feature maps.

[0020] Gradient enhancement processing is applied to the smoothed geometric feature map to form a gradient-enhanced geometric feature map.

[0021] Local contrast enhancement processing is performed on the gradient-enhanced geometric feature map to form an enhanced geometric feature map.

[0022] Spatially align the enhanced geometric feature map with the structural partition mask to ensure a one-to-one correspondence between the enhanced geometric feature map and the structural partition mask in pixel coordinates.

[0023] Optionally, the step of inputting the standardized detection region image and enhanced geometric feature map into the dual-stream DRAE model to obtain the reconstructed appearance image and reconstructed geometric feature map specifically includes:

[0024] The standardized detection region image is input into the appearance branch of the dual-stream DRAE model, and the first set of convolution parameters is used to perform multi-layer convolution operations on the standardized detection region image to obtain the appearance feature map.

[0025] The enhanced geometric feature map is input into the geometric branch of the dual-stream DRAE model, and multi-layer convolution operation is performed on the enhanced geometric feature map using the second convolution parameter set to obtain the geometric feature map.

[0026] The geometric feature map is input into the geometric gated cross-current coupling module to generate a gated weight map. The appearance feature map is then fused element by element based on the gated weight map to obtain the fused feature map.

[0027] The fused feature map is input into the reconstruction branch of the dual-stream DRAE model. The fused feature map is then processed by upsampling and convolution operations through the decoding network to obtain the reconstructed appearance image and the reconstructed geometric feature map.

[0028] Optionally, the step of inputting the geometric feature map into the geometric gated cross-current coupling module to generate a gated weight map, and then performing element-wise weighted fusion of the appearance feature map based on the gated weight map to obtain the fused feature map specifically includes:

[0029] The geometric feature map is input into the geometric gated cross-current coupling module, and a structural modulation geometric feature map is constructed based on the geometric feature map and the structural partition mask.

[0030] Multi-scale transformation is performed on the structure modulation geometric feature map to obtain a multi-scale structure modulation geometric feature map;

[0031] Based on the multi-scale structure modulation geometric feature map, the geometric response intensity value is calculated to obtain the geometric response intensity map;

[0032] Based on the structural partition mask and geometric response intensity map, a region normalized response map is generated in each structural region.

[0033] The region normalized response map is mapped to an upsampled gated weight map, and the upsampled gated weight maps at each scale are fused across scales to obtain the gated weight map.

[0034] The appearance feature map is fused element by element based on the gating weight map to obtain the fused feature map.

[0035] Optionally, the step of calculating the appearance residual map based on the standardized detection region image and the reconstructed appearance image, calculating the geometric residual map based on the enhanced geometric feature map and the reconstructed geometric feature map, and obtaining the composite anomaly feature map specifically includes:

[0036] The appearance residual value is calculated based on the standardized detection area image and the reconstructed appearance image to obtain the appearance residual map;

[0037] Geometric residual values ​​are calculated based on the enhanced geometric feature map and the reconstructed geometric feature map to obtain the geometric residual map;

[0038] The appearance residual map and the geometric residual map are normalized to obtain the normalized appearance residual map and the normalized geometric residual map.

[0039] The normalized appearance residual map, normalized geometric residual map, fused feature map, and structural partition mask are concatenated to obtain a composite anomaly feature map.

[0040] Optionally, the step of inputting the composite anomaly feature map into the discrimination branch and performing pixel-level anomaly discrimination on the composite anomaly feature map to obtain a pixel-level anomaly heatmap specifically includes:

[0041] The composite anomaly feature map is input into the discriminant branch of the dual-stream DRAE model. The discriminant branch performs pixel-level feature mapping on the composite anomaly feature map to obtain the pixel-level discriminant feature map.

[0042] The basic anomaly score is calculated based on the pixel-level discriminative feature map to obtain the pixel-level basic anomaly score map.

[0043] Normalized appearance residual map, normalized geometric residual map and structural partition mask are extracted from the composite anomaly feature map, and pixel-level residual consistency score map is calculated based on the normalized appearance residual map and normalized geometric residual map.

[0044] A pixel-level joint anomaly score map is generated based on the pixel-level basic anomaly score map and the pixel-level residual consistency score map.

[0045] Activation function mapping is applied to the pixel-level joint anomaly score map to obtain a pixel-level anomaly heatmap.

[0046] Optionally, the step of performing threshold segmentation on the pixel-level anomaly heatmap to obtain an anomaly region map, and performing connected component analysis on the anomaly region map to obtain a set of defect candidate regions specifically includes:

[0047] Threshold segmentation is performed on pixel-level anomaly heatmaps to obtain anomaly region maps;

[0048] Connectivity analysis is performed on the abnormal region map. The connectivity of pixels with a value of one in the abnormal region map is determined by the connected neighborhood rule, resulting in multiple connected regions.

[0049] Calculate the region attributes for each connected component to obtain the number of pixels and the coordinates of the bounding rectangle corresponding to each connected component, and form a set of connected component attributes.

[0050] Based on the set of connected component attributes, defect candidate regions are obtained by filtering connected components, resulting in a set of defect candidate regions.

[0051] Optionally, the step of obtaining defect region parameters based on the defect candidate region set, determining the defect category, obtaining defect category information and quality judgment results, and generating defect location coordinates and defect category information specifically includes:

[0052] For each defect candidate region in the defect candidate region set, the area parameter is calculated, and the shape parameter is calculated based on the coordinates of the bounding rectangle. The shape parameter includes the width parameter, height parameter, and aspect ratio parameter. The anomaly intensity parameter is calculated based on the pixel-level anomaly heatmap.

[0053] The area parameters, shape parameters, and abnormal intensity parameters are combined to form the defect area parameters. The defect category is determined according to the judgment rules to obtain the defect category information.

[0054] The quality of the defect area parameters is determined based on the set of quality judgment thresholds, and the quality judgment result is obtained.

[0055] When the quality judgment result is unqualified, the defect location coordinates are generated based on the coordinates of the circumscribed rectangle, and the defect location coordinates and defect category information are output.

[0056] Optionally, the step of outputting the defect location coordinates, defect category information, and quality judgment results to the production line control system and generating an inspection record specifically includes:

[0057] For each defect candidate region, when the quality judgment result is unqualified, the corresponding defect location coordinates, defect category information and quality judgment result are read to construct the physical location coordinates of the defect;

[0058] The physical location coordinates of the defect, the defect category information, and the quality judgment results are encapsulated into a detection data message according to the data format.

[0059] The detection data message is sent to the production line control system through the communication interface, and the detection data message is verified and encoded during the transmission process to generate a verification field;

[0060] Inspection records are generated based on the defect location coordinates, defect category information, and quality judgment results.

[0061] The beneficial effects of this invention are:

[0062] This invention constructs a dual-stream DRAE model, extracting features from the standardized detection region image and the enhanced geometric feature map separately. Cross-modal feature fusion is achieved through a geometrically gated cross-stream coupling module, enabling appearance and geometric information to form a structural association under the same pixel coordinates. By generating a gated weight map under structural partitioning mask constraints, adaptive modulation of different structural regions is achieved, thereby improving the consistency of abnormal response expression within key structural regions and reducing the probability of misjudgment caused by illumination changes and surface reflection.

[0063] This invention constructs separate appearance residual maps and geometric residual maps, and integrates residual consistency information into the composite anomaly feature map, enabling pixel-level anomaly discrimination to make joint decisions based on both appearance and geometric evidence. Through the calculation and activation mapping of pixel-level joint anomaly scores, anomaly heatmaps can be generated while maintaining spatial resolution, thereby improving the precision and continuity of defect region localization and providing a stable input foundation for subsequent connected component analysis.

[0064] This invention introduces a structured combination analysis of area parameters, morphological parameters, and anomaly intensity parameters at the defect candidate region level, and combines this with preset judgment rules to complete defect category and quality judgment, realizing the transformation from pixel-level anomaly detection to region-level defect identification and quality decision-making. Simultaneously, by converting the defect location coordinates into physical coordinates in the production line coordinate system and outputting the detection record, the detection results are integrated with the production line control system, improving the automation level and data traceability of the online detection process. Attached Figure Description

[0065] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:

[0066] Figure 1 This is a flowchart of a machine learning-based defect detection method for automotive stamping parts proposed in this invention.

[0067] Figure 2 This is a schematic diagram of the dual-flow DRAE model in the machine learning-based defect detection method for automotive stamping parts proposed in this invention.

[0068] Figure 3 This is a schematic diagram of the geometric gated cross-flow coupling module in a machine learning-based defect detection method for automotive stamping parts proposed in this invention. Detailed Implementation

[0069] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.

[0070] refer to Figures 1-3 A machine learning-based method for detecting defects in automotive stamping parts includes the following steps:

[0071] The surface images of automotive stamping parts are acquired by an industrial camera, preprocessed to obtain standardized inspection area images, and structural partition masks are generated based on the structural contour of the stamping parts.

[0072] Geometric feature maps are constructed based on standardized detection region images. These geometric feature maps are then processed to obtain enhanced geometric feature maps, which are then aligned with structural partitioning masks.

[0073] The standardized detection region image and the enhanced geometric feature map are input into the dual-stream DRAE model to obtain the reconstructed appearance image and the reconstructed geometric feature map.

[0074] The appearance residual map is calculated based on the standardized detection region image and the reconstructed appearance image. The geometric residual map is calculated based on the enhanced geometric feature map and the reconstructed geometric feature map, and a composite anomaly feature map is obtained.

[0075] Input the composite anomaly feature map into the discrimination branch, perform pixel-level anomaly discrimination on the composite anomaly feature map, and obtain a pixel-level anomaly heatmap;

[0076] Threshold segmentation is performed on the pixel-level anomaly heatmap to obtain an anomaly region map, and connected component analysis is performed on the anomaly region map to obtain a set of defect candidate regions.

[0077] Based on the defect candidate region set, defect region parameters are obtained, defect category is determined, defect category information and quality judgment results are obtained, and defect location coordinates and defect category information are generated.

[0078] The system outputs the defect location coordinates, defect category information, and quality judgment results to the production line control system and generates inspection records.

[0079] In this embodiment, images of the surface of automotive stamping parts are acquired using an industrial camera, preprocessed to obtain standardized inspection area images, and structural partition masks are generated based on the structural contour of the stamping parts. Specifically, this includes:

[0080] The surface image of automotive stamping parts is acquired by an industrial camera to obtain the original appearance image. The original appearance image is represented by the grayscale or brightness distribution of the original appearance image in pixel coordinates. The pixel coordinates consist of horizontal and vertical coordinates, which are used to characterize the position of each pixel in the original appearance image.

[0081] The original appearance image is subjected to distortion correction processing. The distortion correction image is obtained by using the camera intrinsic parameter matrix and distortion coefficient vector to perform distortion removal mapping on the original appearance image. The camera intrinsic parameter matrix includes focal length parameters and principal point coordinate parameters. The distortion coefficient vector is used to describe the radial and tangential distortion characteristics of the lens. By performing inverse coordinate transformation on the coordinates of each pixel in the original appearance image according to the camera intrinsic parameter matrix and distortion coefficient vector, the lens imaging distortion is eliminated, and the distortion correction image is obtained.

[0082] The distortion-corrected image is subjected to brightness normalization processing. The calculation is performed by subtracting the minimum gray value in the distortion-corrected image from the gray value of each pixel in the distortion-corrected image, and then dividing by the difference between the maximum and minimum gray values ​​in the distortion-corrected image. The brightness normalization image is used to linearly scale the gray range of the distortion-corrected image to make its gray value distribution uniform.

[0083] The brightness-normalized image is subjected to pose alignment processing. The transformation matrix is ​​calculated through feature matching or template matching, and the transformation matrix is ​​used to perform geometric transformation on the brightness-normalized image to obtain a standardized detection region image. The geometric transformation is implemented by mapping the coordinate points of the brightness-normalized image in pixel coordinates to the new pixel coordinate positions through the transformation matrix and then resampling. The transformation matrix includes translation parameters, rotation parameters, and scaling parameters, which are used to align the brightness-normalized images under different acquisition poses to a unified standard coordinate system, thereby obtaining a standardized detection region image.

[0084] The structural contour of the stamping part is extracted based on the standardized detection area image, the edge response map is calculated by the edge detection algorithm, and the structural contour area is obtained by connected component analysis.

[0085] A structural partition mask is generated based on the structural contour region. The structural partition mask is a binary image with the same size as the standardized detection region image, which is used to represent the spatial distribution of different structural regions of the stamping part.

[0086] In this embodiment, constructing a geometric feature map based on a standardized detection region image, processing the geometric feature map to obtain an enhanced geometric feature map, and aligning the enhanced geometric feature map with the structural partition mask specifically includes:

[0087] Geometric feature maps are constructed based on standardized detection region images. When the geometric feature map is a normal map, image sequences under different illumination directions are obtained through multi-source imaging, and the surface normal vector components of each pixel are calculated based on the illumination direction vector to obtain the normal map.

[0088] When the geometric feature map is a depth map, the depth value corresponding to the standardized detection region image is obtained by using a depth sensor to obtain the depth map;

[0089] When the geometric feature map is a curvature proxy map, the curvature response value is calculated based on the gray-level gradient of the standardized detection region image;

[0090] The curvature response value is determined as follows: the square of the gradient value in the horizontal coordinate direction of the standardized detection region image is added to the square of the gradient value in the vertical coordinate direction, and then the square root is taken to obtain the curvature response value. The distribution of the curvature response value in the pixel coordinates is used to construct the curvature proxy map.

[0091] The gradient value of the standardized detection region image in the horizontal coordinate direction represents the gray-level change rate of the standardized detection region image along the horizontal coordinate, and the gradient value of the standardized detection region image in the vertical coordinate direction represents the gray-level change rate of the standardized detection region image along the vertical coordinate.

[0092] The geometric feature map is smoothed by a pre-defined convolution kernel. The convolution operation is performed by multiplying the value of each pixel in the geometric feature map with the coefficients at the corresponding positions in the convolution kernel point by point and then summing the results in a weighted result. The convolution kernel is a filter template used to suppress high-frequency noise. The smoothed geometric feature map is used to reduce noise interference in the geometric feature map and maintain the continuity of the overall structure.

[0093] Gradient enhancement processing is performed on the smoothed geometric feature map. The gradient values ​​of the smoothed geometric feature map in the horizontal coordinate direction and the gradient values ​​in the vertical coordinate direction are calculated respectively. The gradient value in the horizontal coordinate direction represents the rate of change of the smoothed geometric feature map along the horizontal coordinate, and the gradient value in the vertical coordinate direction represents the rate of change of the smoothed geometric feature map along the vertical coordinate.

[0094] The square of the gradient value in the horizontal coordinate direction is added to the square of the gradient value in the vertical coordinate direction, and then the square root is taken to obtain the gradient magnitude corresponding to each pixel. The distribution of the gradient magnitude under the pixel coordinates constitutes the geometric feature map after gradient enhancement.

[0095] Local contrast enhancement processing is performed on the gradient-enhanced geometric feature map. In the gradient-enhanced geometric feature map, a local window of a preset size is constructed with each pixel as the center. The average value of all pixel values ​​in the local window is calculated as the local mean, and the square root of the average of the squares of the deviations of all pixel values ​​in the local window from the local mean is calculated as the local standard deviation.

[0096] Subtract the corresponding local mean from the value of each pixel in the gradient-enhanced geometric feature map, and then divide by the corresponding local standard deviation to obtain the normalized pixel value. The distribution of the normalized pixel value in the pixel coordinates constitutes the enhanced geometric feature map.

[0097] Spatially align the enhanced geometric feature map with the structural partition mask to ensure a one-to-one correspondence between the enhanced geometric feature map and the structural partition mask in pixel coordinates.

[0098] In this embodiment, the standardized detection region image and enhanced geometric feature map are input into the dual-stream DRAE model to obtain the reconstructed appearance image and reconstructed geometric feature map, specifically including:

[0099] The standardized detection region image is input into the appearance branch of the dual-stream DRAE model, and the first set of convolution parameters is used to perform multi-layer convolution operations on the standardized detection region image to obtain the appearance feature map.

[0100] The first convolution parameter set includes multiple convolution kernel weight parameters and bias parameters. In the two-stream DRAE model, the first convolution parameter set is only used for the appearance branch and is not shared with the geometry branch.

[0101] The appearance branch adopts a small receptive field configuration, which includes using a smaller size convolution kernel or a convolution structure with a smaller dilation rate to enhance the response to texture details, edge contours and local brightness changes in the standardized detection region image, thereby obtaining the appearance feature map;

[0102] The enhanced geometric feature map is input into the geometric branch of the dual-stream DRAE model, and multi-layer convolution operation is performed on the enhanced geometric feature map using the second convolution parameter set to obtain the geometric feature map.

[0103] The second convolution parameter set includes multiple convolution kernel weight parameters and bias parameters. In the two-stream DRAE model, the second convolution parameter set is only used for the geometric branch and is not shared with the appearance branch.

[0104] The geometric branch employs a large receptive field configuration, which includes using larger-sized convolutional kernels or convolutional structures with larger dilation rates to enhance the response to cross-regional topographic variations, curvature abrupt changes, and surface continuity features in the enhanced geometric feature map.

[0105] The geometric feature map is input into the geometric gated cross-current coupling module to generate a gated weight map. The appearance feature map is then fused element by element based on the gated weight map to obtain the fused feature map.

[0106] The fused feature map is input into the reconstruction branch of the dual-stream DRAE model. The decoding network performs upsampling and convolution operations on the fused feature map to obtain the reconstructed appearance image and the reconstructed geometric feature map.

[0107] Upsampling is used to restore the fused feature map to the same spatial resolution as the standardized detection region image in the spatial dimension step by step, and convolution operation is used to perform non-linear mapping on the upsampled features;

[0108] The reconstructed appearance image is the appearance reconstruction result generated in pixel coordinates based on the fused feature map, and the reconstructed appearance image is consistent with the standardized detection region image in terms of spatial size;

[0109] The reconstructed geometric feature map is the geometric reconstruction result generated from the fused feature map in pixel coordinates, and the reconstructed geometric feature map is spatially similar to the enhanced geometric feature map. Figure 1 To.

[0110] In this embodiment, the geometric feature map is input into the geometric gated cross-current coupling module to generate a gated weight map, and the appearance feature map is then fused element-by-element based on the gated weight map to obtain the fused feature map. Specifically, the fused feature map includes:

[0111] The geometric feature map is input into the geometric gated cross-current coupling module. Based on the geometric feature map and the structural partition mask, a structural modulation geometric feature map is constructed. Specifically, under the same pixel coordinates and the same feature channel index, the feature value at the corresponding position in the geometric feature map is multiplied element-wise with the mask value at the corresponding position in the structural partition mask to obtain the structural modulation geometric feature map. The structural modulation geometric feature map is consistent with the geometric feature map in terms of the dimensions of pixel coordinates and feature channel index.

[0112] Multi-scale transformation is performed on the structure modulation geometric feature map. Specifically, the structure modulation geometric feature map is scaled in the spatial resolution dimension by a preset number of scales. The scale transformation process includes downsampling or pooling of the structure modulation geometric feature map to obtain multi-scale structure modulation geometric feature maps with at least two scales. Each scale in the multi-scale structure modulation geometric feature map corresponds to a scale index. The scale index is used to distinguish multi-scale structure modulation geometric feature maps under different spatial resolutions. Moreover, the multi-scale structure modulation geometric feature maps at each scale are consistent with the structure modulation geometric feature map in the feature channel index dimension.

[0113] Based on the multi-scale structure modulation geometric feature map, the geometric response intensity map is calculated. Specifically, for the multi-scale structure modulation geometric feature map corresponding to any scale index, under the same pixel coordinate, the feature values ​​of the pixel in all feature channel indices are squared, and then the squares of the channel dimensions are summed. Then, the square root of the summation is performed to obtain the geometric response intensity value corresponding to the pixel coordinate. The distribution of the geometric response intensity values ​​of each pixel coordinate in spatial location constitutes the scale geometric response intensity map. The summation of the squares of the channel dimensions represents the process of squaring and accumulating all channels of the multi-scale structure modulation geometric feature map in the feature channel index dimension.

[0114] Based on the structural partition mask and geometric response intensity map, a region normalized response map is generated in each structural region.

[0115] The structural partition mask is represented as a set of at least two structural regions. Specifically, the structural partition mask is divided into multiple non-overlapping structural region masks. Each structural region mask corresponds to a structural region index, which is used to identify different structural regions. The number of structural regions is represented by a structural region number sign, and the values ​​of each structural region mask at any pixel coordinate are summed to one.

[0116] Based on this, a region-normalized response map is generated in each structural region based on the geometric response intensity map at any scale. The region-normalized response map is generated by determining the structural region mask to which the pixel coordinate belongs at any pixel coordinate, then performing an exponential operation on the geometric response intensity value at the pixel coordinate to obtain the exponential response value, using the sum of the exponential response values ​​of all pixel coordinates in the structural region plus a preset constant as the normalization denominator, and using the exponential response value at the pixel coordinate as the normalization numerator to calculate the normalized response value at the pixel coordinate. The preset constant is used to prevent the normalization denominator from being zero.

[0117] The normalized response value is multiplied by the value of the structure region mask at the pixel coordinates, and the product results corresponding to all structure region indices are summed to obtain the region normalized response map at the pixel coordinates. The pixel coordinates within the structure region refer to the pixel coordinates that are in the same structure region as the pixel coordinates.

[0118] Mapping the region normalized response map to an upsampled gated weight map involves copying and extending the normalized response value of the region normalized response map at each pixel coordinate to the feature channel index dimension under any scale index, so that the gated weight values ​​corresponding to each feature channel index at the same pixel coordinate are the same, thus obtaining the gated weight map.

[0119] The gating weight map is generated by setting the value of the gating weight map at pixel coordinates to be equal to the value of the region normalized response map at the corresponding pixel coordinates.

[0120] Upsampling is performed on the gated weight map to make it spatially similar to the appearance features. Figure 1 Thus, an upsampled gated weight map is obtained, wherein the upsampling process involves improving the spatial resolution of the gated weight map and generating a pixel coordinate system corresponding to the appearance features. Figure 1 A corresponding distribution of gating weight values;

[0121] Cross-scale fusion is performed on the upsampled gated weight maps at each scale. Specifically, for the upsampled gated weight map corresponding to each scale index, a preset scale fusion coefficient is assigned. Under the same pixel coordinates and the same feature channel index, the upsampled gated weight map of each scale is multiplied by the corresponding scale fusion coefficient in a weighted manner and then summed in a weighted manner to obtain the gated weight map. The gated weight map is generated by linearly weighting and superimposing the upsampled gated weight maps of each scale according to their scale fusion coefficients to obtain the final gated weight value distribution. The scale fusion coefficients satisfy that the sum of the scale fusion coefficients of all scale indices is equal to one, so that the overall weight magnitude of the gated weight map remains consistent after cross-scale fusion.

[0122] The appearance feature map is fused element by element based on the gating weight map to obtain the fused feature map.

[0123] In this embodiment, the calculation of the appearance residual map based on the standardized detection region image and the reconstructed appearance image, the calculation of the geometric residual map based on the enhanced geometric feature map and the reconstructed geometric feature map, and the resulting composite anomaly feature map specifically include:

[0124] The appearance residual value is calculated based on the standardized detection region image and the reconstructed appearance image to obtain the appearance residual map. Specifically, under the same pixel coordinates, the difference between the gray value of the corresponding pixel in the standardized detection region image and the gray value of the corresponding pixel in the reconstructed appearance image is calculated. Then, the element-wise absolute value operation is performed on the difference to obtain the appearance residual value at the corresponding pixel coordinates. The appearance residual map is constructed by the spatial distribution of the appearance residual values ​​at each pixel coordinate. The element-wise absolute value operation means taking the absolute value of the difference for each pixel. The appearance residual map is consistent with the standardized detection region image in the pixel coordinate dimension.

[0125] Geometric residuals are calculated based on the enhanced geometric feature map and the reconstructed geometric feature map to obtain the geometric residual map. Specifically, at the same pixel coordinates, the geometric feature values ​​of the corresponding pixels in the enhanced geometric feature map and the corresponding pixels in the reconstructed geometric feature map are compared. Then, the element-wise absolute value operation is performed on the difference to obtain the geometric residual value at the corresponding pixel coordinates. The geometric residual map is constructed by the spatial distribution of the geometric residual values ​​at each pixel coordinate. The element-wise absolute value operation means taking the absolute value of the difference for each pixel. The geometric residual map is consistent with the enhanced geometric feature map in the pixel coordinate dimension.

[0126] The appearance residual map and the geometric residual map are normalized to obtain the normalized appearance residual map and the normalized geometric residual map.

[0127] Specifically, minimum and maximum values ​​are calculated for the appearance residual plot and the geometric residual plot respectively, to obtain the minimum and maximum residual values ​​of the appearance residual plot and the geometric residual plot.

[0128] The appearance residual value at any pixel coordinate in the appearance residual map is normalized in the following way: the minimum residual value of the appearance residual map is subtracted from the appearance residual value, and then divided by the difference between the maximum residual value and the minimum residual value of the appearance residual map, so as to obtain the normalized appearance residual value at the pixel coordinate. The normalized appearance residual map is constructed by the spatial distribution of the normalized appearance residual values ​​at each pixel coordinate.

[0129] The geometric residual value at any pixel coordinate in the geometric residual map is normalized as follows: the geometric residual value is subtracted from the minimum residual value of the geometric residual map, and then divided by the difference between the maximum residual value and the minimum residual value of the geometric residual map to obtain the normalized geometric residual value at the pixel coordinate. The distribution of the normalized geometric residual values ​​at each pixel coordinate in spatial location constitutes the normalized geometric residual map, so that both the normalized appearance residual value and the normalized geometric residual value are limited to between zero and one.

[0130] The normalized appearance residual map, normalized geometric residual map, fused feature map, and structural partition mask are concatenated by channel concatenation. Specifically, at the same pixel coordinates, the normalized appearance residual value of the normalized appearance residual map at the pixel coordinates is used as one residual channel, and the normalized geometric residual value of the normalized geometric residual map at the pixel coordinates is used as another residual channel. The feature values ​​corresponding to the feature channel indices of the fused feature map at the pixel coordinates and the mask value of the structural partition mask at the same pixel coordinates are concatenated and combined according to the feature channel index dimension to obtain the composite anomaly feature map. The composite anomaly feature map is consistent with the normalized detection region image in the pixel coordinate dimension, and the feature channel index of the composite anomaly feature map is composed of the feature channel index of the fused feature map and the newly added channels corresponding to the normalized appearance residual map, normalized geometric residual map, and structural partition mask.

[0131] In this embodiment, inputting the composite anomaly feature map into the discrimination branch and performing pixel-level anomaly discrimination on the composite anomaly feature map to obtain a pixel-level anomaly heatmap specifically includes:

[0132] The composite anomaly feature map is input into the discriminant branch of the dual-stream DRAE model. The discriminant branch performs pixel-level feature mapping on the composite anomaly feature map to obtain the pixel-level discriminant feature map.

[0133] The basic anomaly score is calculated based on the pixel-level discriminative feature map to obtain the pixel-level basic anomaly score map. The pixel-level basic anomaly score map is generated by weighted summation of the feature values ​​corresponding to each feature channel index at the same pixel coordinate in the pixel-level discriminative feature map. The weighted summation is to multiply the feature value corresponding to each feature channel index by the corresponding discriminative weight and then sum them to obtain the basic anomaly score at the pixel coordinate.

[0134] Normalized appearance residual map, normalized geometric residual map and structural partition mask are extracted from the composite anomaly feature map, and pixel-level residual consistency score map is calculated based on the normalized appearance residual map and normalized geometric residual map.

[0135] The pixel-level residual consistency score map is calculated by multiplying the normalized appearance residual value of the normalized appearance residual map at the pixel coordinates with the normalized geometric residual value of the normalized geometric residual map at the pixel coordinates element by element to obtain an intermediate consistency value. Then, the intermediate consistency value is multiplied element by element with the mask value of the structure partition mask at the pixel coordinates to obtain the residual consistency score value at the pixel coordinates. The pixel-level residual consistency score map is constructed by the spatial distribution of the residual consistency scores at each pixel coordinate.

[0136] A pixel-level joint anomaly score map is generated based on the pixel-level basic anomaly score map and the pixel-level residual consistency score map.

[0137] A pixel-level joint anomaly score map is generated based on the pixel-level basic anomaly score map and the pixel-level residual consistency score map. Specifically, under the same pixel coordinates, the basic anomaly score value of the pixel-level basic anomaly score map at the pixel coordinates is read, and the residual consistency score value of the pixel-level residual consistency score map at the pixel coordinates is read.

[0138] The joint anomaly score at the pixel coordinates is calculated using a weighted linear combination method. The weighted linear combination method is to multiply the basic anomaly score by a weighting coefficient and then add the result of multiplying the residual consistency score by one and subtracting the weighting coefficient to obtain the joint anomaly score at the pixel coordinates.

[0139] The weighting coefficients range from zero to one, and the distribution of the joint anomaly score at each pixel coordinate in spatial location constitutes a pixel-level joint anomaly score map.

[0140] Activation function mapping is applied to the pixel-level joint anomaly score map to obtain a pixel-level anomaly heatmap. Specifically, under the same pixel coordinates, activation function mapping is applied to the joint anomaly score values ​​at the pixel coordinates of the pixel-level joint anomaly score map. The joint anomaly score value is inversely inverted and then exponentially calculated. The result of the exponential calculation is added to one as the denominator, and a division operation is performed with one as the numerator to obtain the anomaly heatmap value at the pixel coordinates. The anomaly heatmap value is limited to between zero and one. The distribution of the anomaly heatmap values ​​at each pixel coordinate in spatial location constitutes the pixel-level anomaly heatmap, and the pixel-level anomaly heatmap is consistent with the standardized detection region image in the pixel coordinate dimension.

[0141] In this embodiment, threshold segmentation is performed on the pixel-level anomaly heatmap to obtain an anomaly region map, and connected component analysis is performed on the anomaly region map to obtain a set of defect candidate regions, specifically including:

[0142] A threshold segmentation process is performed on the pixel-level anomaly heatmap. Specifically, an anomaly determination threshold is set, which satisfies that zero is less than or equal to the anomaly determination threshold and less than or equal to one. At the same pixel coordinates, the anomaly heatmap value at that pixel coordinate is compared with the anomaly determination threshold. When the anomaly heatmap value is greater than or equal to the anomaly determination threshold, the pixel coordinate is assigned a value of one; otherwise, it is assigned a value of zero, thus obtaining an anomaly region map. The anomaly region map is a binary image and is consistent with the pixel-level anomaly heatmap in the pixel coordinate dimension.

[0143] Connectivity analysis is performed on the abnormal region map. The connectivity of pixels with a value of one in the abnormal region map is determined by the connectivity neighborhood rule. The connectivity neighborhood rule can be either the four-neighbor rule or the eight-neighbor rule. Adjacent pixels that satisfy the connectivity neighborhood rule and have a value of one are merged into regions and assigned the same connectivity identifier, thereby obtaining multiple connected regions.

[0144] For each connected component, the region attribute is calculated. Specifically, for each connected component, the corresponding connected component region is identified, and the number of pixels with a value of one in the connected component region is counted as the pixel count. The pixel count is distinguished by the connected component index and recorded as the pixel count of the corresponding connected component.

[0145] Within the connected region, traverse the pixel coordinates of all pixels with a value of 1, determine the minimum, maximum, minimum, and maximum values ​​of the horizontal and vertical coordinates of the pixels, and use the top-left pixel coordinates formed by the minimum horizontal and vertical coordinates and the bottom-right pixel coordinates formed by the maximum horizontal and vertical coordinates as the bounding rectangle coordinates of the minimum bounding rectangle covering the connected region. This yields the number of pixels and bounding rectangle coordinates for each connected region, forming a set of connected region attributes.

[0146] Defect candidate regions are obtained by filtering connected components based on the set of connected component attributes. Specifically, a minimum pixel count threshold is set. When the number of pixels in a connected component is greater than the minimum pixel count threshold, the corresponding region of the connected component is retained as a defect candidate region. Otherwise, the corresponding region of the connected component is removed, thus obtaining a set of defect candidate regions. The set of defect candidate regions maintains a correspondence with the abnormal region map in the pixel coordinate dimension.

[0147] In this embodiment, defect region parameters are obtained based on the defect candidate region set, defect category is determined, defect category information and quality judgment results are obtained, and defect location coordinates and defect category information are generated, specifically including:

[0148] For each defect candidate region in the defect candidate region set, the area parameter is calculated. Specifically, the connected component identifiers corresponding to each defect candidate region are traversed, and the number of pixels with a value of one at all pixel coordinates in the defect candidate region is counted. The number of pixels is used as the area parameter of the defect candidate region. The area parameter is distinguished by the defect candidate region index and is used to represent the number of pixels covered by the corresponding defect candidate region in the abnormal region map. The area parameter maintains a corresponding relationship with the defect candidate region in the pixel coordinate dimension.

[0149] The morphological parameters are calculated based on the coordinates of the bounding rectangle. Specifically, the upper left and lower right pixel coordinates of the corresponding defect candidate region in the bounding rectangle coordinates are read to determine the maximum and minimum horizontal coordinates, as well as the maximum and minimum vertical coordinates of the bounding rectangle coordinates.

[0150] The difference between the maximum and minimum horizontal coordinates plus one is used as the width parameter, the difference between the maximum and minimum vertical coordinates plus one is used as the height parameter, and the ratio of the width parameter to the height parameter is used as the aspect ratio parameter. The shape parameters include the width parameter, height parameter, and aspect ratio parameter, and the shape parameters are distinguished by the defect candidate region index and maintain a corresponding relationship with the corresponding defect candidate region.

[0151] The anomaly intensity parameter is calculated based on the pixel-level anomaly heat map. The anomaly intensity parameter is the average of the anomaly heat values ​​at all pixel coordinates within the defect candidate region. The average value is calculated by summing the anomaly heat values ​​at each pixel coordinate within the defect candidate region and then dividing by the number of pixels in the defect candidate region.

[0152] The area parameters, shape parameters, and abnormal intensity parameters are combined to form the defect area parameters. The defect category is determined according to the judgment rules. Specifically, for each defect candidate area, the corresponding area parameters, width parameters, height parameters, aspect ratio parameters, and abnormal intensity parameters are read, and the area parameters, width parameters, height parameters, aspect ratio parameters, and abnormal intensity parameters are combined to form the defect area parameters.

[0153] The judgment rules include judgment conditions for at least three types of defects. The judgment conditions include area range threshold, aspect ratio threshold, and abnormal intensity threshold. When the defect area parameter satisfies the condition that the area parameter is less than the first area threshold and the abnormal intensity parameter is greater than or equal to the first abnormal intensity threshold, the defect category information is judged as a point defect.

[0154] When the defect region parameters satisfy the following conditions: the area parameter is greater than or equal to the first area threshold, the aspect ratio parameter is greater than or equal to the first aspect ratio threshold, and the abnormal intensity parameter is greater than or equal to the second abnormal intensity threshold, the defect category information is determined to be a linear defect.

[0155] When the defect region parameters satisfy the following conditions: the area parameter is greater than or equal to the second area threshold, the aspect ratio parameter is less than the second aspect ratio threshold, and the abnormal intensity parameter is greater than or equal to the third abnormal intensity threshold, the defect category information is determined to be a planar defect.

[0156] The first area threshold, the second area threshold, the first aspect ratio threshold, the second aspect ratio threshold, the first abnormal intensity threshold, the second abnormal intensity threshold, and the third abnormal intensity threshold are preset threshold parameters, and the defect category information of the corresponding defect candidate region index is output.

[0157] The quality of the defect area parameters is judged based on the quality judgment threshold set to obtain the quality judgment result. Specifically, for each defect candidate area, the area parameter, aspect ratio parameter and abnormal intensity parameter corresponding to the defect candidate area are read, and the quality judgment threshold set is set. The quality judgment threshold set includes the minimum area threshold, the maximum aspect ratio threshold and the minimum abnormal intensity threshold.

[0158] Under the same defect candidate region index, the area parameter is compared with the minimum area threshold, the aspect ratio parameter is compared with the maximum aspect ratio threshold, and the anomaly intensity parameter is compared with the minimum anomaly intensity threshold.

[0159] When the area parameter is greater than or equal to the minimum area threshold and the abnormal intensity parameter is greater than or equal to the minimum abnormal intensity threshold, or when the aspect ratio parameter is greater than the maximum aspect ratio threshold, the quality judgment result corresponding to the defect candidate area is set as unqualified.

[0160] Otherwise, the quality judgment result corresponding to the defect candidate region is set as qualified, and the quality judgment result is identified by the defect candidate region index;

[0161] When the quality judgment result is unqualified, the defect location coordinates are generated based on the coordinates of the bounding rectangle, and the defect location coordinates and defect category information are output. The defect location coordinates are the upper left and lower right pixel coordinates of the bounding rectangle coordinates.

[0162] In this embodiment, the defect location coordinates, defect category information, and quality judgment results are output to the production line control system, and an inspection record is generated, specifically including:

[0163] For each defect candidate area, when the quality judgment result is unqualified, the corresponding defect location coordinates, defect category information and quality judgment result are read, and the upper left and lower right pixel coordinates in the defect location coordinates are converted into physical coordinates in the production line coordinate system. The physical coordinates are calculated by multiplying the pixel coordinates by a preset pixel size coefficient, so as to obtain the physical location coordinates of the defect in the production line coordinate system.

[0164] The physical location coordinates of the defect, the defect category information, and the quality judgment result are encapsulated into a detection data message according to the data format. The detection data message includes a defect index field, a defect physical location field, a defect category field, and a quality judgment field.

[0165] The detection data message is sent to the production line control system through the communication interface, which can be either an industrial Ethernet interface or a serial communication interface. During the transmission process, the detection data message is verified and encoded to generate a verification field, thereby completing the output of defect location coordinates, defect category information and quality judgment results to the production line control system.

[0166] Inspection records are generated based on defect location coordinates, defect category information, and quality judgment results. The inspection records include inspection timestamps, product numbers corresponding to standardized inspection area images, defect candidate area indexes, and quality judgment results. The inspection records are then stored in a database or file system, thus completing the generation and saving of inspection records.

[0167] Example 1: To verify the feasibility of this invention in practice, it was applied to a stamping production line of an automobile manufacturing company to perform online defect detection on mass-produced body panels. This production line uses a continuous stamping process, and the surface of stamped parts is prone to defects such as scratches, indentations, cracks, and small pits. Traditional manual inspection methods are easily interfered with by strong light and metallic reflection, resulting in a high rate of missed detections, poor consistency, and limited inspection cycle time. Existing single-image inspection methods are prone to misjudging bright areas as abnormalities when facing reflective areas, or failing to accurately identify defects in areas of shallow surface morphology variation, making it difficult to meet the requirements of inspection accuracy and stability under mass production conditions.

[0168] In practical applications, industrial cameras are deployed at the back end of the stamping station to capture images of the surface of automotive stamped parts. Standardized inspection area images are obtained through image preprocessing, and structural partition masks are generated to distinguish edge regions from planar regions. Subsequently, a geometric feature map is constructed based on the standardized inspection area image and enhanced. The standardized inspection area image and the enhanced geometric feature map are then input into a dual-stream DRAE model for feature extraction and reconstruction. A composite anomaly feature map is constructed by calculating the appearance residual map and the geometric residual map, and then a pixel-level anomaly heatmap is generated by the discriminant branch. After threshold segmentation and connected component analysis of the anomaly heatmap, candidate defect regions are obtained. Based on area parameters, morphological parameters, and anomaly intensity parameters, defect category and quality are determined. Finally, the defect location coordinates and determination results are output to the production line control system for automatic sorting and recording.

[0169] In continuous operation testing, a total of 12,000 stamped parts were inspected, including 2,100 manually marked defect samples and 9,900 defect-free samples. After using the method of this invention, the overall inspection accuracy reached 98.7%, the defect detection rate was 97.9%, the missed detection rate was 2.1%, and the false detection rate was 1.4%. In specialized testing in areas with strong reflective interference, the false detection rate of the traditional single-flow appearance model was 6.8%, while the false detection rate of the method of this invention was reduced to 1.9%. The average inspection time per part was 0.42 seconds, meeting the online inspection requirements of a production cycle time of less than 0.5 seconds. The average defect area positioning error was 1.6 pixels, which translates to an actual size error of approximately 0.18 mm, meeting the quality judgment standard. After 8 hours of continuous operation, the fluctuation range of the inspection results was controlled within 0.3%, and the inspection stability met the requirements of industrial applications.

[0170] Table 1. Statistical comparison of detection performance between the method of this invention and traditional methods

[0171] Indicator Items Traditional single-flow appearance model Traditional reconstruction model Method of the present invention Total number of samples tested 12000 12000 12000 Number of defective samples 2100 2100 2100 Detection rate 93.2% 95.6% 97.9% False negative rate 6.8% 4.4% 2.1% False positive rate 6.8% 3.9% 1.4% Overall accuracy 94.5% 96.2% 98.7% Average detection time 0.65 seconds 0.58 seconds 0.42 seconds Average positioning error 3.4 pixels 2.2 pixels 1.6 pixels False detection rate of reflective areas 6.8% 4.7% 1.9% Continuous operation with stable fluctuations 1.2% 0.8% 0.3%

[0172] As can be seen from the table above, the method of this invention significantly improves upon the traditional single-flow appearance model and the traditional reconstruction model in several key performance indicators for surface defect detection of automotive stamping parts. Firstly, in terms of overall detection accuracy, the method of this invention achieves 98.7%, which is 4.2 percentage points higher than the 94.5% of the traditional single-flow appearance model and 2.5 percentage points higher than the 96.2% of the traditional reconstruction model, indicating that the detection results are more stable and reliable after integrating appearance and geometric features. Regarding the defect detection rate, this invention achieves 97.9%, with a false negative rate reduced to 2.1%, a significant decrease compared to the 6.8% false negative rate of the traditional single-flow appearance model. This demonstrates that the discrimination mechanism based on the consistency of appearance residuals and geometric residuals can effectively reduce defect omissions.

[0173] Regarding the false detection rate, the method of this invention has a false detection rate of only 1.4%, significantly lower than the 6.8% of the traditional single-flow appearance model and the 3.9% of the traditional reconstruction model. Especially in the specific test of reflective areas, the false detection rate is controlled at 1.9%, a significant advantage over the 6.8% of the traditional method, reflecting the good effect of the geometrically gated cross-flow coupling structure in suppressing illumination interference. In terms of positioning accuracy, the average positioning error of this invention is 1.6 pixels, better than the 3.4 pixels and 2.2 pixels of the traditional methods, indicating that the composite anomaly feature map and pixel-level anomaly discrimination strategy improve the precision of defect boundary positioning.

[0174] In terms of inspection efficiency, the average inspection time per piece of this invention is 0.42 seconds, meeting the requirements of online production cycle time. This is significantly higher than the 0.65 seconds of the traditional single-flow appearance model and the 0.58 seconds of the traditional reconstruction model. Furthermore, in continuous operation stability tests, the fluctuation range of the inspection results is controlled within 0.3%, which is better than the 1.2% and 0.8% of the traditional methods, indicating that the method of this invention has good stability under long-term operation. In summary, the above indicators show that this invention achieves significant improvements in inspection accuracy, anti-interference ability, positioning accuracy, and operational stability, verifying its effectiveness in online inspection scenarios for industrial stamped parts.

[0175] The above are merely preferred embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A machine learning-based method for detecting defects in automotive stamping parts, characterized in that, Includes the following steps: The surface images of automotive stamping parts are acquired by an industrial camera, preprocessed to obtain standardized inspection area images, and structural partition masks are generated based on the structural contour of the stamping parts. Geometric feature maps are constructed based on standardized detection region images. These geometric feature maps are then processed to obtain enhanced geometric feature maps, which are then aligned with structural partitioning masks. The standardized detection region image and the enhanced geometric feature map are input into the dual-stream DRAE model to obtain the reconstructed appearance image and the reconstructed geometric feature map. The appearance residual map is calculated based on the standardized detection region image and the reconstructed appearance image. The geometric residual map is calculated based on the enhanced geometric feature map and the reconstructed geometric feature map, and a composite anomaly feature map is obtained. Input the composite anomaly feature map into the discrimination branch, perform pixel-level anomaly discrimination on the composite anomaly feature map, and obtain a pixel-level anomaly heatmap; Threshold segmentation is performed on the pixel-level anomaly heatmap to obtain an anomaly region map, and connected component analysis is performed on the anomaly region map to obtain a set of defect candidate regions. Based on the defect candidate region set, defect region parameters are obtained, defect category is determined, defect category information and quality judgment results are obtained, and defect location coordinates and defect category information are generated. The system outputs the defect location coordinates, defect category information, and quality judgment results to the production line control system and generates inspection records.

2. The method for detecting defects in automotive stamping parts based on machine learning according to claim 1, characterized in that, The preprocessing includes distortion correction, brightness normalization, and pose alignment.

3. The method for detecting defects in automotive stamping parts based on machine learning according to claim 1, characterized in that, The process of constructing a geometric feature map based on a standardized detection region image, processing the geometric feature map to obtain an enhanced geometric feature map, and aligning the enhanced geometric feature map with the structural partition mask specifically includes: Geometric feature maps are constructed based on standardized detection region images. The geometric feature maps are then smoothed and filtered. Finally, a pre-defined convolution kernel is used to perform convolution operations on the geometric feature maps to obtain smoothed geometric feature maps. Gradient enhancement processing is applied to the smoothed geometric feature map to form a gradient-enhanced geometric feature map. Local contrast enhancement processing is performed on the gradient-enhanced geometric feature map to form an enhanced geometric feature map. Spatially align the enhanced geometric feature map with the structural partition mask to ensure a one-to-one correspondence between the enhanced geometric feature map and the structural partition mask in pixel coordinates.

4. The method for detecting defects in automotive stamping parts based on machine learning according to claim 1, characterized in that, The step of inputting the standardized detection region image and enhanced geometric feature map into the dual-stream DRAE model to obtain the reconstructed appearance image and reconstructed geometric feature map specifically includes: The standardized detection region image is input into the appearance branch of the dual-stream DRAE model, and the first set of convolution parameters is used to perform multi-layer convolution operations on the standardized detection region image to obtain the appearance feature map. The enhanced geometric feature map is input into the geometric branch of the dual-stream DRAE model, and multi-layer convolution operation is performed on the enhanced geometric feature map using the second convolution parameter set to obtain the geometric feature map. The geometric feature map is input into the geometric gated cross-current coupling module to generate a gated weight map. The appearance feature map is then fused element by element based on the gated weight map to obtain the fused feature map. The fused feature map is input into the reconstruction branch of the dual-stream DRAE model. The fused feature map is then processed by upsampling and convolution operations through the decoding network to obtain the reconstructed appearance image and the reconstructed geometric feature map.

5. The method for detecting defects in automotive stamping parts based on machine learning according to claim 4, characterized in that, The process of inputting the geometric feature map into the geometric gated cross-current coupling module to generate a gated weight map, and then performing element-wise weighted fusion of the appearance feature map based on the gated weight map to obtain the fused feature map specifically includes: The geometric feature map is input into the geometric gated cross-current coupling module, and a structural modulation geometric feature map is constructed based on the geometric feature map and the structural partition mask. Multi-scale transformation is performed on the structure modulation geometric feature map to obtain a multi-scale structure modulation geometric feature map; Based on the multi-scale structure modulation geometric feature map, the geometric response intensity value is calculated to obtain the geometric response intensity map; Based on the structural partition mask and geometric response intensity map, a region normalized response map is generated in each structural region. The region normalized response map is mapped to an upsampled gated weight map, and the upsampled gated weight maps at each scale are fused across scales to obtain the gated weight map. The appearance feature map is fused element by element based on the gating weight map to obtain the fused feature map.

6. The method for detecting defects in automotive stamping parts based on machine learning according to claim 1, characterized in that, The process of calculating the appearance residual map based on the standardized detection region image and the reconstructed appearance image, calculating the geometric residual map based on the enhanced geometric feature map and the reconstructed geometric feature map, and obtaining the composite anomaly feature map specifically includes: The appearance residual value is calculated based on the standardized detection area image and the reconstructed appearance image to obtain the appearance residual map; Geometric residual values ​​are calculated based on the enhanced geometric feature map and the reconstructed geometric feature map to obtain the geometric residual map; The appearance residual map and the geometric residual map are normalized to obtain the normalized appearance residual map and the normalized geometric residual map. The normalized appearance residual map, normalized geometric residual map, fused feature map, and structural partition mask are concatenated to obtain a composite anomaly feature map.

7. The method for detecting defects in automotive stamping parts based on machine learning according to claim 1, characterized in that, The step of inputting the composite anomaly feature map into the discrimination branch and performing pixel-level anomaly discrimination on the composite anomaly feature map to obtain a pixel-level anomaly heatmap specifically includes: The composite anomaly feature map is input into the discriminant branch of the dual-stream DRAE model. The discriminant branch performs pixel-level feature mapping on the composite anomaly feature map to obtain the pixel-level discriminant feature map. The basic anomaly score is calculated based on the pixel-level discriminative feature map to obtain the pixel-level basic anomaly score map. Normalized appearance residual map, normalized geometric residual map and structural partition mask are extracted from the composite anomaly feature map, and pixel-level residual consistency score map is calculated based on the normalized appearance residual map and normalized geometric residual map. A pixel-level joint anomaly score map is generated based on the pixel-level basic anomaly score map and the pixel-level residual consistency score map. Activation function mapping is applied to the pixel-level joint anomaly score map to obtain a pixel-level anomaly heatmap.

8. The method for detecting defects in automotive stamping parts based on machine learning according to claim 1, characterized in that, The process of threshold segmentation of the pixel-level anomaly heatmap to obtain an anomaly region map, and then performing connected component analysis on the anomaly region map to obtain a set of defect candidate regions specifically includes: Threshold segmentation is performed on pixel-level anomaly heatmaps to obtain anomaly region maps; Connectivity analysis is performed on the abnormal region map. The connectivity of pixels with a value of one in the abnormal region map is determined by the connected neighborhood rule, resulting in multiple connected regions. Calculate the region attributes for each connected component to obtain the number of pixels and the coordinates of the bounding rectangle corresponding to each connected component, and form a set of connected component attributes. Based on the set of connected component attributes, defect candidate regions are obtained by filtering connected components, resulting in a set of defect candidate regions.

9. The method for detecting defects in automotive stamping parts based on machine learning according to claim 1, characterized in that, The process of obtaining defect region parameters based on the defect candidate region set, determining the defect category, obtaining defect category information and quality judgment results, and generating defect location coordinates and defect category information specifically includes: For each defect candidate region in the defect candidate region set, the area parameter is calculated, and the shape parameter is calculated based on the coordinates of the bounding rectangle. The shape parameter includes the width parameter, height parameter, and aspect ratio parameter. The anomaly intensity parameter is calculated based on the pixel-level anomaly heatmap. The area parameters, shape parameters, and abnormal intensity parameters are combined to form the defect area parameters. The defect category is determined according to the judgment rules to obtain the defect category information. The quality of the defect area parameters is determined based on the set of quality judgment thresholds, and the quality judgment result is obtained. When the quality judgment result is unqualified, the defect location coordinates are generated based on the coordinates of the circumscribed rectangle, and the defect location coordinates and defect category information are output.

10. The method for detecting defects in automotive stamping parts based on machine learning according to claim 1, characterized in that, The process of outputting the defect location coordinates, defect category information, and quality judgment results to the production line control system and generating inspection records specifically includes: For each defect candidate region, when the quality judgment result is unqualified, the corresponding defect location coordinates, defect category information and quality judgment result are read to construct the physical location coordinates of the defect; The physical location coordinates of the defect, the defect category information, and the quality judgment results are encapsulated into a detection data message according to the data format. The detection data message is sent to the production line control system through the communication interface, and the detection data message is verified and encoded during the transmission process to generate a verification field; Inspection records are generated based on the defect location coordinates, defect category information, and quality judgment results.