Industrial surface defect detection method and system

By improving the YOLO detection network and combining robust feature downsampling, lightweight attention, and morphological extremum penalty terms, the problems of preserving small defect features and suppressing background noise in industrial surface defect detection are solved, and high-precision localization and identification of extreme morphological defects are achieved.

CN121788531AActive Publication Date: 2026-04-03HANGZHOU JUXIU TECH CO LTD +1
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-03-04
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively preserve minute defect features and suppress background noise in industrial surface defect detection, and their positioning accuracy for extreme-shaped defects is insufficient, especially in complex lighting and background texture scenarios where robustness is lacking.

Method used

An improved YOLO detection network is constructed, which introduces a robust feature downsampling module, a lightweight attention module, and a morphological extremum penalty term. Through dynamic weight allocation and collaborative attention to enhance feature extraction, combined with an adaptive data augmentation strategy, high-precision detection of minute defects is achieved.

Benefits of technology

It significantly improves the ability to extract features from minute defects, enhances the sensitivity to detect hidden defects, and improves the detection rate and positioning accuracy of defects with extreme aspect ratios, ensuring the stability of quality monitoring under complex working conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121788531A_ABST
    Figure CN121788531A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence and industrial automatic detection, in particular to an industrial surface defect detection method and system.The method comprises the steps that collected industrial surface images are input into a backbone network, and a multi-scale feature map is generated; the lightweight attention module receives the multi-scale feature map; generating a collaborative attention weight representing the high-frequency mutation region, and fusing the collaborative attention weight with the original feature map to obtain an enhanced feature; calculating a loss value and updating network parameters by using a loss function containing a morphological extreme value penalty term based on a prediction bounding box output by the detection head; the morphological extreme value penalty term is configured to weight the regression error according to the width-to-height proportion characteristic of the bounding box; reasoning a to-be-detected image by using the trained model, outputting a defect category and a physical coordinate, and outputting a surface qualified state mark; according to the method, the problem of different detection standards caused by physiological fatigue is solved, and the quality monitoring stability of a large-scale and high-speed chemical industry production line under complex working conditions is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of artificial intelligence and industrial automation inspection technology, specifically to industrial surface defect detection methods and systems. Background Technology

[0002] As industrial manufacturing continues to move towards precision and automation, surface quality monitoring of various industrial products such as steel and PCB boards plays a crucial role in the production process. The complexity of this inspection task increases significantly with the increase in production line speed and product precision, especially in the real-time monitoring of minute defects and extreme morphological defects.

[0003] Currently, industrial surface defect detection mainly relies on traditional manual visual inspection or basic machine vision algorithms. Technicians observe surface quality with the naked eye under specific light sources or use traditional digital image processing techniques for edge detection and template matching. Manual monitoring methods are limited by the physiological fatigue and subjective standards of inspectors, making it difficult to maintain stability on large-scale, high-speed production lines. Traditional machine vision algorithms often exhibit insufficient robustness, high false negative and false positive rates when facing industrial scenarios with drastic lighting changes, complex background textures, and diverse defect morphologies. Although deep learning architectures such as the YOLO series have been introduced into the field of industrial inspection in recent years, existing general-purpose models still have limitations in handling specific industrial problems, such as feature loss: traditional networks use stride convolution or pooling during downsampling. While reducing computational load through optimization, this often leads to irreversible loss of feature space information, making it easy for background noise to drown out the features of small defects and cause missed detection of tiny targets. The attention mechanism also has limitations: general attention modules often struggle to accurately capture the high-frequency abrupt changes unique to industrial defects without significantly increasing computational overhead, limiting the model's ability to perceive hidden defects. Furthermore, the geometric shape fitting is suboptimal: existing loss functions primarily focus on the overlap of bounding boxes, lacking specific morphological constraints for defects with extreme aspect ratios, such as thin scratches commonly found in industrial scenarios, resulting in insufficient localization accuracy. Therefore, how to achieve high-precision, fully automated localization and recognition of extreme-shaped defects while preserving the features of small defects and suppressing background noise has become a pressing technical challenge in the field of industrial surface inspection. Summary of the Invention

[0004] The purpose of this invention is to provide an industrial surface defect detection method and system that effectively suppresses background noise and enhances the ability to detect hidden defects while preserving the characteristics of minute defects. Furthermore, it can significantly improve the detection rate and location accuracy of slender defects with extreme aspect ratios through a morphological extreme value penalty term. Specifically, the technical solution of this invention is as follows:

[0005] An industrial surface defect detection method, executed by a computing device equipped with an image processor, includes the following steps:

[0006] An improved detection network based on the YOLO architecture is constructed, which includes a backbone network, a feature fusion layer, and a detection head;

[0007] The collected industrial surface images are input into the backbone network, and features are extracted using the robust feature downsampling module. The robust feature downsampling module includes parallel full-frequency flux preservation branches, high-frequency texture response branches, and low-frequency semantic compression branches. The weight distribution of the above three branches is dynamically adjusted by the gating unit according to the calculated local information entropy value of the feature map to generate multi-scale feature maps.

[0008] The multi-scale feature map is received using a lightweight attention module; by calculating the residual mapping between the original feature map and the linearly transformed feature map generated by linearly transforming the original feature map, a co-attention weight representing the high-frequency abrupt region is generated, and the co-attention weight is fused with the original feature map to obtain the enhanced feature;

[0009] Based on the predicted bounding box output by the detection head, the loss value is calculated using a loss function that includes a morphological extremum penalty term, and the network parameters are updated; the morphological extremum penalty term is configured to weight the regression error according to the ratio of the width to the height of the bounding box.

[0010] The trained model is used to infer the image to be detected: if the confidence level output by the detection head is higher than a preset threshold, the defect category and physical coordinates are output; if the confidence level is not higher than the preset threshold, a surface qualified status mark is output.

[0011] Optionally, the specific processing logic of the three parallel branches in the robust feature downsampling module is as follows:

[0012] The full-frequency flux preservation branch performs a slicing operation, which reassembles the pixels of the input feature map in the spatial dimension into the channel dimension according to a preset step size, so as to preserve the spatial position information of the original pixels.

[0013] The high-frequency texture response branch performs max pooling to extract salient texture features from the input feature map;

[0014] The low-frequency semantic compression branch performs a convolution operation with stride to extract semantic features from the input feature map and reduce the resolution of the feature map.

[0015] Optionally, the step of dynamically adjusting the weight allocation through the gating unit includes:

[0016] A preset high-frequency entropy threshold and a low-frequency entropy threshold are defined, wherein the high-frequency entropy threshold is greater than the low-frequency entropy threshold;

[0017] Calculate the local entropy value of the input feature map within the sliding window;

[0018] When the local information entropy value is greater than or equal to the high-frequency entropy threshold, the current region is determined to be a texture high-frequency region, and a first control instruction is generated to increase the weight ratio of the full-frequency flux preservation branch.

[0019] When the local information entropy value is less than or equal to the low-frequency entropy threshold, the current region is determined to be a flat background region, and a second control instruction is generated to increase the weight ratio of the low-frequency semantic compression branch.

[0020] When the local information entropy value is greater than the low-frequency entropy threshold and less than the high-frequency entropy threshold, a third control instruction is generated to perform a balanced weight allocation on the full-frequency flux preservation branch and the low-frequency semantic compression branch.

[0021] Optionally, the steps for generating collaborative attention weights using a lightweight attention module specifically include:

[0022] The original feature map is generated by using convolution operation, and the original feature map is then linearly transformed to generate the corresponding linearly transformed feature map;

[0023] Calculate the absolute difference between the original feature map and the linearly transformed feature map at the corresponding pixel positions, and define the absolute difference as the residual mapping;

[0024] The energy function of the parameterless attention mechanism is modulated based on the residual mapping: the hyperbolic tangent value of the residual mapping is calculated, and the hyperbolic tangent value is incremented by 1 and used as the gain coefficient. This value is then multiplied by the original value of the energy function calculated based on pixel statistical characteristics to obtain the residual guided energy function.

[0025] The final attention weights are calculated using the residual-guided energy function.

[0026] Optionally, the calculation logic for the morphological extremum penalty term is as follows:

[0027] Obtain the width and height values ​​of the predicted bounding box and the ground truth bounding box;

[0028] Calculate the ratio of the width value to the height value and the ratio of the height value to the width value respectively, and select the larger value as the shape factor;

[0029] Calculate the natural logarithm of the morphological factor, and calculate the preset power of the difference between the value 1 and the intersection-union ratio of the predicted bounding box and the true bounding box.

[0030] The product of the natural logarithm and the preset power is defined as the morphological extremum penalty term and is added to the cross-union ratio loss function.

[0031] Optionally, before inputting the acquired industrial surface image into the backbone network, the method further includes performing data augmentation processing on the industrial surface image, the data augmentation processing including:

[0032] Size normalization is performed on the acquired industrial surface images;

[0033] Perform a random cropping operation;

[0034] If the cropped image size is smaller than the preset input size, then padding is performed; if the cropped image size is larger than the preset input size, then scaling is performed.

[0035] An industrial surface defect detection system, comprising:

[0036] Image acquisition equipment is configured to acquire surface image signals of industrial products;

[0037] Memory, configured to store instructions executed by the computer;

[0038] A processor, connected to the image acquisition device and the memory, is configured to execute the computer execution instructions to implement the industrial surface defect detection method;

[0039] The alarm execution unit is configured to receive the defect category and physical coordinates output by the processor; when the defect category data is received, it triggers an audible and visual alarm signal; when the surface pass status mark is received, it remains silent.

[0040] Compared with the prior art, the present invention has the following beneficial effects:

[0041] 1. This invention effectively solves the problem of small target feature loss caused by traditional downsampling by introducing a robust feature downsampling module. This module uses parallel branches to capture full-frequency, high-frequency, and low-frequency features respectively, and combines local information entropy gating units to achieve dynamic weight allocation. It forcibly retains the signal flux of the original pixels in suspected defect areas, and uses convolution for noise reduction and compression in flat background areas. This on-demand downsampling strategy achieves simultaneous background suppression and defect fidelity preservation, greatly improving the feature extraction capability for small defects.

[0042] 2. This invention utilizes a lightweight attention module to cleverly locate high-frequency abrupt change regions in the feature space by calculating the residual mapping between the original features and the linearly transformed features. Since industrial defects typically correspond to such high-frequency features, this mechanism can transform redundant differences in the feature generation process into attention gains, enabling the model to automatically focus on defect details that are difficult to fit by linear transformations. This significantly enhances the system's sensitivity to hidden defects in complex backgrounds without significantly increasing computational overhead.

[0043] 3. This invention introduces a morphological extremum penalty term into the loss function; this penalty term nonlinearly weights the regression error based on the width-to-height ratio of the bounding box, and the more slender the detected object, the greater the penalty weight; through this targeted geometric morphological constraint, the network regression box is forced to accurately fit the defective topological skeleton, which significantly solves the technical pain point of insufficient localization accuracy of traditional loss functions for irregular targets;

[0044] 4. This invention constructs a complete detection closed loop from image acquisition and adaptive data augmentation to model inference and audible and visual alarms. By normalizing, randomly cropping, and adaptively filling images, it simulates the complex shooting environment of industrial sites, enhancing the generalization ability and robustness of the model. With the help of a high-performance processor and alarm execution unit, the system can replace traditional manual visual inspection, eliminate the problem of inconsistent detection standards caused by physiological fatigue, and ensure the stability of quality monitoring in large-scale, high-speed industrial production lines under complex working conditions. Attached Figure Description

[0045] The present invention will be further explained below with reference to the accompanying drawings and embodiments:

[0046] Figure 1 This is a flowchart of the method of the present invention;

[0047] Figure 2 This is a structural diagram of the system of the present invention. Detailed Implementation

[0048] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments.

[0049] Example 1:

[0050] Please see Figure 1 Example 1:

[0051] An industrial surface defect detection method, executed by a computing device equipped with an image processor, includes the following steps:

[0052] An improved detection network based on the YOLO architecture is constructed, which includes a backbone network, a feature fusion layer, and a detection head;

[0053] The collected industrial surface images are input into the backbone network, and features are extracted using the robust feature downsampling module. The robust feature downsampling module includes parallel full-frequency flux preservation branches, high-frequency texture response branches, and low-frequency semantic compression branches. The weight distribution of the above three branches is dynamically adjusted by the gating unit according to the calculated local information entropy value of the feature map to generate multi-scale feature maps.

[0054] A lightweight attention module is used to receive multi-scale feature maps; by calculating the residual mapping between the original feature map and the linearly transformed feature map generated by linearly transforming the original feature map, a co-attention weight representing high-frequency abrupt regions is generated, and the co-attention weight is fused with the original feature map to obtain enhanced features.

[0055] Based on the predicted bounding boxes output by the detection head, the loss value is calculated using a loss function that includes a morphological extremum penalty term, and the network parameters are updated. The morphological extremum penalty term is configured to weight the regression error according to the ratio of the width to the height of the bounding box.

[0056] The trained model is used to infer the image to be detected: if the confidence level output by the detection head is higher than the preset threshold, the defect category and physical coordinates are output; if the confidence level is not higher than the preset threshold, the surface qualified status mark is output.

[0057] This embodiment provides an industrial surface defect detection method, which is executed by a computing device equipped with a high-performance image processor, such as a GPU. The core logic of this method is to build and run an improved detection network, commonly referred to as the RGE-YOLO model.

[0058] Execution model building steps:

[0059] The improved detection network constructed in this embodiment is based on the YOLO architecture. Its macroscopic structure includes a backbone network, a feature fusion layer (Neck), and a detection head. The feature fusion layer (Neck) adopts a path aggregation network (PAN) structure, which establishes bidirectional information transmission paths from top to bottom and from bottom to top between multi-scale feature maps to achieve deep fusion of low-level positional information and high-level semantic information. The backbone network is responsible for extracting multi-level feature maps from the input image. The feature fusion layer is used to aggregate features at different scales to take into account both semantic and positional information. The detection head is responsible for the final category prediction and bounding box regression.

[0060] Perform the feature extraction steps:

[0061] The acquired industrial surface images, such as steel and PCB boards, are input into the backbone network. In the critical downsampling stage of the backbone network, this embodiment does not use traditional stride convolution or simple max pooling, but introduces a robust feature downsampling (RFD) module. The purpose of this module is to solve the problem that small target features are submerged by background noise during downsampling.

[0062] In this embodiment, the robust feature downsampling module integrates three parallel processing branches:

[0063] Full-frequency flux preservation branch: used to preserve spatial information;

[0064] High-frequency texture response branch: used to capture edge and defect textures;

[0065] Low-frequency semantic compression branch: used to extract semantics and reduce noise;

[0066] This module introduces an information theory-based gating unit that calculates the local information entropy of the feature map in real time. Based on this entropy value, the gating unit dynamically adjusts the weight distribution of the three branches to generate a multi-scale feature map containing rich detailed information.

[0067] Perform attention enhancement steps:

[0068] The generated feature map is fed into the lightweight attention module GhostSAM. The purpose of this module is to locate defects by utilizing the redundant differences in the feature generation process without significantly increasing the computational load. Specifically, this module calculates the difference between the original feature map and the linearly transformed feature map generated by linear transformation of the original feature map, such as Ghost convolution operation, i.e., the residual map. This residual map physically represents the high-frequency abrupt change region in the feature space, and industrial defects often correspond to such high-frequency abrupt changes. The system uses this residual map to generate collaborative attention weights and fuses them with the original feature map to obtain enhanced features with high response values ​​to the defect region.

[0069] Perform network training and parameter update steps:

[0070] After the detection head outputs the predicted bounding box, the system uses a loss function that includes a morphological extremum penalty term to calculate the loss value. This morphological extremum penalty term is specifically designed for extreme aspect ratio defects commonly found in industrial scenarios, such as thin scratches. It is configured to non-linearly weight the regression error based on the ratio of the width to the height of the bounding box, forcing the network to pay more attention to the shape fit of the box.

[0071] Execution reasoning steps:

[0072] The trained and converged model is used to perform inference on the image to be detected; if the confidence level of the detection head output is higher than a preset threshold, for example... If the confidence level of all predicted boxes is not higher than the preset threshold, the system will output the specific defect category, such as scratches, pits and physical coordinates; if the confidence level of all predicted boxes is not higher than the preset threshold, the surface will be determined to be defect-free and the surface will be output as qualified.

[0073] By dynamically adjusting the weights of the robust feature downsampling module, background noise is suppressed while retaining the features of minor defects. By using an attention mechanism based on residual mapping, the differences in the feature generation process are transformed into attention, which significantly enhances the ability to perceive hidden defects. By using a morphological extremum penalty term, the detection rate and positioning accuracy of slender defects are greatly improved.

[0074] Example 2:

[0075] The specific processing logic of the three parallel branches in the robust feature downsampling module is as follows:

[0076] The full-frequency flux preservation branch performs a slicing operation, reorganizing the pixels of the input feature map in the spatial dimension to the channel dimension according to a preset step size, so as to preserve the spatial location information of the original pixels;

[0077] The high-frequency texture response branch performs max pooling to extract salient texture features from the input feature map;

[0078] The low-frequency semantic compression branch performs a strided convolution operation to extract semantic features from the input feature map and reduce the resolution of the feature map.

[0079] According to the industrial surface defect detection method of Example 1, the step of dynamically adjusting the weight allocation through the gating unit includes:

[0080] A high-frequency entropy threshold and a low-frequency entropy threshold are preset, with the high-frequency entropy threshold being greater than the low-frequency entropy threshold;

[0081] Calculate the local entropy value of the input feature map within the sliding window;

[0082] When the local information entropy value is greater than or equal to the high-frequency entropy threshold, the current region is determined to be a high-frequency texture region, and the first control instruction is generated to increase the weight ratio of the full-frequency flux maintenance branch.

[0083] When the local information entropy value is less than or equal to the low-frequency entropy threshold, the current region is determined to be a flat background region, and a second control instruction is generated to increase the weight ratio of the low-frequency semantic compression branch.

[0084] When the local information entropy value is greater than the low-frequency entropy threshold and less than the high-frequency entropy threshold, a third control instruction is generated to balance the weight allocation between the full-frequency flux preservation branch and the low-frequency semantic compression branch.

[0085] This embodiment provides a detailed description of the specific structure and dynamic weight adjustment logic of the robust feature downsampling module RFD described above.

[0086] The specific processing logic for the three parallel branches is as follows:

[0087] To achieve decoupling of frequency domain features during downsampling, this embodiment designs the following three functionally defined branches:

[0088] Full-frequency flux preservation branch: This branch performs a slicing operation; specifically, it slices the input feature map pixels in the spatial dimension according to a preset step size, for example... Interval sampling is performed, and the sampled pixels are recombined into the channel dimension; this is a lossless downsampling method that fully preserves the spatial location information of the original pixels, avoids information ambiguity caused by convolution operations, and ensures the signal throughput of minor defects.

[0089] High-frequency texture response branch: This branch performs max pooling operation; max pooling is extremely sensitive to texture changes and can effectively extract significant texture features from the input feature map, such as the edges of defects and noise, which are the high-frequency components of the main response image.

[0090] Low-frequency semantic compression branch: This branch performs convolution operations with stride, such as Convolution, stride is The system utilizes the receptive field of the convolutional kernel to extract semantic features from the input feature map, while simultaneously smoothing noise and reducing the resolution of the feature map, primarily processing low-frequency components of the image. To enable weighted fusion of the feature maps output from the three branches, the system concatenates a function after each of the above branch operations. Convolutional layers maintain the full-frequency flux while keeping the number of branch channels constant. The number of high-frequency texture response branch channels is and the number of low-frequency semantic compression branch channels is The number of channels in the output feature maps is uniformly adjusted to the preset dimension. This yields three feature maps to be fused, each with the same size and number of channels. ;in, This indicates the number of channels in the original feature map input to the module. This indicates the number of output channels after the branch convolution operation. Indicates the process The target channel dimension after uniform adjustment of convolution;

[0091] Regarding the dynamic weight adjustment logic of the gating unit:

[0092] To achieve on-demand downsampling, this embodiment introduces a flow control mechanism based on local information entropy;

[0093] Define the local information entropy value It characterizes the texture complexity of local regions of an image;

[0094] In the specific calculation, the sliding window size is set to... Pixel; Normalized histogram distribution probability of pixel grayscale values ​​within a statistical window. ,in, ; Calculate the local entropy value of the center pixel of the window using the Shannon entropy formula: ;

[0095] The system presets two key thresholds: the high-frequency entropy threshold. and low-frequency entropy threshold And satisfy The specific steps for obtaining these two thresholds are as follows: collect no fewer than 1000 images of defect-free and defective samples; calculate the local entropy distribution curves for the two types of samples respectively; and select the 95th percentile of the entropy distribution of defect-free samples as the low-frequency entropy threshold. ,For example The 5% quantile of the entropy distribution of defective samples was selected as the high-frequency entropy threshold. ,For example ;

[0096] The dynamic adjustment process is as follows:

[0097] High-frequency texture region determination: when the calculated local information entropy value When the current region texture is extremely complex, it is very likely a defect region or a complex edge region. At this time, the system generates the first control instruction, which significantly increases the weight ratio of the full-frequency flux preservation branch. In the suspected defect region, the original pixel information must be forcibly preserved to prevent the convolution operation from blurring the key defect details.

[0098] Flat background area determination: when the local information entropy value When the current region has a simple texture and is a flat background, such as a normal steel plate surface, the system generates a second control instruction to increase the weight ratio of the low-frequency semantic compression branch. For the background region, convolution should be used for noise reduction and compression to reduce redundant calculations.

[0099] Transition zone determination: when When this occurs, it indicates that the current region is in a transitional state; the system generates a third control command to distribute the weights evenly between the full-frequency flux preservation branch and the low-frequency semantic compression branch, so as to balance information preservation and feature abstraction.

[0100] The specific dynamic weight fusion is achieved through a weighted summation formula: ;

[0101] Where the weight vector The generation logic is as follows:

[0102] Responding to the first control command :set up Force the retention of throughput information;

[0103] Responding to the second control command :set up It mainly utilizes convolution for noise reduction;

[0104] Responding to third control commands :set up Perform balanced fusion;

[0105] By introducing information entropy as a router, the network no longer adopts a one-size-fits-all downsampling strategy for all image regions. Instead, it achieves simultaneous background noise reduction and defect fidelity preservation, solving the problem of small targets disappearing in deep networks.

[0106] Example 3:

[0107] The specific steps for generating collaborative attention weights using a lightweight attention module include:

[0108] The original feature map is generated by using convolution operations, and then a linear transformation is performed on the original feature map to generate the corresponding linearly transformed feature map.

[0109] Calculate the absolute difference between the original feature map and the linearly transformed feature map at the corresponding pixel positions, and define the absolute difference as the residual mapping;

[0110] Modulation of the energy function of the parameterless attention mechanism based on residual mapping: Calculate the hyperbolic tangent value of the residual mapping, add 1 to the hyperbolic tangent value and use it as the gain coefficient, multiply it with the original value of the energy function calculated based on pixel statistical characteristics to obtain the residual guided energy function;

[0111] The final attention weights are calculated using the residual-guided energy function.

[0112] This embodiment details the specific calculation process of the lightweight attention module GhostSAM in generating collaborative attention weights; this module innovatively utilizes the difference between phantom features and original features to drive attention generation;

[0113] Feature generation:

[0114] Convolution operations are typically used Standard convolution generates the original feature map. ; Regarding the original feature map Performing a linear transformation, typically using Depth-wise Convolution in the Ghost module, generates a linearly transformed feature map, also known as a phantom feature map, denoted as... Specifically, Depth-wise Convolution adopts... The kernel size is adjusted to capture local spatial correlation differences while keeping computations low;

[0115] Residual mapping calculation:

[0116] Calculate the original feature map Feature map of linear transformation The absolute difference at the corresponding pixel position is defined as the residual mapping. : ,in , It is a linear transformation operator;

[0117] In the feature space, the background region typically changes little after a linear transformation, i.e. The value is low, while the defect edge or high-frequency abrupt change region often produces a large difference in response after transformation, that is... High value; therefore, It directly indicates the location of potential defects;

[0118] Energy function modulation:

[0119] This embodiment uses a parameter-free attention mechanism, such as SimAM, as its basis, which defines the original value of the energy function. ;in This represents the neuron location index in the spatial dimension of the input feature map. The energy function is constructed based on the spatial inhibition effect of neurons and is calculated as follows: ;

[0120] in, The value of the target neuron. and These are the mean and variance of the input feature map in the current channel, respectively. This is the regularization coefficient; it is used to prevent the denominator from being zero and to adjust the sensitivity of the energy function. Its preferred value range is... to In this embodiment, the value is taken as 0.0001; to enhance the sensitivity to defects, a gain coefficient is introduced in this embodiment. : ;

[0121] in, Given the hyperbolic tangent function, map the residuals. Values ​​mapped to intervals Since the residual mapping R is the absolute difference, its value is always non-negative. The actual mapping interval is [0,1), which makes the range of the gain coefficient G [1,2);

[0122] The residual guided energy function is obtained by modulating the energy function using this gain coefficient. : ;

[0123] Weight generation:

[0124] The modulated residual is used to guide the energy function to calculate the final collaborative attention weights, which are then applied to the feature map.

[0125] Not only does it utilize the statistical characteristics of pixels in the SimAM primitive logic, but it also creatively introduces the operational differences in the feature generation process as prior knowledge. This allows the attention mechanism to automatically focus on regions that are difficult to fit with linear transformations, which are often where industrial defects are found, thus achieving... The detection effect.

[0126] Example 4:

[0127] The calculation logic for the morphological extremum penalty term is as follows:

[0128] Obtain the width and height values ​​of the predicted bounding box and the ground truth bounding box; calculate the ratio of the width to the height value and the ratio of the height to the width value respectively, and select the larger value as the shape factor; calculate the natural logarithm of the shape factor, and calculate the preset power of the difference between the value 1 and the intersection-union ratio of the predicted bounding box and the ground truth bounding box; define the product of the natural logarithm and the preset power as the shape extremum penalty term, and add it to the intersection-union ratio loss function.

[0129] This embodiment details the mathematical construction of the morphological extremum penalty term and its application in the loss function; this design is specifically designed to address the difficulty in detecting large aspect ratio defects, such as slender cracks, in industrial scenarios.

[0130] Definition of morphological factors:

[0131] During training, the system acquires the width of the predicted bounding box in real time. and height And the corresponding value of the true bounding box; to uniformly measure the elongation of defects, a shape factor is defined. : ;

[0132] Regardless of whether the defect is slender laterally or slender longitudinally. All can characterize the extreme values ​​of its aspect ratio; for square targets, For extremely fine and long scratches, The value is very large;

[0133] Construction of the morphological extremum penalty term:

[0134] Based on morphological factors, construct a morphological extremum penalty term. : ;

[0135] in, : is the natural logarithm of the morphological factor; its function is as a basic penalty weight; the thinner and longer the object being detected, the more... The larger, The larger the value, the more sensitive the network is to the regression error of that type of sample; : This is the intersection-union ratio (IU) between the predicted bounding box and the ground truth bounding box; : Represents regression error; : This is the preset power, i.e., the focus coefficient, for example, a value of . or Its function is to further amplify the low The sample loss value; when the target being detected contains a large number of extremely fine scratches, i.e., the aspect ratio is greater than 10:1, it is preferable to use... Set to 3 to force the network to generate stronger gradient backpropagation for low-overlapping prediction boxes, thereby improving localization accuracy;

[0136] Correction of the loss function:

[0137] Final total loss function In standard crossover loss This penalty term is added on top of the existing penalty, where the balance coefficient is... A dimensionless constant used for alignment. and Quantity: ;

[0138] in, This is a balance coefficient; in this embodiment, to ensure that the morphological extremum penalty term and the basic intersection-union ratio loss are aligned in magnitude, The preferred value range is between 0.5 and 1.5, for example, a value of 1.0;

[0139] By introducing The loss function no longer treats defects of all shapes the same; for strip defects, which are the most difficult to detect in industrial scenarios, the model will receive exponentially higher attention, forcing the regression box to fit the topological skeleton of the defect, which significantly improves the fitting accuracy for scratch and crack defects.

[0140] Example 5:

[0141] The industrial surface defect detection method further includes data augmentation processing of the industrial surface images before inputting them into the backbone network. This data augmentation processing includes:

[0142] Size normalization is performed on the acquired industrial surface images;

[0143] Perform a random cropping operation;

[0144] If the cropped image size is smaller than the preset input size, padding is performed; if the cropped image size is larger than the preset input size, scaling is performed.

[0145] This embodiment describes data augmentation processing before the image is input into the backbone network, which is crucial for improving the model's generalization ability;

[0146] Before inputting the acquired industrial surface images into the network, perform the following steps in sequence:

[0147] Size normalization: This involves resizing original images from different sources and at different resolutions to a standard size. Pixels, to meet the tensor dimension requirements of network input;

[0148] Random cropping: randomly select regions in the image for cropping; this step aims to increase the diversity of the sample and simulate the shooting effect at different viewing distances;

[0149] Adaptive fill and scaling:

[0150] If the cropped image size is smaller than the preset input size, the system performs a padding process, typically using gray pixels with RGB values ​​of [value missing]. Perform edge padding to prevent image distortion;

[0151] If the cropped image size is larger than the preset input size, the system performs scaling, typically using bilinear interpolation to reduce the image to the preset size.

[0152] Through the above enhancement strategies, various shooting distances and composition situations that may occur in industrial settings were simulated, effectively preventing model overfitting and improving the model's robustness on actual production lines.

[0153] Example 6:

[0154] Please see Figure 2 An industrial surface defect detection system, based on any one of Examples 1-5, comprising:

[0155] Image acquisition equipment is configured to acquire surface image signals of industrial products;

[0156] Memory, configured to store instructions executed by the computer;

[0157] The processor, connected to the image acquisition device and memory, is configured to execute computer-executed instructions to implement industrial surface defect detection methods.

[0158] The alarm execution unit is configured to receive the defect category and physical coordinates output by the processor; when the defect category data is received, it triggers an audible and visual alarm signal; when the surface pass status mark is received, it remains silent.

[0159] This embodiment provides an industrial surface defect detection system based on the above method; the system includes the following core components at the hardware level:

[0160] Image acquisition equipment: High-resolution industrial cameras, such as Basler area scan cameras, are selected and configured to capture and acquire surface image signals of industrial products, such as high-speed running steel plates, in real time.

[0161] Memory: Used to store computer execution instructions and the weight file of the trained RGE-YOLO model;

[0162] Processor: Typically an embedded industrial computer or high-performance server, integrating a GPU acceleration unit, such as the NVIDIA RTX series; the processor is electrically connected to the image acquisition device and the memory, and is configured to read data from the image acquisition device, call instructions in the memory, and execute all the steps of Examples 1-6;

[0163] Alarm execution unit: connected to the processor's I / O interface;

[0164] When the processor outputs specific defect category data, the alarm execution unit triggers an audible and visual alarm signal, such as lighting up a red light or sounding a buzzer, and can also link the production line PLC to stop the machine or perform marking operations.

[0165] When the processor outputs a surface pass status mark, the alarm execution unit remains silent, and the production line continues to run.

[0166] This embodiment provides a complete hardware and software integration solution, which deploys the above-mentioned high-precision algorithm in actual physical equipment, realizing fully automated closed-loop control from image acquisition to defect removal.

[0167] 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.

Claims

1. A method for detecting surface defects in industrial applications, characterized in that, The method is performed by a computing device equipped with an image processor and includes the following steps: An improved detection network based on the YOLO architecture is constructed, which includes a backbone network, a feature fusion layer, and a detection head; The collected industrial surface images are input into the backbone network, and features are extracted using the robust feature downsampling module. The robust feature downsampling module includes parallel full-frequency flux preservation branches, high-frequency texture response branches, and low-frequency semantic compression branches. The weight distribution of the above three branches is dynamically adjusted by the gating unit according to the calculated local information entropy value of the feature map to generate multi-scale feature maps. The multi-scale feature map is received using a lightweight attention module; by calculating the residual mapping between the original feature map and the linearly transformed feature map generated by linearly transforming the original feature map, a co-attention weight representing the high-frequency abrupt region is generated, and the co-attention weight is fused with the original feature map to obtain the enhanced feature; Based on the predicted bounding box output by the detection head, the loss value is calculated using a loss function that includes a morphological extremum penalty term, and the network parameters are updated; the morphological extremum penalty term is configured to weight the regression error according to the ratio of the width to the height of the bounding box. The trained model is used to infer the image to be detected: if the confidence level output by the detection head is higher than a preset threshold, the defect category and physical coordinates are output; if the confidence level is not higher than the preset threshold, a surface qualified status mark is output.

2. The industrial surface defect detection method according to claim 1, characterized in that, The specific processing logic of the three parallel branches in the robust feature downsampling module is as follows: The full-frequency flux preservation branch performs a slicing operation, which reassembles the pixels of the input feature map in the spatial dimension into the channel dimension according to a preset step size, so as to preserve the spatial position information of the original pixels. The high-frequency texture response branch performs max pooling to extract salient texture features from the input feature map; The low-frequency semantic compression branch performs a convolution operation with stride to extract semantic features from the input feature map and reduce the resolution of the feature map.

3. The industrial surface defect detection method according to claim 1, characterized in that, The step of dynamically adjusting the weight allocation through the gating unit includes: A preset high-frequency entropy threshold and a low-frequency entropy threshold are defined, wherein the high-frequency entropy threshold is greater than the low-frequency entropy threshold; Calculate the local entropy value of the input feature map within the sliding window; When the local information entropy value is greater than or equal to the high-frequency entropy threshold, the current region is determined to be a texture high-frequency region, and a first control instruction is generated to increase the weight ratio of the full-frequency flux preservation branch. When the local information entropy value is less than or equal to the low-frequency entropy threshold, the current region is determined to be a flat background region, and a second control instruction is generated to increase the weight ratio of the low-frequency semantic compression branch. When the local information entropy value is greater than the low-frequency entropy threshold and less than the high-frequency entropy threshold, a third control instruction is generated to perform a balanced weight allocation on the full-frequency flux preservation branch and the low-frequency semantic compression branch.

4. The industrial surface defect detection method according to claim 1, characterized in that, The step of generating collaborative attention weights using a lightweight attention module specifically includes: The original feature map is generated by using convolution operation, and the original feature map is then linearly transformed to generate the corresponding linearly transformed feature map; Calculate the absolute difference between the original feature map and the linearly transformed feature map at the corresponding pixel positions, and define the absolute difference as the residual mapping; The energy function of the parameterless attention mechanism is modulated based on the residual mapping: the hyperbolic tangent value of the residual mapping is calculated, and the hyperbolic tangent value is incremented by 1 and used as the gain coefficient. This value is then multiplied by the original value of the energy function calculated based on pixel statistical characteristics to obtain the residual guided energy function. The final attention weights are calculated using the residual-guided energy function.

5. The industrial surface defect detection method according to claim 1, characterized in that, The calculation logic for the morphological extreme value penalty term is as follows: Obtain the width and height values ​​of the predicted bounding box and the ground truth bounding box; Calculate the ratio of the width value to the height value and the ratio of the height value to the width value respectively, and select the larger value as the shape factor; Calculate the natural logarithm of the morphological factor, and calculate the preset power of the difference between the value 1 and the intersection-union ratio of the predicted bounding box and the true bounding box. The product of the natural logarithm and the preset power is defined as the morphological extremum penalty term and is added to the cross-union ratio loss function.

6. The industrial surface defect detection method according to claim 1, characterized in that, Before inputting the acquired industrial surface images into the backbone network, the method further includes performing data augmentation processing on the industrial surface images, the data augmentation processing including: Size normalization is performed on the acquired industrial surface images; Perform a random cropping operation; If the cropped image size is smaller than the preset input size, then padding is performed; if the cropped image size is larger than the preset input size, then scaling is performed.

7. An industrial surface defect detection system, based on the industrial surface defect detection method according to any one of claims 1-6, characterized in that, include: Image acquisition equipment is configured to acquire surface image signals of industrial products; Memory, configured to store instructions executed by the computer; A processor, connected to the image acquisition device and the memory, is configured to execute the computer execution instructions to implement the industrial surface defect detection method; The alarm execution unit is configured to receive the defect category and physical coordinates output by the processor; when the defect category data is received, it triggers an audible and visual alarm signal; when the surface pass status mark is received, it remains silent.

Citation Information

Patent Citations

  • Bearing surface scratch detection method based on machine vision

    CN115272204A

  • Steel surface defect detection method and system and computer equipment

    CN116664558A

  • Defect inspection method and defect inspection device

    WO2021038633A1