Classification method for formation foil appearance defects based on deep convolutional neural network
By using a hybrid detection model based on deep convolutional neural networks, combined with ResNet50 and spatial attention mechanisms, the problems of high false negative rate and insufficient severity quantification in the detection of surface defects on electroforming foils are solved. This achieves efficient defect classification and severity assessment, and improves the stability and computation speed of the model.
Patent Information
- Application Number
- CN202511376138.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-25
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2045-09-25
AI Technical Summary
Existing technologies for detecting surface defects in electroformed foil suffer from high false negative rates, severe quantification deficiencies, and interference from multiple defect couplings. Furthermore, fixed-weight multi-task loss functions struggle to balance the learning progress of classification and regression, impacting model convergence efficiency and the real-time nature of industrial deployment.
A hybrid detection model based on deep convolutional neural networks is adopted, which combines ResNet50 backbone network, global average pooling and spatial attention mechanism. Through one-hot code annotation and adaptive loss function optimization, the classification probability and severity score of defect type are output respectively, and a comprehensive risk score is constructed.
It improves the classification accuracy and stability of appearance defects in electroforming foil, enhances the local representation of low-contrast defects, reduces model parameters, improves computation speed, and optimizes classification reliability.
Smart Images

Figure CN120877002B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of appearance defect classification method, in particular to a classification method for appearance defects of formation foil based on deep convolutional neural network. BACKGROUND
[0002] In the field of formation foil surface defect detection, traditional methods rely on manual inspection or threshold-based image processing algorithms, which have high missed detection rate, insufficient severity quantization, and multi-defect coupling interference problems. Although existing deep learning-based solutions have improved classification accuracy, they generally use single-task models, resulting in poor coupling between defect classification and severity regression tasks. Moreover, the attention mechanism is not adapted to the physical characteristics of defects such as the linear features of cracks and the regional distribution of corrosion, resulting in large deviations in severity scores and process standards. In addition, the fixed weight multi-task loss function is difficult to balance the learning progress of classification and regression, affecting the convergence efficiency of the model and the real-time performance of industrial deployment.
[0003] In the prior art, CN109871906A discloses a method of extracting high-order features of an image by performing hierarchical convolution and pooling operations on the image, and then using a neural network to classify the features, thereby achieving pattern recognition. However, this method can only classify images and cannot output the probability of defect classification and the severity of each type of defect. The model only implements classification functions and is not further optimized. Moreover, the prediction error of the model is not further processed, so there is an urgent need for a more perfect deep learning method for detecting formation foil surface defects.
[0004] The above information disclosed in the background section is only intended to enhance the understanding of the background of the present disclosure, and thus it can include information that does not constitute the prior art known to those of ordinary skill in the art. SUMMARY
[0005] The present application aims to provide a classification method for appearance defects of formation foil based on deep convolutional neural network to solve the problems raised in the background.
[0006] To achieve the above-mentioned purpose, the present application provides the following technical solutions:
[0007] The classification method for appearance defects of formation foil based on deep convolutional neural network includes the following specific steps:
[0008] S1: Obtain a plurality of formation foil image data sets, preprocess the image data sets, and perform one-hot code labeling and severity labeling on the formation foil surface crack, corrosion and wrinkle regions of the preprocessed image data sets, respectively, to form samples of the training data set;
[0009] S2: Construct a hybrid detection model, and use the labeled training data set samples as the input of the model, wherein the hybrid detection model uses ResNet50 as the backbone network, the classification branch performs global average pooling on the feature map output by the backbone network, and the full connection layer outputs the classification probability of the defect type of each global average pooled feature map, wherein the classification probability of the defect type is respectively the classification probability of the surface crack, corrosion and wrinkle defect category of the chemical conversion foil;
[0010] S3: The regression branch of the hybrid detection model generates an attention weight parameter for each feature map by using a spatial attention mechanism, performs weighted calculation on the attention weight parameter, and constructs a severity score factor for each sample;
[0011] S4: Based on the classification probability of the defect type, the severity score factor of each sample and the severity label, a loss function is defined, the loss function includes a regression loss and a classification loss, and the adaptive method is used to adjust the weight parameter of the loss function, and when the loss function is less than the set accuracy threshold, the training of the hybrid detection model is completed;
[0012] S5: Input the chemical conversion foil picture to be detected into the trained hybrid detection model, respectively output the classification probability of the defect type of the surface crack, corrosion and wrinkle of the chemical conversion foil, and construct a comprehensive risk score for each defect type based on the classification probability and the severity score factor, and issue an alarm according to the comprehensive risk score.
[0013] Further, a plurality of chemical conversion foil picture data sets are obtained, and the picture data sets are preprocessed, specifically including the following steps:
[0014] The chemical conversion foil picture image is converted into a gray scale picture, the gray scale picture is standardized, the gray scale pixel value is mapped from [0, 255] to [0, 1], the image gradient after standardization is calculated by using a Sobel operator, adjacent pixels are compared along the gradient direction, and when the gradient is a local maximum value, the gray scale value is set to 1, otherwise it is set to zero; a low threshold is set according to the gradient, a binary image is obtained by using Canny edge detection, including the broken line of the crack, the boundary of the corrosion and the junction of the wrinkle, and the binary image and the image after gray scale and standardization are spliced according to the channel number to generate an enhanced image data set.
[0015] Further, the Sobel operator is used to calculate the image gradient after standardization, the adjacent pixels are compared along the gradient direction, and when the gradient is a local maximum value, the gray scale value is set to 1, otherwise it is set to zero, and a binary image is obtained, specifically including the following steps:
[0016] The horizontal and vertical direction gradients of each pixel point are calculated by using the Sobel operator, the gradient amplitude and direction angle are calculated based on the horizontal and vertical direction gradients of each pixel point, and the gradient amplitude and direction angle are calculated:
[0017]
[0018] wherein,
[0019]
[0020] G (k) (i,j) represents the gradient magnitude of the k-th image at (i,j); θ (k) (i,j) represents the direction angle of the k-th image at (i,j); represents the horizontal gradient of the k-th image at (i,j); represents the vertical gradient of the k-th image at (i,j); i represents the horizontal coordinate index of the pixel; j represents the vertical coordinate index of the pixel; W represents the width of the input image; H represents the height of the input image; k represents the picture index number;
[0021] The gradient direction θ (k) (i,j) is quantized into 4 main directions:
[0022]
[0023] wherein, represents the quantized direction of the k-th image at (i,j);
[0024] According to the quantized direction, the adjacent pixels are compared:
[0025]
[0026] If the gradient of the current pixel is the local maximum, it is reserved as 1, otherwise it is set to zero:
[0027]
[0028] represents the binary pixel of the k-th image at (i,j).
[0029] Further, the binary image and the normalized image are enhanced by attention fusion to generate an enhanced image dataset, specifically including the following steps:
[0030] The normalized gray pixel is represented as:
[0031]
[0032] represents the pixel point at the original (i,j) of the k-th image; represents the maximum pixel point at the original (i,j) of the k-th image; normalized pixel at (i, j) of the kth picture; normalized grayscale map of the kth picture;
[0033] Attention-weighted normalized grayscale pixel with binary pixel as spatial weight:
[0034]
[0035] wherein,
[0036]
[0037] α represents the weight coefficient of the binary map; β represents the baseline weight; enhanced pixel value of the kth picture at pixel point (i, j).
[0038] Further, the pre-processed picture dataset is respectively marked with one-hot code and severity label for the foil surface crack, corrosion and wrinkle area to form a sample of the training dataset, specifically including the following steps:
[0039] For the kth pre-processed image, a defect category vector is generated:
[0040]
[0041] one-hot code label of the kth picture on the cth defect; binary variable indicating whether the kth picture has a crack, 1 for existing and 0 for non-existing; binary variable indicating whether the kth picture has corrosion, 1 for existing and 0 for non-existing; binary variable indicating whether the kth picture has a wrinkle, 1 for existing and 0 for non-existing; c represents the index number of the foil defect category, c = 1 represents that the foil has a crack, c = 2 represents that the foil has corrosion, and c = 3 represents that the foil has a wrinkle;
[0042] The data set is in the form of:
[0043]
[0044] wherein,
[0045]
[0046] complete enhanced image of the kth sample; training dataset sample; severity label of the defect category c; crack severity label of the kth sample; denotes the corrosion severity label of the kth sample; denotes the wrinkle severity label of the kth sample.
[0047] Further, the classification branch outputs the classification probability of the defect type of each global average pooled feature map through global average pooling of the feature map output by the backbone network, and specifically includes the following steps:
[0048] The enhanced image dataset is input into the ResNet50, and multi-scale feature maps are output. The output feature map of the third stage is Global average pooling is performed:
[0049]
[0050] wherein, denotes the value of the feature map F3 of the kth sample at position (i,j); denotes the classification feature map of the kth sample after global average pooling; ResNet50(·) denotes the feature map output by ResNet50;
[0051] The fully connected layer outputs the defect category probability;
[0052]
[0053] wherein, W c denotes the weight vector of the defect category c; b c denotes the bias of the defect category c; denotes the probability that the model predicts that the kth sample belongs to category c; c denotes the index of the anode defect category, 1 indicates that the anode has cracks, 2 indicates that the anode has corrosion, and 3 indicates that the anode has wrinkles.
[0054] Further, the regression branch of the hybrid detection model generates attention weight parameters for each feature map by adopting a spatial attention mechanism, performs weighted calculation on the attention weight parameters, and constructs a severity score factor for each sample. The specific steps are as follows:
[0055] Independent attention is designed for cracks, corrosion and wrinkles of the anode picture respectively:
[0056]
[0057] wherein, denotes the attention weight of the defect category c of the kth sample; W a,c denotes the spatial attention weight matrix of the defect category c; b a,c denotes the spatial attention bias term of the defect category c;
[0058] The attention weight parameter is weighted and calculated to construct the severity score factor:
[0059]
[0060] wherein, represents the severity score factor of the kth sample, W reg,c represents the regression weight matrix of the defect category c.
[0061] The classification probability based on the defect type, the severity score factor of each sample, and the severity label define a loss function, the loss function includes a regression loss and a classification loss, and an adaptive method is used to adjust the weight parameter of the loss function, and the specific steps are:
[0062] The classification loss is defined as:
[0063]
[0064] wherein, y k,c represents the cth defect category component of y (k) ; N represents the number of samples; represents the classification loss function;
[0065] The regression loss is defined as:
[0066]
[0067] wherein, represents the regression loss function;
[0068] The total loss function is:
[0069]
[0070] wherein, represents the current total loss function; represents the weight coefficient of the current classification loss; represents the weight coefficient of the current regression loss;
[0071] The adaptive update rule is:
[0072]
[0073] The training termination condition is:
[0074]
[0075] wherein, ∈ represents a preset accuracy threshold; represents the loss value of the last round of classification task; represents the loss value of the last round of regression task.
[0076] Further, the picture of the formation foil to be detected is input into the trained mixed detection model, and the classification probability and severity score factor of the defect type of the surface crack, corrosion and wrinkle of the formation foil are respectively output;
[0077] The picture of the formation foil to be detected is input into the mixed detection model, and the defect classification probability and corresponding severity score of each picture are output, and the comprehensive risk score of each defect type is defined based on the defect classification probability and corresponding severity score, and is expressed as:
[0078]
[0079] Wherein, The comprehensive risk score of the cth defect is represented as when When the defect type is high risk, when When the defect type is medium risk, and when When the defect type is low risk.
[0080] Compared with the prior art, the beneficial effects of the present application are:
[0081] The spatial attention mechanism and the independent regression weight matrix are adopted, so that the model focuses on the key area according to the physical characteristics of the crack, corrosion and wrinkle while sharing the main features, the classification accuracy of the model is improved, the gradient guided preprocessing module fuses the edge and gray features, enhances the local expression of low contrast defects, and the stability of the model is further improved, the lightweight attention module and the adaptive loss strategy reduce the model parameters, and further improve the operation speed of the model, and through dynamic weight distribution, the optimization direction is adaptively adjusted according to the classification and regression loss order of magnitude, and the classification reliability is preferentially guaranteed. BRIEF DESCRIPTION OF DRAWINGS
[0082] Fig. 1 It is the overall method flowchart of the present application.
[0083] Fig. 2 It is the parameter of the total loss function and the variation of the preset accuracy threshold in the present application. DETAILED DESCRIPTION
[0084] In order to make the purpose, technical scheme and advantages of the present application more clear and explicit, the present application is further described in detail below in combination with specific embodiments.
[0085] It should be noted that the technical terms or scientific terms used in the present application should be the general meaning understood by those skilled in the art unless otherwise defined. The "first", "second" and similar words used in the present application do not represent any order, quantity or importance, but are only used to distinguish different components. "Include" or "contain" and similar words mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connected" or "connected" and similar words are not limited to physical or mechanical connection, but can include electrical connection, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to represent the relative positional relationship, when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0086] Embodiment:
[0087] Please refer to Figs. 1-2 The present application provides a technical solution:
[0088] The classification method of the formation foil appearance defect based on the deep convolutional neural network, the specific steps include:
[0089] S1: Obtain a plurality of formation foil picture data sets, pre-process the picture data sets, and respectively perform one-hot code labeling and severity labeling on the formation foil surface cracks, corrosion and wrinkle regions of the pre-processed picture data sets to form samples of the training data set;
[0090] The obtaining of the plurality of formation foil picture data sets, the pre-processing of the picture data sets, specifically includes the following steps:
[0091] The formation foil picture image is converted into a gray scale picture, and the gray scale picture is standardized. The steps of the standardization processing are to normalize the gray scale image pixel value; the sobel operator is used to calculate the gradient of the standardized image, the adjacent pixels are compared along the gradient direction, the gray scale value is set to 1 when the gradient is the local maximum value, otherwise it is set to zero, and a binary image is obtained; the binary image and the image after standardization are enhanced by attention fusion to generate an enhanced image data set.
[0092] The sobel operator is used to calculate the gradient of the standardized image, the adjacent pixels are compared along the gradient direction, the gray scale value is set to 1 when the gradient is the local maximum value, otherwise it is set to zero, and a binary image is obtained, specifically including the following steps:
[0093] The sobel operator is used to calculate the horizontal and vertical direction gradient of each pixel point, and the gradient amplitude and direction angle are calculated based on the horizontal and vertical direction gradient of each pixel point. The gradient amplitude and direction angle are calculated:
[0094] The sobel operator is used to calculate the horizontal and vertical direction gradient of each pixel point, and the gradient amplitude and direction angle are calculated based on the horizontal and vertical direction gradient of each pixel point. The gradient amplitude and direction angle are calculated:
[0095] where G (k) (i,j) represents the gradient magnitude of the k-th image at (i,j); θ (k) (i,j) represents the direction angle of the k-th image at (i,j); represents the horizontal gradient of the k-th image at (i,j); represents the vertical gradient of the k-th image at (i,j); i represents the horizontal coordinate index of the pixel; j represents the vertical coordinate index of the pixel; k represents the picture index number;
[0096] The gradient direction θ (k) (i,j) is quantized into 4 main directions:
[0097]
[0098] where, represents the quantized direction of the k-th image at (i,j);
[0099] According to the quantized direction, the adjacent pixels are compared:
[0100]
[0101] If the gradient of the current pixel is the local maximum, it is kept as 1, otherwise it is set to 0:
[0102]
[0103] represents the binary pixel of the k-th image at (i,j);
[0104] The binary image of the whole picture can be represented as:
[0105]
[0106] where, represents the binary image of the k-th image; W represents the width of the input image; H represents the height of the input image.
[0107] The horizontal and vertical direction gradients of each pixel point are calculated by using the sobel operator:
[0108]
[0109] where,
[0110]
[0111] S x represents the horizontal sobel kernel matrix; S y represents the vertical sobel kernel matrix; denotes the normalized pixel value of the kth image at (i, j).
[0112] In the above process, by horizontal / vertical gradient separation calculation, while retaining the anti-noise ability of the traditional Sobel operator, a pixel-level direction gradient field is established, providing a physical basis for subsequent direction quantization; by using gradient amplitude non-maximum suppression strategy, the comparison range of adjacent pixels is selected by quantizing the direction, effectively suppressing the false edge response, and the edge is refined to a single pixel level; the continuous direction angle is discretized into four main directions, which reduces the direction comparison operation amount on the premise of ensuring the direction resolution; the structured edge map is generated by binaryzation mapping, which eliminates the influence of light intensity difference on subsequent defect recognition and improves the robustness of the algorithm.
[0113] The binary image and the image after normalization are enhanced by attention fusion to generate an enhanced image dataset, specifically including the following steps:
[0114] The normalized gray pixel is represented as:
[0115]
[0116] denotes the pixel point at (i, j) of the kth image; denotes the maximum pixel point at (i, j) of the kth image; denotes the normalized pixel at (i, j) of the kth image; denotes the normalized gray image of the kth image;
[0117] The binary pixel is used as a spatial weight to perform attention weighting on the normalized gray pixel:
[0118]
[0119] wherein,
[0120]
[0121] α denotes the weight coefficient of the binary image; β denotes the baseline weight; denotes the enhanced pixel value of the kth image at the pixel point (i, j).
[0122] In the above process, denotes the enhanced pixel value of the kth image at the pixel point (i, j), which is obtained by fusing the edge information of the binary image, i.e. and the normalized original image gray information, i.e. represents generating an enhanced image, the enhanced image highlights the edge features of the defect area such as cracks, corrosion and wrinkles, while retaining the overall brightness information; alpha represents the weight coefficient of the binary image, which controls the contribution of the binary image to the final enhanced image; a larger alpha will strengthen the edge area, that is, increase the weight of the pixels with a value of 1 in the binary image; a smaller alpha will weaken the edge and retain the original image information; beta represents the baseline weight, which ensures that the weighted sum of all pixels satisfies alpha·binary average activation value+1, maintains the stability of the overall brightness of the image, and prevents global brightness imbalance caused by excessive enhancement of the edge area;
[0123] The pre-processed picture data set is subjected to one-hot code labeling and severity labeling of the formation foil surface crack, corrosion and wrinkle area respectively to form a sample of a training data set, specifically including the following steps:
[0124] For the kth pre-processed image, a defect category vector is generated:
[0125]
[0126] represents the one-hot code label of the kth picture on the cth defect; represents the existence annotation of the crack of the kth picture, 1 for existence and 0 for nonexistence; represents the existence annotation of the corrosion of the kth picture, 1 for existence and 0 for nonexistence; represents the existence annotation of the wrinkle of the kth picture, 1 for existence and 0 for nonexistence; c represents a defect category identifier, c=1 represents a formation foil crack, c=2 represents a formation foil corrosion, and c=3 represents a formation foil wrinkle;
[0127] The data set is in the form of:
[0128]
[0129] wherein,
[0130]
[0131] represents a complete enhanced image of the kth sample; represents a training data set sample; represents the severity annotation of the defect category c; represents the crack severity annotation of the kth sample; represents the corrosion severity annotation of the kth sample; represents the wrinkle severity annotation of the kth sample;
[0132] S2: a mixed detection model is constructed, and the labeled training data set sample is used as the input of the model, wherein the mixed detection model adopts ResNet50 as the backbone network, the classification branch performs global average pooling on the feature map output by the backbone network, and a full connection layer outputs the classification probability of the defect type of each global average pooled feature map, wherein the classification probability of the defect type is respectively the probability of the anode foil surface crack, corrosion, and wrinkle defect category;
[0133] The classification branch performs global average pooling on the feature map output by the backbone network, and a full connection layer outputs the classification probability of the defect type of each global average pooled feature map, and the specific steps include the following steps:
[0134] The enhanced image data set is input into ResNet50, and a multi-scale feature map is output, and the output feature map of the third stage is global average pooling is performed:
[0135]
[0136] wherein W represents the width of the input image; H represents the height of the input image; F3(k)(i,j) represents the value of the feature map F3 of the kth sample at position (i,j); F3(k) represents the classification feature map of the kth sample after global average pooling; ResNet50(·) represents the feature map output by ResNet50;
[0137] The full connection layer outputs the defect category probability;
[0138]
[0139] wherein W c Wc represents the weight vector of the defect category c; b c b represents the bias of the defect category c; Pc(k) represents the probability that the kth sample belongs to the cth category; c represents the anode foil defect category index, 1 represents that the anode foil appears cracks, 2 represents that the anode foil appears corrosion, and 3 represents that the anode foil appears wrinkles.
[0140] S3: the regression branch of the mixed detection model generates an attention weight parameter of each feature map by adopting a spatial attention mechanism, performs weighted calculation on the attention weight parameter, and constructs a severity score factor of each sample;
[0141] The regression branch of the mixed detection model generates an attention weight parameter of each feature map by adopting a spatial attention mechanism, performs weighted calculation on the attention weight parameter, and constructs a severity score factor of each sample, and the specific steps are as follows:
[0142] Respective cracks, corrosion and wrinkles of the formed foil picture are designed with independent attention:
[0143]
[0144] wherein, represents the attention weight of the defect category c of the kth sample; W a,c represents the spatial attention weight matrix of the defect category c; b a,c represents the spatial attention bias term of the defect category c.
[0145] The attention weight parameters are weighted calculated to construct the severity score factor:
[0146]
[0147] wherein, represents the severity score factor of the kth sample; W reg,c represents the regression weight matrix of the defect category c.
[0148] S4: based on the classification probability of the defect type, the severity score factor of each sample and the severity label, a loss function is defined, the loss function includes regression loss and classification loss, the weight parameters of the loss function are adjusted by adaptive method, when the loss function is less than the set accuracy threshold, the training of the mixed detection model is completed;
[0149] The classification probability of the defect type, the severity score factor of each sample and the severity label are used to define a loss function, the loss function includes regression loss and classification loss, the weight parameters of the loss function are adjusted by adaptive method, and the specific steps are:
[0150] The classification loss is defined:
[0151]
[0152] wherein, y k,c represents the cth defect category component of y (k) ; N represents the number of samples; represents the classification loss function;
[0153] In the above formula, for each sample k, all defect types thereof are traversed, and binary cross entropy loss thereof is calculated respectively, if the kth sample exists cth defect, i.e. y k,c =1, the loss term is encouraging the model to improve the prediction probability; if it does not exist, i.e. y k,c =0, the loss term is The model encourages the reduction of prediction probability; the average classification loss is obtained by summing the loss of all samples and all categories and dividing by the total number of samples N; multiple defects such as cracks and corrosion exist in each sample, and the binary cross entropy of each type of defect is calculated independently to support the multi-label scenario and avoid the mutual exclusion restriction of traditional multi-classification; the loss function automatically balances the learning direction by weighting the contributions of positive and negative samples;
[0154] The regression loss is defined as:
[0155]
[0156] wherein, represents the regression loss function;
[0157] In the above formula, for each sample k, all defect types of the sample k are traversed, and only when the sample k has the cth defect, i.e., y k,c =1, the square error of the predicted value and the true value of the defect is calculated; if there is no defect, i.e., y k,c =0, the contribution of this item is 0; the square error of all samples and all defect types is summed and divided by the total number of samples N to obtain the average regression loss; the severity score of each defect type is calculated independently to avoid interference between different types of defects.
[0158] The total loss function is:
[0159]
[0160] wherein, represents the total loss function; represents the weight coefficient of the current classification loss; represents the weight coefficient of the current regression loss;
[0161] The adaptive update rule is:
[0162]
[0163] The training termination condition is:
[0164]
[0165] wherein, ∈ represents a preset accuracy threshold; represents the loss value of the last round of classification task; represents the loss value of the last round of regression task.
[0166] In the above formula, if the classification loss of the last round is significantly greater than the regression loss , the classification task weight of the current round is increased, and the model prioritizes optimizing the classification performance; if the regression loss dominates, then automatically increases, and the learning of the regression task is strengthened; the weight coefficient satisfies and the weight value is always located in the interval (0, 1), which ensures that the gradient magnitude of the loss of the two tasks is controllable, avoiding the explosion or disappearance of the gradient of a certain task.
[0167] In the above embodiment, through the dynamic updating of the parameters and , the total loss function is continuously adjusted to approach the preset accuracy threshold, until it is less than the preset accuracy threshold, and the training is completed. Table 1 shows the changes of a series of regression parameters and classification parameters:
[0168] Table 1: Relationship table between total loss function and preset accuracy threshold
[0169]
[0170] As can be seen from the above table, with the changes of the classification loss and the regression loss of the last round, the current classification loss and the regression loss are continuously reduced until they reach a balance. The total loss quantity continuously decreases from the initial 0.52, which conforms to the gradient descent optimization characteristics. Finally, it reaches 0.03 in the 6th round, triggering the training termination condition. The classification and regression loss converge synchronously, indicating that the model does not have a bias phenomenon in multi-task learning.
[0171] S5: input the to-be-detected chemical conversion foil picture into the trained hybrid detection model, respectively output the classification probability and severity score factor of the defect type of the chemical conversion foil surface crack, corrosion and wrinkle, construct a comprehensive risk score of each defect type based on the classification probability and severity score factor, and issue an alarm according to the comprehensive risk score. The specific steps of inputting the to-be-detected chemical conversion foil picture into the trained hybrid detection model and respectively outputting the classification probability and severity score factor of the defect type of the chemical conversion foil surface crack, corrosion and wrinkle are as follows:
[0172] input the to-be-detected chemical conversion foil picture into the hybrid detection model, output the defect classification probability and corresponding severity score of each picture, define the comprehensive risk score of each defect type based on the defect classification probability and corresponding severity score, and express it as:
[0173]
[0174] wherein, represents the comprehensive risk score of the cth defect type. When , it means that the defect type is high risk; when , it means that the defect type is medium risk; and when , it means that the defect type is low risk.
[0175] The comprehensive risk score of the cth defect, which quantifies the risk level of the defect by fusing the classification probability and the severity score factor; The classification probability of the cth defect by the model, the greater the value, the higher the confidence of the existence of the defect, directly affecting The baseline risk; The severity score of the cth defect, the greater the value, the greater the harm of the defect to the product quality, directly amplifying the actual impact of the risk; the two are coupled through the product relationship, reflecting the joint contribution of the “existence probability” and the “severity” to the comprehensive risk, and one is indispensable. And And Both show a strict positive correlation, when the classification probability Increases, or Increases, Must increase, otherwise decrease.
[0176] The above formulas are all dimensionless numerical calculations, and the formulas are obtained by software simulation of a large amount of data to obtain the most recent real situation. The preset parameters in the formula are set by the person skilled in the art according to the actual situation.
[0177] The above embodiments can be realized wholly or partially by software, hardware, firmware or any combination thereof. When realized by software, the above embodiments can be realized in the form of a computer program product wholly or partially. Those skilled in the art can realize that the units and algorithm steps of the examples described in connection with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are realized by hardware or software methods depends on the specific application and design constraints of the technical solutions.
[0178] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, which can be located in one place or distributed on multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiments.
[0179] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application.
Claims
1. A method for classifying formation foil appearance defects based on a deep convolutional neural network, characterized by the steps of The method comprises the following steps: S1: obtaining a plurality of rolled foil picture data sets, preprocessing the picture data sets, respectively performing one-hot code labeling and severity labeling on the surface crack, corrosion and wrinkle regions of the preprocessed picture data sets, and constructing sample of the training data set; S2: constructing a mixed detection model, and taking the labeled training data set sample as the input of the model, wherein the mixed detection model adopts ResNet50 as the backbone network, the classification branch performs global average pooling on the feature map output by the backbone network, and the full connection layer respectively outputs the classification probability of each global average pooled feature map defect type; the classification probability of the defect type is respectively the rolled foil surface crack, corrosion and wrinkle defect type probability; S3: the regression branch of the mixed detection model generates attention weight parameters of each feature map by adopting a spatial attention mechanism, performs weighted calculation on the attention weight parameters, and constructs a severity score factor of each sample; S4: defining a loss function based on the classification probability of the defect type, the severity score factor of each sample and the severity labeling, the loss function comprises a regression loss and a classification loss, and the weight parameters of the loss function are adjusted by using an adaptive method; when the loss function is less than a set accuracy threshold, the training of the mixed detection model is completed; S5: inputting the rolled foil picture to be detected into the trained mixed detection model, respectively outputting the classification probability of the defect type of the rolled foil surface crack, corrosion and wrinkle, and constructing a comprehensive risk score of each defect type based on the classification probability and the severity score factor, and issuing an alarm according to the comprehensive risk score; The preprocessing of the picture data set comprises the following steps: The rolled foil picture image is converted into a gray scale picture, and the gray scale picture is standardized. The standardization process comprises normalizing the gray scale image pixel value; the gradient of the standardized image is calculated by using a sobel operator, adjacent pixels are compared along the gradient direction, the gray scale value is set to 1 when the gradient is a local maximum value, otherwise it is set to 0, and a binary image is obtained; the binary image and the image after standardization are enhanced by attention fusion to generate an enhanced image data set. 2.The method of claim 1, wherein, The gradient of the standardized image is calculated by using a sobel operator, adjacent pixels are compared along the gradient direction, the gray scale value is set to 1 when the gradient is a local maximum value, otherwise it is set to 0, and a binary image is obtained, which comprises the following steps: The horizontal and vertical direction gradients of each pixel point are calculated by using a sobel operator, the gradient amplitude and direction angle are calculated based on the horizontal and vertical direction gradients of each pixel point, and the gradient amplitude and direction angle are calculated: Wherein, G (k) (i,j) represents the gradient magnitude of the kth image at (i,j); θ (k) (i,j) represents the direction angle of the kth image at (i,j); represents the horizontal gradient of the kth image at (i,j); represents the vertical gradient of the kth image at (i,j); i represents the horizontal coordinate index of the pixel point; j represents the vertical coordinate index of the pixel point; W represents the width of the input image; H represents the height of the input image; k represents the picture index number; The gradient direction θ (k) (i,j) is quantized into 4 main directions: wherein, denotes the quantization direction of the k-th image at (i,j). Adjacent pixels are compared according to the quantization direction: If the current pixel gradient is a local maximum, it is kept as 1, otherwise it is set to 0: represents the binarized pixel at (i, j) of the kth picture. 3.The method of claim 1, wherein, The standardized gray scale pixel is represented as: The binary pixel is used as a spatial weight, and the attention weighted standardization gray scale pixel is obtained: represents a pixel point at original (i, j) of the kth picture; represents a maximum pixel point at original (i, j) of the kth picture; represents a normalized pixel at (i, j) of the kth picture; represents a normalized gray image of the kth picture; Wherein, a represents the weight coefficient of the binary image; b represents the baseline weight; represents the enhanced pixel value of the kth picture at the pixel point (i, j). 4.The method of claim 1, wherein, The pre-processed picture data set is respectively marked by a one-hot code and a severity label for the formation foil surface crack, corrosion and wrinkle area, to form a sample of a training data set, and specifically includes the following steps: For the kth pre-processed image, a defect category vector is generated: represents a one-hot code label for the kth picture on the cth class of defects; represents a presence annotation of a crack for the kth picture, 1 for present, 0 for absent; represents a presence annotation of corrosion for the kth picture, 1 for present, 0 for absent; represents a presence annotation of a wrinkle for the kth picture, 1 for present, 0 for absent; c represents a defect class identifier, c = 1 represents a wafer crack, c = 2 represents a wafer corrosion, c = 3 represents a wafer wrinkle; The data set is in the form of: Wherein, denotes a complete augmented image of the k-th sample; denotes a training dataset sample; denotes a severity annotation of a defect class c; denotes a crack severity annotation of the k-th sample; denotes a corrosion severity annotation of the k-th sample; denotes a wrinkle severity annotation of the k-th sample. 5.The method of claim 1, wherein, The classification branch outputs the classification probability of the defect type of each global average pooling feature map through global average pooling of the feature map output by the backbone network, and specifically includes the following steps: The enhanced image dataset is input into the ResNet50, and a multi-scale feature map is output. The output feature map of the third stage is input into the global average pooling layer global average pooling is performed: wherein, denotes a feature value of the feature map F3 of the kth sample at position (i, j); denotes the classification feature map of the kth sample after global average pooling; ResNet50(·) denotes a feature map output by ResNet50; The full connection layer outputs the defect category probability; where Wc represents the weight vector of the defect category c; b c represents the bias of the defect category c. c represents the bias of the defect category c. represents the probability that the model predicts the kth sample belongs to the c category; c represents the index of the lithium metal anode foil defect category, 1 represents that the lithium metal anode foil appears cracks, 2 represents that the lithium metal anode foil appears corrosion, and 3 represents that the lithium metal anode foil appears wrinkles. 6.The method of claim 1, wherein, The regression branch of the hybrid detection model generates an attention weight parameter for each feature map by using a spatial attention mechanism, performs weighted calculation on the attention weight parameter, and constructs a severity score factor for each sample, and the specific steps are as follows: Independent attention is designed for the crack, corrosion and wrinkle of the formation foil picture: wherein, denotes the attention weight of the defect class c for the k-th sample; W a,c denotes the spatial attention weight matrix of the defect class c; b a,c denotes the spatial attention bias term of the defect class c. The attention weight parameter is weighted calculated to construct the severity score factor: wherein, denotes the severity score factor for the kth sample, W reg,c denotes the regression weight matrix for defect class c. 7.The method of claim 1, wherein, Based on the classification probability of the defect type, the severity score factor of each sample and the severity label, a loss function is defined, the loss function includes a regression loss and a classification loss, the weight parameter of the loss function is adjusted by using an adaptive method, and the specific steps are as follows: The classification loss is defined: where N represents the number of samples; denotes a classification loss function; The regression loss is defined: wherein, denotes a regression loss function; The total loss function is: wherein, represents the current total loss function; represents a weight coefficient of the current classification loss; represents a weight coefficient of the current regression loss; The adaptive update rule is: The training termination condition is: Wherein, ∈ represents a preset accuracy threshold; represents a loss value of the previous classification task; represents a loss value of the previous regression task. 8.The method of claim 1, wherein, The formation foil picture to be detected is input into the trained hybrid detection model, and the classification probability of the defect type of the formation foil surface crack, corrosion and wrinkle and the severity score factor are respectively output; The formation foil picture to be detected is input into the hybrid detection model, and the defect classification probability and the corresponding severity score of each picture are output, based on the defect classification probability and the corresponding severity score, the comprehensive risk score of each defect type is defined and expressed as: wherein, represents the overall risk score for the cth type of defect, when then the defect type is high risk; when then the defect type is medium risk; and when then the defect type is low risk.
Citation Information
Patent Citations
Bobbin yarn appearance defect classification method based on a deep convolutional neural network
CN109871906A
Pavement defect detection method and system based on infrared thermal imaging
CN118967573A
Textile fabric product defect detection method and system
CN119290896A