Non-ferrous metal calendaring defect detection method based on machine vision

By enhancing the edge of surface defects in non-ferrous metal rolled strips through multi-scale Laplace filtering and gradient coherence analysis, and combining feature fusion methods of deformable convolution and void convolution, pseudo-defect samples that conform to physical laws are generated, solving the problem of low detection accuracy in existing technologies and achieving efficient defect detection.

CN121304589AInactive Publication Date: 2026-01-09HUZHOU XINGCHEN CLEAN PRECISION TECHNOLOGY CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202511451406.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-11
Publication Date
2026-01-09
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing technologies are difficult to effectively detect surface defects in non-ferrous metal rolling production, especially under conditions of strong reflection, significant differences in defect size, and scarcity of defect samples, resulting in low detection accuracy and limited robustness.

Method used

Multi-scale Laplacian filtering and gradient coherence analysis are used to enhance defect edges. A multi-scale adaptive convolution module combining deformable convolution and dilated convolution is constructed to generate pseudo-defect samples that conform to physical laws through global-local dual-stream feature fusion and spatial attention mechanism. A composite loss function is used for model training.

Benefits of technology

It significantly improves the identifiability of defect areas, enhances detection accuracy and robustness, overcomes the challenges of class imbalance and feature confusion, accelerates model convergence, and achieves accurate characterization of defects of different sizes and shapes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121304589A_ABST
    Figure CN121304589A_ABST
Patent Text Reader

Abstract

The invention discloses a non-ferrous metal calendaring defect detection method based on machine vision, and relates to the technical field of machine learning and image data processing, and the method comprises the following steps: S1, aiming at a non-ferrous metal calendaring strip surface defect detection task, systematically collecting training data and constructing a data set by relying on an actual industrial production line; s2, suppressing reflective noise through multi-scale gradient coherence filtering and enhancing a real defect edge to obtain an enhanced image; s3, constructing and training a non-ferrous metal calendaring defect detection model in combination with the multi-scale feature fusion vector; and S4, detecting the preprocessed image based on a non-ferrous metal calendaring defect detection model to obtain a defect detection result. The problems of metal strong reflection interference, large defect scale difference, sample scarcity, category imbalance and the like in the existing detection are solved. And the non-ferrous metal calendaring defect detection precision and robustness can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of machine learning and image data processing technology, and in particular to a machine vision-based method for detecting defects in non-ferrous metal rolling. Background Technology

[0002] In the non-ferrous metal rolling process, the surface quality of the strip directly affects the mechanical properties, appearance, and applicability of the product for subsequent processing. Due to the complex stress-strain states and variable production environment during the rolling process, the strip surface is highly susceptible to various defects such as cracks, pits, scratches, oxide spots, and indentations. If these defects are not detected and controlled in a timely manner, they can not only lead to material scrap and increased production costs, but may also cause downstream product failures, resulting in serious economic losses and safety hazards.

[0003] In existing technologies, conventional manual quality inspection methods rely on experienced inspectors for visual inspection, which is not only labor-intensive and inefficient, but also highly susceptible to subjective factors, making it difficult to achieve stable and reliable real-time inspection on high-speed continuous production lines. Although existing automated inspection methods based on machine vision have replaced manual inspection to some extent, they still have significant shortcomings in dealing with problems such as strong reflectivity of metal surfaces, significant differences in defect size, scarcity of defect samples, and class imbalance, resulting in low detection accuracy and limited robustness.

[0004] Therefore, there is an urgent need for a new method for detecting defects in non-ferrous metal rolling mills that can suppress strong reflective interference, take into account multi-scale characteristics, have good generalization ability, and adapt to the real-time needs of industrial sites, so as to improve the level of product quality control and the intelligence of the production process. Summary of the Invention

[0005] The purpose of this application is to provide a machine vision-based method for detecting defects in non-ferrous metal rolling mills. This method can enhance defects and suppress reflections through multi-scale Laplacian filtering, gradient coherence calculation, and feature fusion. Then, a detection model is constructed, which includes a multi-scale adaptive convolution module, dual-stream feature fusion, physical pseudo-defect generation, a multi-scale classifier, and a composite loss function. The pseudo-defect generation is based on the principle of metal plastic deformation, and the composite loss function integrates surface characteristics, sample balancing, and contrast discrimination loss. Finally, the trained model is used to process new images, output the defect category, and feed it back to the production system.

[0006] To achieve the above objectives, this application provides the following solution:

[0007] In a first aspect, this application provides a machine vision-based method for detecting defects in non-ferrous metal rolling mills, comprising:

[0008] S1. For the task of detecting surface defects in non-ferrous metal rolled strip, training data is systematically collected based on actual industrial production lines and a non-ferrous metal dataset is constructed.

[0009] S2. Enhanced images are obtained by suppressing reflective noise and enhancing real defect edges through multi-scale gradient coherence filtering;

[0010] S3. Construct and train a non-ferrous metal rolling defect detection model by combining multi-scale feature fusion vectors;

[0011] S4. Based on the non-ferrous metal rolling defect detection model, the preprocessed image is detected to obtain the defect detection results.

[0012] Furthermore, the step of collecting training data and constructing a non-ferrous metal dataset in S1 also includes:

[0013] Acquire image data of various non-ferrous metal materials;

[0014] The collected image data is labeled using a labeling tool to generate a binary mask aligned with the image pixels and corresponding category labels;

[0015] A non-ferrous metal dataset was constructed based on binary masks and corresponding category labels.

[0016] Furthermore, in step S2, the enhanced image obtained by suppressing reflective noise and enhancing real defect edges through multi-scale gradient coherence filtering also includes:

[0017] S201. Based on the constructed dataset, the value of the feature map at the coordinates is obtained through multi-scale Gaussian smoothing and the Laplacian operator;

[0018] S202. Calculate the tensor field based on the first-order gradient of the image at each scale, and perform eigenvalue decomposition on the tensor field to obtain the maximum and minimum eigenvalues. Calculate the gradient direction consistency coefficient based on the maximum and minimum eigenvalues.

[0019] S203. Multiply the Laplacian filter output features at each scale with the gradient coherence coefficients at the corresponding scale, and then perform weighted fusion according to the preset exponential decay weights to obtain the enhanced image.

[0020] Furthermore, obtaining the enhanced image also includes:

[0021] ;

[0022] In the formula, This represents the fusion weight coefficient at the s-th scale; Let be the gradient coherence coefficient of the tensor field at the s-th scale; Indicates the enhanced image in coordinates Pixel value at that location, This indicates an enhanced image, which is a single-channel grayscale image after enhancement. Represents the scale index; S is a preset set of discrete scales.

[0023] Furthermore, the construction and training of the non-ferrous metal rolling defect detection model in S3 also includes:

[0024] S301. Adaptive extraction of multi-scale defect features is performed through deformable convolution and multi-scale adaptive convolution modules to form a multi-scale feature map that combines geometric adaptability and multi-scale context.

[0025] S302. Based on multi-scale feature maps, a global-local dual-branch structure is adopted, and feature modulation is achieved through spatial attention mechanism to obtain dual-stream fusion features that have both global semantics and local details;

[0026] S303. Based on the principle of metal plastic deformation, synthesize pseudo-defect images that combine realistic appearance and defect morphology.

[0027] S304. A multi-scale feature pyramid classifier is adopted, and multi-scale feature fusion is performed through a spatial-channel dual attention mechanism to obtain a multi-scale defect feature classifier.

[0028] S305. A three-stage adaptive loss function is adopted, and a composite loss function is obtained through a dynamic weighting mechanism.

[0029] S306. The final non-ferrous metal rolling defect detection model is obtained by iterative optimization using a small-batch gradient descent strategy.

[0030] Furthermore, the formation of a multi-scale feature map with both geometric adaptability and multi-scale context in step S301 also includes:

[0031] S3011. The spatial offset of each sampling point of the convolution kernel is generated by the offset prediction network, the sampling position of the standard convolution kernel is dynamically adjusted, the input feature map is subjected to adaptive convolution operation, and the geometric adaptive features are output through the ReLU activation function.

[0032] S3012. Dynamically adjust the dilation rate of the dilated convolution according to the current network layer depth, perform multi-receptive field convolution operation on the feature map output by deformable convolution, and extract multi-scale contextual features.

[0033] S3013: By splicing geometric adaptive features and multi-scale contextual features, a multi-scale feature map with both geometric adaptability and multi-scale contextuality is formed.

[0034] Furthermore, the synthesis of a pseudo-defect image that combines realistic appearance and defect morphology in step S303 also includes:

[0035] S3031. Based on the deformation characteristics of metallic materials, generate crack element models and pit element models respectively.

[0036] S3032. Randomly rotate the generated crack primitive model and combine it with the pit primitive model through morphological expansion to generate a composite defect mask that simulates the actual metal deformation morphology.

[0037] S3033. Apply the defect mask to the normal sample image, add Gaussian noise that matches the noise characteristics of metal surface to the defect area, and synthesize a pseudo-defect image that has both realistic appearance and defect shape.

[0038] Furthermore, in step S304, a multi-scale feature pyramid classifier is employed, and a multi-scale feature fusion is performed through a spatial-channel dual attention mechanism to obtain a multi-scale defect feature classifier. This also includes:

[0039] S3041. Convolutionally compress the channel dimension and capture spatial relationships of the multi-scale feature map in sequence, and generate a spatial attention map by using the Sigmoid activation function.

[0040] S3042. Global average pooling is performed on the dual-stream fusion features to obtain the global feature vector. The channel attention weights for each category are calculated using the trainable weight matrix and bias terms. After normalization by the Softmax function, the channel attention vectors are obtained.

[0041] S3043. Perform a dot product weighting on the spatial attention maps and channel attention vectors at each scale, and sum the weighted multi-scale features to construct a feature pyramid fusion feature.

[0042] S3044. Perform convolution and spatial flattening operations on the feature pyramid fusion features, extract auxiliary features of the pseudo-defect image and fuse them according to weights, and then output the defect classification prediction probability vector through the Softmax function.

[0043] Furthermore, S305 employs a three-stage adaptive loss function, obtaining a composite loss function through a dynamic weighting mechanism, and also includes:

[0044] S3051. Generate a reflective mask based on the bright areas in the enhanced image, weight the defect classification loss based on the reflective mask, and calculate the surface characteristic loss.

[0045] S3052. Dynamically adjust the cross-entropy loss weights based on the number of samples of each category in the current training batch, and calculate the sample balance loss.

[0046] S3053. Calculate the similarity between positive and negative sample features based on cosine distance, control the inter-class distance through boundary margin, and calculate the contrast discrimination loss.

[0047] S3054. The weighted sum of surface characteristic loss, sample balance loss, and contrast discrimination loss yields the composite loss function, expressed as:

[0048] ;

[0049] In the formula, Indicates the surface characteristic loss weight; Indicates the sample balance loss weights; Indicates the weights used to differentiate between loss values; Indicates the comparison and differentiation of losses; Indicates the sample balance loss; Indicates loss of surface properties; This represents the composite loss function.

[0050] Furthermore, obtaining the defect detection result in S4 also includes:

[0051] For the acquired images of non-ferrous metal rolled strip, multi-scale texture enhancement preprocessing is performed to obtain the preprocessed image;

[0052] The preprocessed image is input into the non-ferrous metal rolling defect detection model, and the defect classification prediction probability vector is output.

[0053] Determine whether an image has defects and the type of defects based on the probability vector predicted by defect classification.

[0054] According to the specific embodiments provided in this application, compared with the prior art, the non-ferrous metal rolling defect detection method provided in this application based on machine vision has the following technical effects:

[0055] 1. This application proposes a texture enhancement method that combines multi-scale Laplacian filtering and gradient coherence analysis. While preserving the texture details of micron-level defects, it effectively suppresses strong reflective noise interference and significantly improves the recognizability of defect areas.

[0056] 2. This application constructs a multi-scale adaptive convolution module that combines deformable convolution and dilated convolution, and adopts a global-local dual-stream feature fusion and spatial attention mechanism to take into account both global semantics and local details, thereby achieving accurate representation of defects of different sizes and shapes.

[0057] 3. This application proposes a pseudo-defect generation method based on the principle of metal plastic deformation. By geometric modeling, mask deformation and noise injection, a defect sample that conforms to physical laws is generated, which solves the problem of scarcity of real defect data and improves the generalization ability and robustness of the model.

[0058] 4. This application adopts a composite loss function that integrates surface characteristic loss, sample balance loss and contrast discrimination loss, and uses an adaptive weighting strategy to dynamically adjust the optimization objective, which effectively overcomes the problems of class imbalance and feature confusion, accelerates model convergence and improves detection accuracy and stability. Attached Figure Description

[0059] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0060] Figure 1 A structural diagram of a machine vision-based method for detecting defects in non-ferrous metal rolling mills, provided in an embodiment of this application;

[0061] Figure 2 A comparative diagram showing the impact of different data augmentation methods provided in an embodiment of this application on the model's generalization ability in a small sample scenario;

[0062] Figure 3 A comparative diagram showing the impact of multi-scale parameters on detection performance in an embodiment of this application;

[0063] Figure 4 This is a comparison chart of the detection accuracy of different defect types provided in an embodiment of this application;

[0064] Figure 5 A comparison chart of the changes in the loss function during the training process provided in an embodiment of this application. Detailed Implementation

[0065] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0066] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0067] like Figure 1 As shown, a machine vision-based method for detecting defects in non-ferrous metal rolling mills includes:

[0068] S1. For the task of detecting surface defects in non-ferrous metal rolled strip, training data is systematically collected based on actual industrial production lines and a non-ferrous metal dataset is constructed.

[0069] S2. Enhanced images are obtained by suppressing reflective noise and enhancing real defect edges through multi-scale gradient coherence filtering;

[0070] S3. Construct and train a non-ferrous metal rolling defect detection model by combining multi-scale feature fusion vectors;

[0071] S4. Based on the non-ferrous metal rolling defect detection model, the preprocessed image is detected to obtain the defect detection results.

[0072] Optionally, the step S1 of collecting training data and constructing a non-ferrous metal dataset further includes:

[0073] This application addresses the surface defect detection task of non-ferrous metal rolled strips. It relies on actual industrial production lines to collect training data and systematically construct the dataset. Specifically...

[0074] The data acquisition process is completed at the inspection station of the non-ferrous metal rolling production line. A high-resolution line scan camera is used in conjunction with a uniformly distributed LED linear light source to suppress ambient light interference and maintain imaging stability.

[0075] The acquired image data covers a variety of typical non-ferrous metal materials, including rolled strips of copper, aluminum, and titanium alloys. The image resolution is 4096×2048 pixels and it is stored in RGB three-channel format.

[0076] Data sources include continuous collection during normal production processes and targeted sampling for typical defects to ensure data diversity.

[0077] Furthermore, the collected data is labeled. During the labeling stage, experienced quality inspectors meticulously label the defective areas in the images according to industry standards. The labeling categories include common rolling defects such as cracks and pits. At the same time, a "normal" category is set for defect-free samples.

[0078] The annotation process is carried out with the help of annotation tools to generate binary masks and category labels aligned with image pixels. The final non-ferrous metal dataset includes a training set, a validation set and a test set. The training set is used for model parameter learning, the validation set is used for hyperparameter tuning and early stopping judgment, and the test set is used for final performance evaluation.

[0079] Optionally, the surface of rolled metal strip has strong reflective interference, which can easily mask the true defect features. Conventional processing methods such as histogram equalization, while enhancing image contrast, often amplify reflective noise and destroy the texture structure of micron-level defects, resulting in a decrease in defect recognition performance.

[0080] This application suppresses reflective noise and enhances realistic defect edges through multi-scale gradient coherence filtering, effectively suppressing reflective areas while preserving micron-level defect texture. The specific steps are as follows:

[0081] S201. Based on the constructed dataset, feature maps in coordinates are obtained through multi-scale Gaussian smoothing and the Laplacian operator. The value at;

[0082] Specifically, the original RGB image of the non-ferrous metal is converted into a grayscale image. The grayscale image is then smoothed using Gaussian kernels with different standard deviations from a preset scale set. Subsequently, the Laplacian operator is applied to extract second-order gradient features at each scale. Multi-scale Gaussian smoothing suppresses noise, and the Laplacian operator enhances edge and texture structure features in the image, thereby highlighting the edge information of real defects at multiple scales while reducing interference from smoothed background regions. This can be represented as follows:

[0083] ;

[0084] In the formula, Represents the original non-ferrous metal image in coordinates The value at that location, the image dimension is It is an RGB three-channel image; This is a grayscale conversion function used to convert the original non-ferrous metal image into a grayscale image; Image height; Image width; Indicates coordinate index; The standard deviation is expressed as The two-dimensional Gaussian kernel function in coordinates The value at; The standard deviation of the Gaussian kernel is preferably set. Used to control smoothing intensity; This represents the scale index; S is a predefined set of discrete scales. ; Represents a two-dimensional convolution operation; This represents the Laplacian operator, used to extract second-order gradient features from an image; This represents the Laplacian filter output feature map at scale s in coordinates. The value at that point represents the scale. The pixel values ​​of the second-order gradient feature map of the image below are used to highlight edges and texture structures, such as defect edges, while suppressing smooth areas.

[0085] S202. Calculate the tensor field based on the first-order gradient of the image at each scale, and perform eigenvalue decomposition on the tensor field to obtain the maximum and minimum eigenvalues. Calculate the gradient direction consistency coefficient based on the maximum and minimum eigenvalues.

[0086] Specifically, a tensor field is calculated based on the first-order gradient of the image at various scales, and the tensor field is decomposed into maximum and minimum eigenvalues. Based on this, a gradient direction consistency coefficient is calculated to quantify the degree of consistency of gradient directions in local regions. High consistency regions correspond to real defect edges, while low consistency regions correspond to reflective noise, thus effectively distinguishing defects from noise. This is expressed as:

[0087] ;

[0088] In the formula, This represents the tensor field at the s-th scale, where each pixel location has a... Matrix, represented as ; For the tensor field at the s-th scale in coordinates The matrix at the location; Indicates image along The first-order gradient in the axial direction; Indicates image along The first-order gradient in the axial direction; The largest eigenvalue of the tensor field corresponds to the maximum rate of change of the local gradient direction, and is obtained through tensor field eigenvalue decomposition. The smallest eigenvalue of the tensor field corresponds to the smallest rate of change of the local gradient direction and is obtained through tensor field eigenvalue decomposition. This represents a very small positive number, used to avoid a denominator of zero; it is preferably set to 0.0001.

[0089] The gradient coherence coefficient is used to calculate the consistency of local gradient directions, and the output value range is... , Let be the gradient coherence coefficient of the tensor field at the s-th scale. The term is used to quantify the consistency of local gradient directions; a high value indicates high consistency in local gradient directions, while a low value indicates disordered directions. This indicates that the gradient direction is highly consistent in a local area, such as the edge of a real defect. To indicate directional disorder, such as reflective noise, in one implementation, the thresholds for distinguishing high and low values ​​can be set to 0.7 and 0.3, respectively.

[0090] In practice, and They represent the first time. Gaussian smoothed image at different scales along shaft and The first-order gradient of the axis is calculated using the Sobel operator. Gaussian smoothed image at different scales In coordinates The value at that location is The acquisition method is represented as .

[0091] S203. Multiply the Laplacian filter output features at each scale with the gradient coherence coefficients at the corresponding scale, and then perform weighted fusion according to the preset exponential decay weights to obtain the enhanced image.

[0092] Specifically, the Laplacian filter output features at each scale are multiplied by the gradient coherence coefficients of the corresponding scale, and then weighted and fused according to a preset exponential decay weight to obtain the enhanced image. During the fusion process, the rich details of small-scale features are emphasized while noise in large-scale features is suppressed, thus enhancing defect edges while reducing reflective interference. This can be expressed as:

[0093] ;

[0094] In the formula, The fusion weight coefficient at the s-th scale is expressed as follows: ; Indicates the weight decay factor, such as, To control the suppression intensity of large-scale features; It is a natural exponential function; Indicates the enhanced image in coordinates Pixel value at that location, The enhanced image is a single-channel grayscale image with dimensions of . This characterizes the defect enhancement result after suppressing reflection, which suppresses reflective areas while preserving micron-level defect texture.

[0095] Optionally, the construction and training of the non-ferrous metal rolling defect detection model in S3 further includes:

[0096] S301. Adaptive extraction of multi-scale defect features is performed through deformable convolution and multi-scale adaptive convolution modules to form a multi-scale feature map that combines geometric adaptability and multi-scale context.

[0097] S302. Based on multi-scale feature maps, a global-local dual-branch structure is adopted, and feature modulation is achieved through spatial attention mechanism to obtain dual-stream fusion features that have both global semantics and local details;

[0098] S303. Based on the principle of metal plastic deformation, synthesize pseudo-defect images that combine realistic appearance and defect morphology.

[0099] S304. A multi-scale feature pyramid classifier is adopted, and multi-scale feature fusion is performed through a spatial-channel dual attention mechanism to obtain a multi-scale defect feature classifier.

[0100] S305. A three-stage adaptive loss function is adopted, and a composite loss function is obtained through a dynamic weighting mechanism.

[0101] S306. The final non-ferrous metal rolling defect detection model is obtained by iterative optimization using a small-batch gradient descent strategy.

[0102] Optionally, conventional convolutional neural networks use convolutional kernels of fixed shape and size, which makes it difficult to effectively extract features of micron-level point defects and millimeter-level strip defects simultaneously, resulting in missed detection of small defects and incomplete features of large defects.

[0103] In step S301, deformable convolution and multi-scale adaptive convolution modules are used to adaptively extract multi-scale defect features, forming a fusion feature that combines geometric adaptability and multi-scale context. The specific steps are as follows:

[0104] S3011. The spatial offset of each sampling point of the convolution kernel is generated by the offset prediction network, the sampling position of the standard convolution kernel is dynamically adjusted, the input feature map is subjected to adaptive convolution operation, and the geometric adaptive features are output through the ReLU activation function.

[0105] Specifically, the offset prediction network generates the spatial offset of each sampling point of the convolutional kernel, dynamically adjusts the sampling position of the standard convolutional kernel, performs adaptive convolution on the input feature map, and outputs geometrically adaptive features through the ReLU activation function. This enhances the feature extraction capability for irregular shape defects and improves the model's adaptability to geometric deformation, as expressed in:

[0106] ;

[0107] In the formula, This indicates the multi-scale adaptive convolution module. The input feature map of the layer, when hour, To enhance the image ; This represents the layer index of the multi-scale adaptive convolution module. ; This represents the total number of layers in the multi-scale adaptive convolutional module, with the preferred setting being... ; Indicates the number of convolution sampling points, e.g., correspond Convolution kernel; For sampling point index; This indicates the multi-scale adaptive convolution module. Layer The convolution weight parameters for each sampling point are trainable parameters; In the standard convolution kernel, the first... The fixed coordinate positions of each sampling point are the fixed sampling positions of the standard convolution kernel, such as when performing a 3×3 convolution. ; Indicates the first The learnable offset of each sampling point is generated by a preset offset prediction network; This indicates the multi-scale adaptive convolution module. The bias terms of a layer are trainable parameters; This represents the modified linear unit activation function; This indicates the multi-scale adaptive convolution module. The deformable convolutional feature map output by the layer represents geometrically adaptive features and captures irregular defects.

[0108] In practice, learnable offsets are generated through a pre-set offset prediction network. The offset prediction network can use lightweight convolutional layers to predict the offset of sampling points, achieving adaptive spatial deformation of features. This network uses feature maps... The input is and the output dimension is . The offset field.

[0109] S3012. Dynamically adjust the dilation rate of the dilated convolution according to the current network layer depth, perform multi-receptive field convolution operation on the feature map output by deformable convolution, and extract multi-scale contextual features.

[0110] Specifically, the dilation rate of dilated convolutions is dynamically adjusted based on the current network layer depth. Multi-receptive-field convolution operations are performed on deformable convolutional feature maps to extract contextual information at different scales. By expanding the receptive field, global features of large-scale defects are captured, while maintaining sensitivity to small-scale defects. This can be represented as:

[0111] ;

[0112] In the formula, This represents a dilated convolution operation with an inflation rate of r.

[0113] This indicates the multi-scale adaptive convolution module. The expansion rate of the layer is calculated as follows: It changes periodically with network depth;

[0114] This represents the modulo operation, used to calculate the remainder. express The remainder when divided by 3, such as, hour, ;

[0115] This indicates the multi-scale adaptive convolution module. The dilated convolutional feature map output by the layer represents multi-scale contextual features and captures defects of different sizes.

[0116] S3013: By splicing geometric adaptive features and multi-scale contextual features, a fused feature map with both geometric adaptability and multi-scale contextuality is formed.

[0117] Specifically, the output features of deformable convolution and dilated convolution are spliced ​​together to form a complementary multi-scale representation, as shown below:

[0118] ;

[0119] In the formula, Indicates feature concatenation operation;

[0120] This indicates the multi-scale adaptive convolution module. The fused feature map output by the layer combines geometric adaptability and multi-scale contextual information, representing features that combine geometric adaptability and multi-scale context.

[0121] Furthermore, a single feature extraction path cannot simultaneously take into account both global semantic information and local detailed features, which can easily lead to small defects being submerged by the global background and large defects lacking local support.

[0122] The S302 dual-stream feature fusion package adopts a global-local dual-branch structure and uses a spatial attention mechanism to achieve feature modulation. It sequentially performs global feature extraction, local feature extraction, and spatial attention feature fusion to obtain fused features that combine global semantics and local details. The specific steps are as follows:

[0123] S3021. Global feature extraction includes: performing global average pooling on the fused feature maps output from different layers of the multi-scale adaptive convolution module, concatenating them to obtain feature vectors, and then transforming them through a multilayer perceptron to obtain global feature vectors representing the overall semantic content of the image. This achieves the aggregation of deep, high-level semantic information and provides contextual basis for defect classification, represented as follows:

[0124] ;

[0125] In the formula, This indicates the multi-scale adaptive convolution module. The fused feature map output by the layer represents deep high-level semantic features. The fourth layer was chosen because it balances abstraction and detail in the multi-scale adaptive convolution module. This indicates the multi-scale adaptive convolution module. The fused feature map output by the layers is selected from the second layer because it retains more spatial information; Represents a global feature vector, which characterizes the overall content of the image; Indicates feature concatenation operation; This indicates a global average pooling operation; It is a multilayer perceptron used to enhance global semantic representation and extract high-level semantic global features. For example, a 3-layer perceptron network has a hidden layer dimension of 256, an output layer dimension of 512, and the activation function is ReLU activation function.

[0126] S3022. Local feature extraction includes: locating regions that significantly contribute to classification decisions based on gradient-weighted class activation mapping algorithm; cropping high-response regions from intermediate layer feature maps to obtain local feature maps focusing on potential defects, enhancing the feature preservation ability for minor defects and local details, as shown below:

[0127] ;

[0128] In the formula, The attention region is represented by a size of The rectangular region is calculated as follows: ; This represents the gradient-weighted class activation mapping algorithm, used to locate regions that significantly contribute to classification decisions. To retrieve the position of the maximum value, return the coordinate index. The project uses the location of the maximum value in the heatmap as the center of the attention area, and then clips a fixed-size area. For the cropping operation, Indicates from the fused feature map Extracting attention regions The corresponding area; This represents a local feature map, characterizing local high-response areas and focusing on potential defect areas; The height dimension of the attention area; This refers to the width of the attention area. This indicates the number of channels in the feature map.

[0129] It should be noted that Gradient-weighted Class Activation Mapping (Grad-CAM) is a method for interpreting the decisions of convolutional neural networks. It generates heatmaps to show the regions of interest of the model in the input image. The core idea is to use gradient information to calculate the weights of feature maps to class scores.

[0130] S3023. Spatial attention feature fusion includes: projecting the global feature vector and local feature map onto the same dimension as the intermediate layer feature map, generating spatial attention weights through the Sigmoid activation function, and then weighting and fusing them with the intermediate layer features adjusted by hyperbolic tangent activation to obtain fused features that combine global semantics and local details. This achieves functional complementarity and adaptive modulation of global and local information, as expressed as:

[0131] ;

[0132] In the formula, This represents the global feature projection weight matrix, which is a trainable parameter. The local feature projection weight matrix represents trainable parameters. This represents the Sigmoid activation function, which maps the fused features to... Intervals serve as spatial attention weights; To expand global features, the global feature vector is... Expand to Dimension, specifically projected onto the fully connected layer. The channel is then projected, and the resulting features are copied along its spatial dimensions to obtain... A three-dimensional tensor; To expand local features, the local feature map is... Expand to Specifically, its height and width are adjusted using upsampling or downsampling interpolation methods. Size, and adjust its channel count using a preset convolutional layer. aisle; This represents the hyperbolic tangent activation function, which compresses the feature values ​​to... This enhances nonlinearity and stabilizes training. Represents the Hadamard product; This indicates the multi-scale adaptive convolution module. The fused feature map output by the layers is selected from the third layer as the fusion point because it takes into account both semantics and details; This represents a global-local fusion feature map, which combines global semantics with local detail information, and has a dimension of [missing information]. .

[0133] Optionally, in actual production, defect samples are extremely rare, while normal samples account for the vast majority. Synthetic samples generated by conventional oversampling methods often do not conform to the laws of metal deformation, thus misleading the model's learning.

[0134] The generation of pseudo-defects based on physical properties in S303 includes synthesizing physically reasonable pseudo-defect samples based on the principle of metal plastic deformation, and synthesizing pseudo-defect images with realistic appearance and diverse shapes. The specific steps are as follows:

[0135] S3031. Based on the deformation characteristics of metallic materials, generate crack element models and pit element models respectively.

[0136] Specifically, based on the deformation characteristics of metallic materials, geometric models of two typical defects, cracks and pits, are generated respectively;

[0137] Define the crack primitive model as , The crack length parameter is represented by the following condition: Uniform distribution of intervals, The crack width parameter follows a normal distribution with a mean of 0 and a standard deviation of 0.1.

[0138] Define the pit primitive model as , The diameter parameter of the pit is specified, and follows the parameters. Uniform distribution within the interval.

[0139] In practical implementation, the crack primitive model Parametric curves are generated using the Bézier curve model. Controlling the length, Controlling width noise, simulating metal tensile cracks, and creating a pitted element model. Generate circular or elliptical masks using circular or elliptical mask models. Control the diameter to simulate indentation deformation.

[0140] S3032. Randomly rotate the generated crack primitive model and combine it with the pit primitive model through morphological expansion to generate a composite defect mask that simulates the actual metal deformation morphology.

[0141] Specifically, the generated crack primitive model is randomly rotated and morphologically expanded and combined with the pit primitive model to generate a composite defect mask that simulates the actual deformation morphology of metal. Affine transformations and morphological operations are used to enhance the diversity and physical plausibility of the defect morphology, as shown below:

[0142] ;

[0143] In the formula, Represents the rotation transformation operator. For the rotation angle, obey Uniform distribution of intervals, The term represents the result after rotating the generated crack primitive model;

[0144] This represents a morphological expansion operation, simulating the material accumulation effect during metal deformation.

[0145] The defect mask matrix is ​​represented by a value range of . binary mask, Indicates the defect area. Represents the normal region, with dimensions of .

[0146] S3033. Apply the defect mask to the normal sample image, add Gaussian noise that matches the noise characteristics of metal surface to the defect area, and synthesize a pseudo-defect image that has both realistic appearance and defect shape.

[0147] Specifically, a defect mask is applied to a normal sample image, and Gaussian noise matching the noise characteristics of a metal surface is added to the defect area to synthesize a pseudo-defect image that combines realistic appearance with defect morphology. By controlling the noise intensity and distribution, the realism and diversity of the generated samples are improved, as shown below:

[0148] ;

[0149] In the formula, The normal sample image is a defect-free surface image obtained from the dataset, with dimensions of [dimension number missing]. ;

[0150] The mean is Standard deviation is Gaussian noise field;

[0151] Representation and defect mask matrix A matrix of all ones with the same dimension;

[0152] The noise intensity is expressed as follows: ;

[0153] This represents the local standard deviation of the image, specifically calculated using a sliding window. For example, the sliding window size is... ;

[0154] This indicates a pseudo-defect image, which is a synthetic pseudo-defect image rather than a natural pseudo-defect image.

[0155] In one embodiment, such as Figure 2As shown, a comparative analysis of the pseudo-defect generation effects was conducted to explore the impact of different data augmentation methods on the model's generalization ability in small sample scenarios. The F1 score (a metric combining precision and recall, ranging from 0 to 1) was observed by varying the number of training samples. Experimental results show that when the sample size is ≤1000, the F1 score of our technique (pseudo-defect generation based on physical characteristics) is significantly higher than the comparative methods (no augmentation, synthetic minority class oversampling, and generative adversarial networks), reaching approximately 0.85 with 500 samples. Even when the sample size increases to 5000, our technique remains superior. The experimental configuration used a 10:1 normal / defect sample ratio, and a lightweight Softmax classifier was used for testing.

[0156] Alternatively, ordinary classifiers struggle to adapt to the differences in feature distributions between defects of different scales, tend to ignore small-scale features, and lack adaptive weighting for feature responses to different categories of defects.

[0157] The S304 uses a multi-scale feature pyramid classifier, performs multi-scale feature fusion through a spatial-channel dual attention mechanism to obtain a multi-scale defect feature classifier, and also includes:

[0158] S3041. Convolutionally compress the channel dimension and capture spatial relationships of the multi-scale feature map in sequence, and generate a spatial attention map by using the Sigmoid activation function.

[0159] Specifically, the multi-scale feature maps are sequentially subjected to 1×1 convolution to compress channel dimensions and 3×3 convolution to capture spatial relationships. A spatial attention map is then generated using the Sigmoid activation function to highlight the feature responses in the defect region, thereby enhancing the spatial information related to the defect location in the feature maps. This is represented as follows:

[0160] ;

[0161] In the formula, This indicates the multi-scale adaptive convolution module. The fused feature map output by the layer represents the multi-scale defect features;

[0162] express Convolution operations are used to compress channel dimensions.

[0163] express Convolution operations capture local spatial relationships;

[0164] This represents the spatial attention weight map at scale s, with dimension . High-value areas correspond to defect locations;

[0165] Represents the fused feature map Height;

[0166] Represents the fused feature map The width.

[0167] It should be noted that in multi-scale feature fusion, the fused feature map The first from the multi-scale adaptive convolution module The fused feature map output by the layer. These feature maps capture defect contextual information at different scales, which is used to construct feature pyramids and scale indexes. Layer indexing with multi-scale adaptive convolution modules The correspondence is as follows: Let These correspond to the first and second steps of the multi-scale adaptive convolution module, respectively. fused feature map output by the layer ,Right now, Corresponding to the multi-scale adaptive convolution module fused feature map of layer output , Corresponding to the multi-scale adaptive convolution module fused feature map of layer output , Corresponding to the multi-scale adaptive convolution module fused feature map output by the layer .

[0168] S3042. Global average pooling is performed on the dual-stream fusion features to obtain a global feature vector. Channel attention weights for each category are calculated using a trainable weight matrix and bias terms. After normalization using the Softmax function, channel attention vectors are obtained. The feature importance of different defect types is then dynamically adjusted, as shown below:

[0169] ;

[0170] In the formula, The global average pooling vector represents the dual-stream fusion feature, obtained by analyzing the global-local fusion feature map. The result obtained by global average pooling is a D-dimensional vector.

[0171] This represents the channel attention weight matrix, with dimension 1. , are trainable parameters;

[0172] The number of categories;

[0173] Global-local fusion feature map The number of channels is a hyperparameter, such as setting it to 64;

[0174] This represents the channel attention bias term, which is a trainable parameter;

[0175] For the Softmax function;

[0176] Let represent the channel attention vector at scale s, which characterizes the importance of features for each category.

[0177] S3043. Perform a dot product weighted summation between the spatial attention maps at each scale and the expanded channel attention vectors, and sum the weighted multi-scale features to construct a feature pyramid fusion feature, achieving adaptive fusion of multi-scale defect features, expressed as:

[0178] ;

[0179] In the formula, The pyramid feature represents the fused feature, and the weighted multi-scale defect feature is represented.

[0180] This is a vector copy operation. The term represents the vector Replicating and expanding along spatial dimensions to The items have the same spatial dimensions.

[0181] S3044. Perform 1×1 convolution and spatial flattening operations on the feature pyramid fusion features, simultaneously extract auxiliary features from the pseudo-defect images and fuse them according to weights, then output the defect classification probability through the Softmax function, thereby combining real and synthetic features to improve the reliability of classification decisions, as expressed as:

[0182] ;

[0183] In the formula, This indicates a flattening operation in spatial dimensions;

[0184] This represents the pseudo-defect feature extraction function. Item will be a pseudo-defect image Input a preset lightweight convolutional network to extract features, specifically using two layers. The convolutional network implementation uses 32 channels and ReLU activation, expressed as follows: And by adjusting the output feature map size and the fused feature pyramid features through adaptive pooling. same;

[0185] Let represent the defect classification prediction probability vector. The dimension of the vector is the same as the number of categories. For a single sample, the is defined as follows: The defect classification prediction probability vector for each sample is: ;

[0186] The feature fusion coefficient is preferably set during the training phase. By incorporating pseudo-defect features, a setting is made during the inference phase. Using only real image features.

[0187] Optionally, the strong reflectivity of metal surfaces and the extreme imbalance of defect samples pose challenges to model training. A single loss function cannot simultaneously address issues such as reflectivity interference, class imbalance, and feature separability.

[0188] S305 employs a three-stage adaptive loss function, which integrates multiple optimization objectives through a dynamic weighting mechanism. The specific steps are as follows:

[0189] S3051. Generate a reflective mask based on the bright areas in the enhanced image. Use this mask to weight the defect classification loss, strengthening the model's feature learning of real defects in the reflective areas, thereby suppressing the impact of reflective interference on classification performance. This is expressed as:

[0190] ;

[0191] In the formula, This indicates the total number of samples in the current batch;

[0192] Indicates the sample index. ;

[0193] Indicates the first The true label vector of each sample is a one-dimensional vector in One-hot encoding format;

[0194] Indicates the first The defect classification prediction probability vector for each sample;

[0195] Indicates the first A mask of reflective areas for each sample, used to enhance the image. Pixel regions with a brightness value greater than 200 are generated;

[0196] This represents the mask counting function. The term represents the mask for reflective areas. Counting non-zero elements;

[0197] This indicates logarithmic operations, with the default base being the natural constant;

[0198] This indicates surface characteristic loss, with classification loss enhanced in reflective areas.

[0199] In the specific implementation, the reflective area mask is obtained by taking the i-th enhanced image. The applied pixel threshold is greater than The binary mask is generated in the manner described above, that is, the i-th enhanced image. If the corresponding pixel value is greater than 200, set it to 1; otherwise, set it to 0.

[0200] S3052. Dynamically adjust the cross-entropy loss weights based on the number of samples of each category in the current training batch, and calculate the sample balance loss.

[0201] Specifically, the cross-entropy loss weights are dynamically adjusted based on the number of samples of each class in the current training batch, reducing the dominant influence of the class with the larger number of samples on the loss function and alleviating the class imbalance problem, as expressed as:

[0202] ;

[0203] In the formula, Indicates category index, ;

[0204] This represents the vector of the number of samples in each category in the current training batch. ;

[0205] Indicates the first in the current training batch The number of samples in each category, i.e. Indicates the first in the current training batch The number of samples in each category Indicates the first in the current training batch The number of samples in each category Indicates the first in the current training batch The number of samples in each category;

[0206] Representing vectors The maximum value of the elements in the middle;

[0207] This indicates that all samples in the current training batch are at the [number]th ...]. The predicted probability vector for each category is composed of the defect classification probability vector for each sample. The Composed of 10 elements;

[0208] Indicates that all samples are in the first... The true label vectors for each category;

[0209] Represents the cross-entropy loss function;

[0210] This represents the sample balance loss, and weighting helps alleviate imbalance.

[0211] S3053. Calculate the similarity between positive and negative sample features based on cosine distance, control the inter-class distance through boundary margin, and calculate the contrast discrimination loss.

[0212] Specifically, the similarity between positive and negative sample features is calculated based on cosine distance. Boundary margin is used to control the inter-class distance, bringing similar defective features closer together and separating dissimilar features, thereby enhancing the separability of the feature space. This can be expressed as:

[0213] ;

[0214] In the formula, This represents the set of positive sample features, derived from the global-local fusion feature map. The training batch contains feature vectors of all defective samples.

[0215] Indicates the number of positive samples;

[0216] This represents the set of negative sample features, derived from the global-local fusion feature map. The training batch contains feature vectors of normal samples or outlier defects;

[0217] Represents the feature vector of positive samples, characterizing the feature vector of positive samples with the same type of defect;

[0218] Represents the feature vector of negative samples, characterizing the feature vector of negative samples that are either outliers or normal samples;

[0219] Represents the natural constant;

[0220] Represents the cosine distance function;

[0221] Indicates boundary margin, such as, Controlling the minimum distance between classes enhances separability;

[0222] This indicates the loss of comparison and differentiation, bringing similar features closer together and pushing away dissimilar features.

[0223] In practical implementation, the positive sample feature set For each defective sample in the training batch, its global-local fusion feature map is calculated. The global average pooling vector is used to collect the global average pooling vectors of all positive samples to form a positive sample feature set. Similarly, for each normal sample in the training batch, its global-local fusion feature map is calculated. The global average pooling vector is used to collect the global average pooling vectors of all negative samples to form a negative sample feature set. .

[0224] It should be noted that the cosine distance function is not sensitive to feature amplitude, making it suitable for similarity measurement. The term uses the cosine distance calculation method instead of other calculation methods such as Euclidean distance.

[0225] S3054. The surface characteristic loss, sample balancing loss, and contrast discrimination loss are weighted and summed to obtain a composite loss function, which is used for model training optimization to dynamically balance the contributions of different optimization objectives, expressed as:

[0226] ;

[0227] In the formula, Represents the surface characteristic loss weights, such as, ;

[0228] Indicates the sample balance loss weights, such as, ;

[0229] This indicates the weights used to differentiate between loss values, such as... ;

[0230] This represents the composite loss function, used for model parameter optimization.

[0231] Furthermore, S306 includes:

[0232] Iterative optimization is performed using a mini-batch gradient descent strategy. The Adam optimizer is used to adaptively adjust the learning rate, with the initial learning rate set to 0.001. A cosine annealing strategy is also used to dynamically adjust the learning rate to promote convergence.

[0233] Each training batch contains normal samples and defective samples, where defective samples include real defects and generated pseudo-defect samples;

[0234] During training, each iteration includes two stages: forward propagation to calculate the composite loss function and back propagation to update the network parameters. The model weights are updated according to the loss gradient.

[0235] The training process continuously monitors performance metrics on the validation set, such as classification accuracy, recall, and F1 score. When the validation set loss no longer decreases over several consecutive periods or the performance approaches saturation, the training is terminated early to avoid overfitting.

[0236] The final model is saved as a parameter version with optimal verification performance for subsequent practical defect detection tasks.

[0237] Optionally, obtaining the defect detection result in step S4 further includes:

[0238] For the acquired images of non-ferrous metal rolled strip, multi-scale texture enhancement preprocessing is performed to obtain the preprocessed image;

[0239] The preprocessed image is input into the non-ferrous metal rolling defect detection model, and the defect classification prediction probability vector is output.

[0240] Determine whether an image has defects and the type of defects based on the probability vector predicted by defect classification.

[0241] Specifically, after the model training is completed, for newly acquired images of non-ferrous metal rolled strip, the first step is to perform multi-scale texture enhancement preprocessing consistent with the training phase to suppress reflective noise and enhance defect features.

[0242] The preprocessed image is input into the trained defect detection model. Features with geometric adaptability and multi-scale context are extracted by the multi-scale adaptive convolution module. Then, global semantics and local detail information are fused through the dual-stream feature fusion mechanism. Finally, the multi-scale feature pyramid classifier outputs the defect category probability.

[0243] The detection system determines whether an image has defects and the type of defects based on probability output. At the same time, it can combine a threshold judgment mechanism to filter low-confidence predictions and improve the reliability of detection results.

[0244] The test results are fed back to the production control system in real time, enabling online quality monitoring and defect early warning during the calendering production process.

[0245] In one embodiment, the performance of different defect detection methods is compared to evaluate the overall performance difference between the proposed machine vision-based non-ferrous metal rolling defect detection method and existing mainstream methods in defect detection tasks. Five methods were compared: conventional image processing methods, conventional convolutional neural network methods, Faster R-CNN methods, YOLOv5 methods, and the proposed method. Performance metrics included accuracy, recall, and F1 score, reflecting the model's performance in correct classification, defect detection rate, and overall performance, respectively. As shown in the bar chart, the proposed method significantly outperformed other methods in all three metrics, with the bars significantly taller, indicating higher reliability and effectiveness in defect detection tasks. Conventional image processing methods, relying on handcrafted features, had relatively low performance; conventional convolutional neural network methods, while showing some improvement, were limited by fixed convolutional kernels; Faster R-CNN and YOLOv5, as object detection methods, performed well in defect localization, but the proposed method further optimized the feature extraction and classification process through multi-scale texture enhancement and adaptive convolution modules, thus achieving optimal results across all metrics. In the experimental setup, each method was evaluated on the same dataset, with slight random fluctuations added to simulate a real experimental environment to ensure the reliability of the results. The horizontal axis represents the detection method, and the vertical axis represents the performance index value, ranging from 0 to 1, with higher values ​​indicating better performance.

[0246] In this embodiment, as Figure 3 As shown, this paper analyzes the impact of multi-scale parameters on detection performance, studies the influence of scale parameter settings in multi-scale texture enhancement preprocessing on detection performance, and determines the optimal parameter range to maximize defect detection effect. Experiments were conducted by varying the scale parameter from 1 to 8, observing the trends in accuracy and recall. The line graph shows that both accuracy and recall initially increase and then decrease with increasing scale parameter, reaching peak values ​​at scale parameters of four or five. This indicates that a suitable scale parameter can effectively balance noise suppression and defect enhancement, while excessively large or small parameters lead to performance degradation. The multi-scale gradient coherence filtering method of this application enhances the texture of micron-level defects while suppressing reflective interference by extracting features at multiple scales, thus achieving optimal performance under specific parameters. The curves in the figure are not perfectly smooth but exhibit natural fluctuations, reflecting the complexity of parameter tuning in real experiments. In the experimental configuration, the scale parameter is in integer units, the performance index value is between 0 and 1, the vertical axis represents the index value, and the horizontal axis represents the scale parameter value, all dimensionless. The results demonstrate the robustness of the proposed method to parameter changes and the effectiveness of the multi-scale processing strategy.

[0247] In this embodiment, as Figure 4As shown, the detection accuracy of different defect types was compared to verify the detection capability of the proposed method for different types of defects, and its generalization performance was demonstrated by comparing it with conventional methods. The experiment focused on five common defect types: cracks, pits, scratches, oxide spots, and indentations. Grouped bar charts compared the detection accuracy of conventional image processing methods, conventional convolutional neural network methods, and the proposed method. As can be seen from the figures, the accuracy of the proposed method is higher than that of other methods for all defect types, especially for cracks and pits, which is particularly outstanding. This indicates that the multi-scale adaptive convolution and dual-stream feature fusion mechanism of the proposed method can effectively capture the features of irregular shapes and small defects. Conventional methods have lower accuracy for all defect types due to limited feature extraction capabilities; although conventional convolutional neural network methods have made improvements, they are still not as comprehensive as the proposed method. The horizontal axis of the experimental data graph represents the defect type, and the vertical axis represents the detection accuracy, with values ​​between 0 and 1. Higher values ​​indicate higher accuracy, and the results fully demonstrate the superiority and consistency of the proposed method in the detection of various defects.

[0248] In this embodiment, as Figure 5 As shown, the changes in the loss function during training are compared. By monitoring the changes in the loss function during training, the convergence and stability of the proposed method are compared with those of conventional methods to evaluate training efficiency. The experiment shows the loss value change curves of the two methods from the 1st to the 100th training epoch. The line graph shows that the loss value of the proposed method decreases faster and more smoothly, eventually stabilizing at a low level, while the loss value of the conventional method decreases more slowly and fluctuates more, occasionally rebounding. This indicates that the proposed method, through a composite loss function and adaptive optimization strategy, effectively accelerates convergence and improves training stability. The reduction in loss value means that the model has better learned the defective features, reducing the risk of overfitting. In the experimental configuration, the horizontal axis represents the number of training epochs, and the vertical axis represents the loss value, which is dimensionless but represents the output value of the loss function. The experiment demonstrates the advantages of the proposed method in the training process, providing support for its efficient deployment in practical applications.

[0249] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0250] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).

[0251] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0252] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0253] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A machine vision-based method for detecting defects in non-ferrous metal rolling mills, characterized in that, include: S1. For the task of detecting surface defects in non-ferrous metal rolled strip, training data is systematically collected based on actual industrial production lines and a non-ferrous metal dataset is constructed. S2. Enhanced images are obtained by suppressing reflective noise and enhancing real defect edges through multi-scale gradient coherence filtering; S3. Construct and train a non-ferrous metal rolling defect detection model by combining multi-scale feature fusion vectors; S4. Based on the non-ferrous metal rolling defect detection model, the preprocessed image is detected to obtain the defect detection results.

2. The method for detecting defects in non-ferrous metal rolling mills based on machine vision as described in claim 1, characterized in that, The process of collecting training data and constructing the dataset in S1 also includes: Acquire image data of various non-ferrous metal materials; The collected image data is labeled using a labeling tool to generate a binary mask aligned with the image pixels and corresponding category labels; A non-ferrous metal dataset was constructed based on binary masks and corresponding category labels.

3. The method for detecting defects in non-ferrous metal rolling mills based on machine vision as described in claim 1, characterized in that, The enhanced image obtained in S2 by suppressing reflective noise and enhancing real defect edges through multi-scale gradient coherence filtering also includes: S201. Based on the constructed dataset, the value of the feature map at the coordinates is obtained through multi-scale Gaussian smoothing and the Laplacian operator; S202. Calculate the tensor field based on the first-order gradient of the image at each scale, and perform eigenvalue decomposition on the tensor field to obtain the maximum and minimum eigenvalues. Calculate the gradient direction consistency coefficient based on the maximum and minimum eigenvalues. S203. Multiply the Laplacian filter output features at each scale with the gradient coherence coefficients at the corresponding scale, and then perform weighted fusion according to the preset exponential decay weights to obtain the enhanced image.

4. The machine vision-based method for detecting defects in non-ferrous metal rolling as described in claim 3, characterized in that, The enhanced image obtained by weighting and fusing the image according to a preset exponential decay weight in step S203 also includes: ; In the formula, This represents the fusion weight coefficient at the s-th scale; Let be the gradient coherence coefficient of the tensor field at the s-th scale; Indicates the enhanced image in coordinates Pixel value at that location, This indicates an enhanced image, which is a single-channel grayscale image after enhancement. Represents the scale index; S is a preset set of discrete scales.

5. The method for detecting defects in non-ferrous metal rolling mills based on machine vision as described in claim 1, characterized in that, The construction and training of the non-ferrous metal rolling defect detection model in S3 also includes: S301. Adaptive extraction of multi-scale defect features is performed through deformable convolution and multi-scale adaptive convolution modules to form a multi-scale feature map that combines geometric adaptability and multi-scale context. S302. Based on multi-scale feature maps, a global-local dual-branch structure is adopted, and feature modulation is achieved through spatial attention mechanism to obtain dual-stream fusion features that have both global semantics and local details; S303. Based on the principle of metal plastic deformation, synthesize pseudo-defect images that combine realistic appearance and defect morphology. S304. A multi-scale feature pyramid classifier is adopted, and multi-scale feature fusion is performed through a spatial-channel dual attention mechanism to obtain a multi-scale defect feature classifier. S305. A three-stage adaptive loss function is adopted, and a composite loss function is obtained through a dynamic weighting mechanism. S306. The final non-ferrous metal rolling defect detection model is obtained by iterative optimization using a small-batch gradient descent strategy.

6. The method for detecting defects in non-ferrous metal rolling mills based on machine vision as described in claim 5, characterized in that, The formation of a multi-scale feature map with both geometric adaptability and multi-scale context in S301 also includes: S3011. The spatial offset of each sampling point of the convolution kernel is generated by the offset prediction network, the sampling position of the standard convolution kernel is dynamically adjusted, the input feature map is subjected to adaptive convolution operation, and the geometric adaptive features are output through the ReLU activation function. S3012. Dynamically adjust the dilation rate of the dilated convolution according to the current network layer depth, perform multi-receptive field convolution operation on the feature map output by deformable convolution, and extract multi-scale contextual features. S3013: By splicing geometric adaptive features and multi-scale contextual features, a multi-scale feature map with both geometric adaptability and multi-scale contextuality is formed.

7. The method for detecting defects in non-ferrous metal rolling mills based on machine vision as described in claim 5, characterized in that, The process of synthesizing a pseudo-defect image that combines realistic appearance with defect morphology in S303 also includes: S3031. Based on the deformation characteristics of metallic materials, generate crack element models and pit element models respectively. S3032. Randomly rotate the generated crack primitive model and combine it with the pit primitive model through morphological expansion to generate a composite defect mask that simulates the actual metal deformation morphology. S3033. Apply the defect mask to the normal sample image, add Gaussian noise that matches the noise characteristics of metal surface to the defect area, and synthesize a pseudo-defect image that has both realistic appearance and defect shape.

8. The method for detecting defects in non-ferrous metal rolling mills based on machine vision as described in claim 5, characterized in that, The S304 uses a multi-scale feature pyramid classifier, performs multi-scale feature fusion through a spatial-channel dual attention mechanism to obtain a multi-scale defect feature classifier, and also includes: S3041. Convolutionally compress the channel dimension and capture spatial relationships of the multi-scale feature map in sequence, and generate a spatial attention map by using the Sigmoid activation function. S3042. Global average pooling is performed on the dual-stream fusion features to obtain the global feature vector. The channel attention weights for each category are calculated using the trainable weight matrix and bias terms. After normalization by the Softmax function, the channel attention vectors are obtained. S3043. Perform a dot product weighting on the spatial attention maps and channel attention vectors at each scale, and sum the weighted multi-scale features to construct a feature pyramid fusion feature. S3044. Perform convolution and spatial flattening operations on the feature pyramid fusion features, extract auxiliary features of the pseudo-defect image and fuse them according to weights, and then output the defect classification prediction probability vector through the Softmax function.

9. The method for detecting defects in non-ferrous metal rolling mills based on machine vision as described in claim 1, characterized in that, S305 employs a three-stage adaptive loss function, obtaining a composite loss function through a dynamic weighting mechanism, and also includes: S3051. Generate a reflective mask based on the bright areas in the enhanced image, weight the defect classification loss based on the reflective mask, and calculate the surface characteristic loss. S3052. Dynamically adjust the cross-entropy loss weights based on the number of samples of each category in the current training batch, and calculate the sample balance loss. S3053. Calculate the similarity between positive and negative sample features based on cosine distance, control the inter-class distance through boundary margin, and calculate the contrast discrimination loss. S3054. The weighted sum of surface characteristic loss, sample balance loss, and contrast discrimination loss yields the composite loss function, expressed as: ; In the formula, Indicates the surface characteristic loss weight; Indicates the sample balance loss weights; This indicates the weights used to differentiate between loss values; Indicates the comparison and differentiation of losses; Indicates the sample balance loss; Indicates loss of surface properties; This represents the composite loss function.

10. The method for detecting defects in non-ferrous metal rolling mills based on machine vision as described in claim 1, characterized in that, The defect detection result obtained in S4 also includes: For the acquired images of non-ferrous metal rolled strip, multi-scale texture enhancement preprocessing is performed to obtain the preprocessed image; The preprocessed image is input into the non-ferrous metal rolling defect detection model, and the defect classification prediction probability vector is output. Determine whether an image has defects and the type of defects based on the probability vector predicted by defect classification.

Citation Information

Cited By

  • Metal part surface defect classification method based on deep learning

    CN122090187A

  • Pump body casting surface defect intelligent detection method and system

    CN122265291A