Method and system for detecting paint surface defects of water-based paint

By improving the YOLOv8 model, the attention mechanism module and AFM module are introduced, the problems of low accuracy and slow efficiency in the detection of defects in water-based coatings are solved, and high-precision automatic detection is achieved to adapt to complex environmental conditions.

CN120219349APending Publication Date: 2025-06-27HOHAI UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510343491.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-21
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

The prior art has problems of low detection accuracy, slow efficiency and high cost in the detection of water-based coating paint defects, especially in the detection of complex defects and different environmental conditions, which are difficult to accurately identify and classify.

Method used

By improving the YOLOv8 model, the attention mechanism module and AFM module are introduced to enhance the ability to extract paint defect characteristics, establish clear defect judgment standards, and achieve high-precision automatic detection of various types of defects.

Benefits of technology

It improves detection accuracy and efficiency, can more accurately identify and classify complex defects, adapt to the surface and environmental conditions of different batches of paints, and reduces the cost and error of manual inspection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120219349A_ABST
    Figure CN120219349A_ABST
Patent Text Reader

Abstract

The invention discloses a method and a system for detecting paint surface defects of a water-based paint. The method comprises the following steps: acquiring a paint surface image of a to-be-detected water-based paint; inputting the paint surface image of the water-based paint to be detected into the trained paint surface defect detection model to obtain a paint surface defect treatment graph; judging whether the paint surface of the to-be-detected water-based paint has flaws or not, the type of the flaws and the severity of the flaws according to the paint surface flaw treatment graph; the paint surface flaw detection model is obtained by improving a YOLOv8 model, and the YOLOv8 model comprises a backbone network, a neck network and a head network which are connected in sequence; replacing a Concat layer in an up-sampling stage in the neck network with an AFM module, and adding an attention mechanism module between the backbone network and the neck network and behind a C2f layer of the neck network to obtain a paint surface flaw detection model; according to the invention, flaw detection precision and detection efficiency can be effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of coating surface quality detection, and particularly to a method and system for detecting defects on the surface of waterborne coatings. Background Art

[0002] With the increasingly stringent environmental protection requirements, waterborne coatings, due to their low volatile organic compound (VOC) content and excellent environmental friendliness, play an increasingly important role in industrial production and have become a key force in promoting the development of green manufacturing. However, during the spraying process of waterborne coatings, due to their leveling property, adhesion and other characteristics, surface defects such as sagging, blistering, orange peel, and pinholes are likely to occur. These surface defects not only damage the appearance quality of the product, but more seriously, they weaken the anti-corrosion performance of the coating, making the product more vulnerable to erosion when facing corrosive media, and the service life and reliability of the product will be seriously affected, thereby reducing its market competitiveness. Therefore, the accurate detection of defects on the surface of waterborne coatings is crucial.

[0003] Currently, the following methods are mainly used for detecting defects on the surface of waterborne coatings in the industrial field: The first is the traditional manual visual inspection method. This method relies on the experience and judgment ability of inspectors, and there are problems such as inconsistent detection standards, large differences in judgment results among different inspectors, and low detection accuracy. At the same time, inspectors are prone to visual fatigue, resulting in a significant decline in detection efficiency and accuracy over time, and the labor cost is high, making it difficult to meet the needs of large-scale production. The second is the automatic detection method based on machine vision. Such systems usually use fixed threshold segmentation or traditional image processing algorithms for defect recognition; the so-called fixed threshold detection means setting a grayscale value or color difference threshold in advance, and after binarizing the image, the defect area is recognized; however, due to the characteristics of defects on the surface of waterborne coatings, such as diverse shapes, low contrast, blurred boundaries with the normal surface, and sensitivity to lighting conditions, this method is difficult to accurately identify and classify complex defects, especially on the surfaces of coatings of different batches or under changing environmental conditions. Summary of the Invention

[0004] The purpose of the present invention is to provide a method and system for detecting defects on the surface of waterborne coatings. By improving the YOLOv8 model, introducing an attention mechanism module and an AFM module to enhance the ability to extract defect features on the coating surface, and establishing clear defect determination criteria, high-precision automatic detection of various types of defects is achieved, effectively improving the detection accuracy and detection efficiency.

[0005] To achieve the above purpose, the present invention is implemented by adopting the following technical solutions:

[0006] In the first aspect, the present invention provides a method for detecting defects on the surface of waterborne coatings, including:

[0007] Obtain the image of the waterborne coating paint surface to be detected; input the image of the waterborne coating paint surface to be detected into the trained paint surface defect detection model to obtain the paint surface defect processing map; judge whether there are defects, the type of defects and the severity of the defects on the waterborne coating paint surface to be detected according to the paint surface defect processing map; the paint surface defect detection model is improved based on the YOLOv8 model, and the YOLOv8 model includes a backbone network, a neck network and a head network connected in sequence; replace the Concat layer in the upsampling stage of the neck network with an AFM module, and add an attention mechanism module between the backbone network and the neck network and after the C2f layer of the neck network to obtain the paint surface defect detection model.

[0008] Optionally, the backbone network includes a convolutional layer, four stage modules and an SPFF layer connected in sequence; according to the connection order of the backbone network, the second stage module is connected to the attention mechanism module for outputting a small-scale feature map with enhanced attention, and the third stage module is connected to the attention mechanism module for outputting a medium-scale feature map with enhanced attention; the SPFF layer is connected to the attention mechanism module for outputting a large-scale feature map with enhanced attention; wherein, each of the four stage modules includes a convolutional layer and a C2f layer connected in sequence.

[0009] Optionally, the neck network includes an upsampling stage and a downsampling stage. Among them, the upsampling stage includes a first upsampling module and a second upsampling module connected in sequence. Both the first upsampling module and the second upsampling module include an upsampling layer, a Concat layer and a C2f layer connected in sequence; replace the Concat layer in the upsampling stage with an AFM module, and add an attention mechanism module after the C2f layer of the upsampling stage to obtain the improved upsampling stage, that is, the improved first upsampling module and the first downsampling module;

[0010] In the improved first upsampling module, the upsampling layer receives the large-scale feature map with enhanced attention and performs upsampling to obtain feature map A1; the AFM module performs feature fusion on feature map A1 and the medium-scale feature map with enhanced attention to obtain feature map A2; feature map A2 is processed by the C2f layer and the attention mechanism module in sequence to obtain feature map F1;

[0011] In the improved first upsampling module: the upsampling layer receives feature map F1 and performs upsampling to obtain feature map B1; the AFM module performs feature fusion on feature map B1 and the small-scale feature map with enhanced attention to obtain feature map B2; feature map B2 is processed by the C2f layer and the attention mechanism module in sequence to obtain feature map T1.

[0012] Optionally, the downsampling stage includes a first downsampling module and a second downsampling module connected in sequence. Both the first downsampling module and the second downsampling module include a convolutional layer, a Concat layer, and a C2f layer connected in sequence. An attention mechanism module is added after the C2f layer in the downsampling stage to obtain an improved downsampling stage, that is, an improved first downsampling module and a second downsampling module.

[0013] In the improved first downsampling module, the convolutional layer receives the feature map T1 and performs convolution to obtain the feature map C1. The Concat layer performs row feature fusion on the feature map C1 and the feature map F1 to obtain the feature map C2. The feature map C2 is processed by the C2f layer and the attention mechanism module in sequence to obtain the feature map T2.

[0014] In the improved second downsampling module, the convolutional layer receives the feature map T2 and performs convolution to obtain the feature map D1. The Concat layer performs row feature fusion on the feature map D1 and the large-scale feature map enhanced by attention to obtain the feature map D2. The feature map D2 is processed by the C2f layer and the attention mechanism module in sequence to obtain the feature map T3.

[0015] Optionally, the AFM module includes a first branch module, a second branch module, and an output module. The first branch module includes an average pooling layer, a bottleneck layer, and an activation function layer two connected in sequence, and is used to take the concatenation of two feature maps as the input, and obtain the first branch output after being processed by the first branch module. The second branch module includes a bottleneck layer and an activation function layer two, and is used to take the concatenation of two feature maps as the input, and obtain the second branch output after being processed by the second branch module. The bottleneck layer includes a convolutional layer one, an activation function layer one, and a convolutional layer one connected in sequence. The output module is used to add the product results of the two feature maps with the first branch output and the second branch output respectively to obtain the output result of the AFM module.

[0016] Optionally, the data processing expression of the AFM module is as follows:

[0017] ;

[0018] ;

[0019] ;

[0020] Among them, represents the output result of the AFM module; and respectively represent two feature maps; and respectively represent the first branch output and the second branch output; represents element-wise multiplication, Indicates element addition; cat indicates the concatenation operation; Avg indicates the average pooling operation; SiLU indicates the activation function in the first activation function layer; Sigmiod indicates the activation function in the second activation function layer; Conv 1×1 Indicates the convolution operation of the first convolutional layer.

[0021] Optionally, the training process of the paint surface defect detection model includes:

[0022] S01: Obtain a dataset of waterborne paint surface images;

[0023] S02: Perform defect category annotation and data augmentation on the dataset of waterborne paint surface images to obtain a preprocessed dataset of waterborne paint surface images;

[0024] S03: Divide the preprocessed dataset of waterborne paint surface images into a training set, a test set, and a validation set;

[0025] S04: Input the training set data into the paint surface defect detection model for training, and adjust the model parameters using the loss function during the training process; input the validation set data into the paint surface defect detection model for validation to obtain a validation result, and adjust the hyperparameters according to the validation result;

[0026] S05: Use the test set data as input to test the paint surface defect detection model to obtain a test result, calculate evaluation metrics based on the test result. If the evaluation metrics are higher than the preset value, the training is completed to obtain a trained paint surface defect detection model. If the evaluation metrics are lower than the preset value, repeat the above S04 - S05 until the evaluation metrics are higher than the preset value to obtain a trained paint surface defect detection model.

[0027] Optionally, the formula of the loss function is expressed as follows:

[0028] ;

[0029] ;

[0030] ;

[0031] ;

[0032] Among them, is the loss function; are the detection loss, classification loss, and regression loss respectively; are the weight coefficients of the detection loss, classification loss, and regression loss respectively; IOU is the intersection over union of the detection box and the ground truth box; are the coordinates of the predicted bounding box; are the coordinates of the ground truth bounding box; is the Euclidean distance between the center points of the detection box and the ground truth box; is the diagonal length of the minimum bounding rectangle of the detection box; is the aspect ratio consistency metric term of the detection box; is the weight coefficient; is the predicted probability of the target category; is the modulation factor, which is used to adjust the loss weights of easy and hard samples in the training set; is the balance factor, which is used to balance the positive and negative sample ratios in the training set; is the predicted point coordinate value; is the ground truth point coordinate value; is the L1 norm, which is used to calculate the absolute difference between the predicted value and the ground truth value.

[0033] Optionally, during the training process of the paint surface defect detection model, a deep Q-network is also used to optimize the hyperparameters of the paint surface defect detection model to obtain the optimal hyperparameters, including:

[0034] Confirm the target parameters to be optimized by the deep Q-network and initialize the target parameters; the target parameters are the hyperparameters of the paint surface defect detection model, including the detection threshold, the bounding box regression coefficient, and the feature fusion weight;

[0035] Define the state space, action space, and reward function;

[0036] Input the target parameters into the deep Q-network for training, and use the Q-network loss function to optimize the variables of the deep Q-network to obtain the optimal target parameters, that is, the optimal hyperparameters.

[0037] In a second aspect, a waterborne paint surface defect detection system based on the threshold of a biomimetic human eye includes:

[0038] A data acquisition module, which is used to acquire the waterborne paint surface image to be detected;

[0039] A defect detection module, which is used to input the waterborne paint surface image to be detected into the trained paint surface defect detection model to obtain a paint surface defect processing map;

[0040] A defect judgment module, which is used to judge whether there are defects, the defect type, and the severity of the defects on the waterborne paint surface to be detected according to the paint surface defect processing map.

[0041] Compared with the prior art, the beneficial effects achieved by the present invention are:

[0042] The present invention provides a method and system for detecting defects on the surface of waterborne coatings. The method inputs an image of the waterborne coating surface to be detected into a paint surface defect detection model improved based on the YOLOv8 model to obtain a paint surface defect processing diagram, and determines whether there are defects, the type of defects, and the severity of the defects on the waterborne coating surface to be detected according to the paint surface defect processing diagram, improving the accuracy of defect recognition and the processing efficiency.

[0043] The present invention provides a method for detecting defects on the surface of waterborne coatings. Compared with the YOLOv8 model, the paint surface defect detection model proposed by the present invention replaces the Concat layer in the upsampling stage of the neck network of the YOLOv8 model with an AFM module, and adds an attention mechanism module between the backbone network and the neck network of the YOLOv8 model and after the C2f layer of the neck network, which not only improves the attention ability of the paint surface defect detection model to subtle defect features, but also can perform multi-scale fusion of defect features, improving the detection accuracy and generalization ability of the paint surface defect detection model.

[0044] The present invention provides a method for detecting defects on the surface of waterborne coatings. The loss function set during the training process of the paint surface defect detection model includes three aspects: detection loss, classification loss, and regression loss, ensuring that the model can achieve good results in terms of detection accuracy, classification accuracy, and localization accuracy. This joint optimization strategy echoes the bionic human eye mechanism because the human eye also performs multiple tasks such as position perception, type recognition, and precise localization during defect detection, improving the detection accuracy.

[0045] The present invention provides a method for detecting defects on the surface of waterborne coatings. During the training process of the paint surface defect detection model, a deep Q network is used to adaptively optimize the hyperparameters (detection threshold, bounding box regression coefficient, feature fusion weight) of the paint surface defect detection model, enabling the paint surface defect detection model to have the ability of continuous learning and quickly adapt to the detection requirements of different types of coating surfaces. Description of the Drawings

[0046] Figure 1 The following shows a schematic flow diagram of the method for detecting defects on the surface of waterborne coatings in an embodiment of the present invention;

[0047] Figure 2 The following shows a defect processing diagram for physical objects and defect images in an embodiment of the present invention;

[0048] Figure 3 The following shows a partial structural schematic diagram of the paint surface defect detection model in an embodiment of the present invention;

[0049] Figure 4 The following shows a schematic diagram of the AFM module processing flow in an embodiment of the present invention. Detailed Embodiments

[0050] The present invention will be further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention and cannot be used to limit the protection scope of the present invention.

[0051] Embodiment 1

[0052] As Figure 1 shown, an embodiment of the present invention introduces a method for detecting defects on the surface of a water-based paint, including the following steps:

[0053] S1: Obtain an image of the water-based paint surface to be detected;

[0054] S2: Input the image of the water-based paint surface to be detected into the trained paint surface defect detection model to obtain a processed image of the paint surface defects;

[0055] S3: Determine whether there are defects, the type of defects, and the severity of the defects on the water-based paint surface to be detected according to the processed image of the paint surface defects;

[0056] Among them, the paint surface defect detection model is improved based on the YOLOv8 model. The YOLOv8 model includes a backbone network, a neck network, and a head network connected in sequence; the Concat layer in the upsampling stage of the neck network is replaced with an AFM module, and an attention mechanism module is added between the backbone network and the neck network, and after the C2f layer of the neck network to obtain the paint surface defect detection model.

[0057] Specifically, as Figure 2 shown is the effect diagram of the paint surface defects for a physical object, which is obtained by inputting a physical picture of the paint surface with scratches into the trained paint surface defect detection model. The red box in the figure is the detection box, and the position information and detection category are displayed in the background;

[0058] This embodiment proposes a method for detecting defects on the surface of a water-based paint. The paint surface defect detection model improved based on the YOLOv8 model is used to detect the defects on the water-based paint surface, effectively improving the detection accuracy and detection efficiency.

[0059] In this embodiment, the step of step S1 for obtaining an image of the water-based paint surface to be detected includes scanning the omnidirectional image of the workpiece to be detected through a camera device in all directions, and performing normalization processing on the omnidirectional image to obtain a set of images of the water-based paint surface to be detected; among them, the workpiece to be detected is sprayed with water-based paint to form multiple paint surfaces; in the industrial application of detecting paint surface defects, the omnidirectional image of the workpiece to be detected, that is, the set of paint surface images, can be obtained by the cooperation of a robotic arm and a camera device, improving the detection accuracy and effectively reducing the missed detection rate.

[0060] In this embodiment, in step S2, the image of the water-based paint surface to be detected is input into the trained paint surface defect detection model to obtain a processed map of paint surface defects. The paint surface defect detection model is obtained by integrating an attention mechanism module and an AFM module (Attentional Fusion Module, adaptive feature fusion module) into the YOLOv8 model;

[0061] Specifically, the YOLOv8 model includes a backbone network, a neck network, and a head network. Since the YOLOv8 model is a prior art, the specific model structure will not be elaborated here;

[0062] As Figure 3 shown, the partial structural schematic diagram of the paint surface defect detection model is the improved part of the present invention:

[0063] (1) An attention mechanism module is added between the backbone network and the neck network of the YOLOv8 model;

[0064] The backbone network includes a convolutional layer, four stage modules, and an SPFF layer connected in sequence. In the figure, ConV Module represents the convolutional layer in the backbone network, Stage Layer1-4 represent the four stage modules respectively, CSPLayer_2ConV represents the C2f layer, and CBAM (Convolutional Block Attention Module) represents the attention mechanism module. Among them, each of the four stage modules includes a convolutional layer and a C2f layer connected in sequence. The C2f layer includes a convolutional layer, a Bottleneck layer, and a residual connection layer. Since both the C2f layer and the SPFF layer are prior arts, they will not be elaborated here;

[0065] According to the connection sequence of the backbone network, the second stage module is connected to the attention mechanism module, that is, the attention mechanism module is connected behind the C2f layer in the second stage module to output a small-scale feature map with enhanced attention. The third stage module is connected to the attention mechanism module, that is, the attention mechanism module is connected behind the C2f layer in the third stage module to output a medium-scale feature map with enhanced attention. The SPFF layer is connected to the attention mechanism module to output a large-scale feature map with enhanced attention;

[0066] (2) The attention mechanism module and the AFM module are integrated into the neck network of the YOLOv8 model;

[0067] The neck network includes an upsampling stage and a downsampling stage. Among them, the upsampling stage includes a first upsampling module and a second upsampling module connected in sequence. Both the first upsampling module and the second upsampling module include an upsampling layer, a Concat layer, and a C2f layer connected in sequence; replace the Concat layer in the upsampling stage with an AFM module, and add an attention mechanism module after the C2f layer in the upsampling stage to obtain the improved upsampling stage, that is, the improved first upsampling module and the first downsampling module, as Figure 3 shown. In the figure, Upsample represents the upsampling layer; ConV represents the convolutional layer in the downsampling stage;

[0068] In the improved first upsampling module, the upsampling layer receives the large-scale feature map enhanced by attention and performs upsampling to obtain the feature map A1; the AFM module performs feature fusion on the feature map A1 and the medium-scale feature map enhanced by attention to obtain the feature map A2; the feature map A2 is sequentially processed by the C2f layer and the attention mechanism module to obtain the feature map F1;

[0069] In the improved first upsampling module: the upsampling layer receives the feature map F1 and performs upsampling to obtain the feature map B1; the AFM module performs feature fusion on the feature map B1 and the small-scale feature map enhanced by attention to obtain the feature map B2; the feature map B2 is sequentially processed by the C2f layer and the attention mechanism module to obtain the feature map T1.

[0070] The downsampling stage includes a first downsampling module and a second downsampling module connected in sequence. Both the first downsampling module and the second downsampling module include a convolutional layer, a Concat layer, and a C2f layer connected in sequence; add an attention mechanism module after the C2f layer in the downsampling stage to obtain the improved downsampling stage, that is, the improved first downsampling module and the second downsampling module;

[0071] In the improved first downsampling module, the convolutional layer receives the feature map T1 and performs convolution to obtain the feature map C1; the Concat layer performs feature fusion on the feature map C1 and the feature map F1 to obtain the feature map C2; the feature map C2 is sequentially processed by the C2f layer and the attention mechanism module to obtain the feature map T2;

[0072] In the improved second downsampling module, the convolutional layer receives the feature map T2 and performs convolution to obtain the feature map D1; the Concat layer performs feature fusion on the feature map D1 and the large-scale feature map enhanced by attention to obtain the feature map D2; the feature map D2 is sequentially processed by the C2f layer and the attention mechanism module to obtain the feature map T3.

[0073] Specifically, after the neck network based on the paint surface defect detection model obtains the feature maps T1, T2, and T3, the feature maps T1, T2, and T3 are respectively input into three detection blocks of the head network for detection, and the paint surface defect processing maps at three scales are output respectively; the coordinates of the detection frames, the confidence scores, and the probability distributions of the categories are displayed in the paint surface defect processing maps.

[0074] Specifically, the attention mechanism module includes a channel attention module and a spatial attention module. The feature map F is used as the input and is respectively input into the channel attention module and the spatial attention module for processing to obtain the channel attention weight map. and the spatial attention weight map , and then the channel attention weight map and the spatial attention weight map are multiplied element by element to obtain the feature map enhanced by attention. ; The formula for its processing process is as follows:

[0075]

[0076] In the calculation, the importance of different channels is modeled through global pooling and MLP to strengthen the response of key feature channels. The formula is as follows:

[0077]

[0078] In the formula: represents the Sigmoid activation function, which normalizes the weight to the interval [0, 1]; represents the multi-layer perceptron, which is used to learn the dependence relationship between channels; represents average pooling, which extracts the global statistical information of the channels; represents max pooling, which extracts the significant features of the channels;

[0079] In the calculation, the convolutional operation is used to capture the attention information in the spatial dimension and highlight the feature expression of the target area. The formula is as follows:

[0080]

[0081] In the formula, represents the 7×7 convolutional layer, which is used to integrate the spatial domain information.

[0082] Specifically, the processing flow of the AFM module is as Figure 4As shown in the figure, in the figure, Finput1 and Finput1 respectively represent two feature maps. The AFM module includes a first branch module, a second branch module, and an output module. The first branch module includes an average pooling layer, a bottleneck layer, and an activation function layer two connected in sequence, and is used to take the concatenation of the two feature maps as the input, and obtain the first branch output after being processed by the first branch module. The second branch module includes a bottleneck layer and an activation function layer two, and is used to take the concatenation of the two feature maps as the input, and obtain the second branch output after being processed by the second branch module. The bottleneck layer includes a convolutional layer one, an activation function layer one, and a convolutional layer one connected in sequence. The output module is used to add the product results of the two feature maps and the first branch output and the second branch output respectively to obtain the output result Foutput of the AFM module.

[0083] The data processing expression of the AFM module is as follows:

[0084] ;

[0085] ;

[0086] ;

[0087] Among them, represents the output result of the AFM module; and respectively represent two feature maps; and respectively represent the first branch output and the second branch output; represents element-wise multiplication, represents element-wise addition; cat represents the concatenation operation; Avg represents the average pooling operation; SiLU represents the activation function in the activation function layer one; Sigmiod represents the activation function in the activation function layer two; Conv 1×1 represents the convolution operation of the convolutional layer one.

[0088] In this embodiment, the training process of the paint surface defect detection model includes:

[0089] S01: Obtain a water-based paint surface image dataset;

[0090] S02: Perform defect category annotation and data augmentation on the water-based paint surface image dataset to obtain a preprocessed water-based paint surface image dataset;

[0091] S03: Divide the preprocessed water-based paint surface image dataset into a training set, a test set, and a validation set;

[0092] S04: Input the training set data into the paint surface defect detection model for training, and adjust the model parameters using the loss function during the training process; input the validation set data into the paint surface defect detection model for validation to obtain the validation result, and adjust the hyperparameters according to the validation result;

[0093] S05: Use the test set data as the input to test the paint surface defect detection model to obtain the test result, calculate the evaluation index according to the test result. If the evaluation index is higher than the preset value, the training is completed and the trained paint surface defect detection model is obtained. If the evaluation index is lower than the preset value, repeat the above S04 - S05 until the evaluation index is higher than the preset value to obtain the trained paint surface defect detection model.

[0094] Specifically, in step S04, the loss function is used to adjust the model parameters during the training process, and the formula of the loss function is expressed as follows:

[0095] ;

[0096] ;

[0097] ;

[0098] ;

[0099] Among them, is the loss function; are the detection loss, classification loss, and regression loss respectively; are the weight coefficients of the detection loss, classification loss, and regression loss respectively; IOU is the intersection - over - union ratio of the detection box and the ground - truth box; is the coordinate of the predicted bounding box; is the coordinate of the ground - truth bounding box; is the Euclidean distance between the center points of the detection box and the ground - truth box; is the diagonal length of the minimum bounding rectangle of the detection box; is the measure term for the aspect - ratio consistency of the detection box; is the weight coefficient; is the predicted probability of the target class; is the modulation factor, which is used to adjust the loss weights of easy and hard samples in the training set; is the balance factor, which is used to balance the ratio of positive and negative samples in the training set; is the coordinate value of the predicted point; is the coordinate value of the ground - truth point; is the L1 norm, which is used to calculate the absolute difference between the predicted value and the true value.

[0100] The design of the three losses in the above loss function fully considers the characteristics of water - based paint defect detection:

[0101] The detection loss uses the improved CIOU loss. By introducing the center point distance and aspect ratio information, it can better guide the model to learn accurate object localization;

[0102] The classification loss uses Focal loss. By dynamically adjusting the sample weights, it effectively solves the common sample imbalance problem in defect detection;

[0103] The regression loss uses L1 loss, which is insensitive to outliers and is suitable for processing the localization task of fine defects on the paint surface;

[0104] Among the losses, through the weight coefficient Dynamic balance is achieved to ensure that the model can achieve good results in terms of detection accuracy, classification accuracy, and localization accuracy. This multi-task joint optimization strategy echoes the humanoid eye mechanism of the present invention because when the human eye performs defect detection, it also performs multiple tasks such as position perception, type recognition, and precise localization at the same time. The design of this loss function provides a basis for the subsequent optimization of hyperparameters and also directly serves the judgment of defects. The entire loss function optimization process is an important link connecting model training and practical applications, ensuring the high accuracy and practicality of the detection system.

[0105] In this embodiment, during the training process of the paint surface defect detection model, a deep Q network is also used to optimize the hyperparameters of the paint surface defect detection model to obtain the optimal hyperparameters, including:

[0106] S11: Confirm the target parameters for deep Q network optimization and initialize the target parameters; the target parameters are the hyperparameters of the paint surface defect detection model, including the detection threshold, the border regression coefficient, and the feature fusion weight;

[0107] S12: Define the state space, action space, and reward function, specifically as follows:

[0108] The state space S, the t-th state

[0109] Contains the current detection parameters and image features:

[0110]

[0111] Among them, Is the t-th detection parameter vector, that is, the input parameter in the paint surface defect detection model, Is the t-th image feature vector; t is the sequence value;

[0112] The action space A, define the parameter adjustment for the t-th action :

[0113]

[0114] Its adjustment range is limited:

[0115]

[0116] Among them, represents the rule for transitioning between states, N represents the current number of convertible spaces, represents the maximum adjustable distance.

[0117] Reward function R, design a multi-objective reward function based on the characteristics of human visual perception:

[0118]

[0119] In the formula, represents the reward value under the state-action pair ; w1, w2, w3, w4 all represent weights;

[0120] Detection accuracy reward: , is the average precision at the t-th moment;

[0121] Visual consistency reward: , is the high-level feature representation, is the target feature representation;

[0122] Parameter stability reward: , is the weight coefficient of the stability reward, is the parameter adjustment amount;

[0123] Time efficiency reward: , T is the current time, is the reference time, is the weight coefficient of the time efficiency reward.

[0124] S13: Input the target parameters into the deep Q-network for training, use the Q-network loss function to optimize the variables of the deep Q-network, and obtain the optimal target parameters, that is, the best hyperparameters.

[0125] The online Q-network in the deep Q-network calculates the Q value of each action according to the input state and selects the action with the maximum Q value; the target Q-network in the deep Q-network obtains the target Q value according to the action with the maximum Q value; calculate the mean square error (Q-network loss function) between the Q value predicted by the online Q-network in the deep Q-network and the target Q value according to the action with the maximum Q value in the current state, so as to optimize the spatial variables of the online Q-network and obtain the optimal target parameters;

[0126] Specifically, the Deep Q-Network (DQN) consists of an online network and a target network:

[0127]

[0128] where is the online Q-network, which is used to evaluate the action value under the current policy; is the target Q-network, which is used to provide a stable target value to assist in training the online Q-network; S is the state space, representing all possible states of the environment, A is the action space, representing all possible actions that the agent can execute, and R is the set of real numbers, representing the output value of the Q-function, that is, the reward value, representing the expected return of taking a specific action in a specific state.

[0129] Specifically, the calculation of the target Q-value: Use the Double Q-learning mechanism:

[0130]

[0131] where is the immediate reward obtained; is the discount factor, and its value range is , which is used to balance the importance of the current reward and future rewards; is the optimal action evaluated by the online Q-network in the state .

[0132] Specifically, the Q-network loss function, that is, the temporal difference loss:

[0133]

[0134] where is the Q-network loss function, which is used to measure the difference between the predicted Q-value and the target Q-value; are the target parameters of the online Q-network, that is, the spatial variables; E is the expectation operator, indicating taking the average of all training samples; is the predicted Q-value of the online Q-network for the action in the state .

[0135] Specifically, this patent designs an idea of static hyperparameter optimization in the YAML configuration file of the YOLOv8 model based on the Deep Q-Network (DQN) reinforcement learning framework. This method maps the evaluation metrics (such as mAP, loss, convergence speed, etc.) generated during the training iteration process of the model into the state space, and then uses the exploration and exploitation strategies of DQN to find the best initial parameter combination, so as to achieve the improvement of the overall performance.

[0136] In this design, the state space of reinforcement learning can be composed of model evaluation metrics, while the actions correspond to the adjustment of hyperparameters (such as learning rate, batch size, etc.). The following table lists the common optimizable hyperparameters in the YOLOv8 model, and gives the descriptions, adjustable ranges (or candidate sets) of each parameter, as well as their roles in state mapping:

[0137]

[0138] In this embodiment, step S3 determines whether there are defects, the type of defects, and the severity of the defects on the waterborne coating surface to be detected according to the paint surface defect treatment diagram. Among them, whether there are defects and the type of defects can be directly obtained through the coordinate, confidence score, and probability distribution of the category of the detection box shown in the paint surface defect treatment diagram;

[0139] The severity of the defect is obtained by weighting three indicators: defect area, defect depth, and defect edge complexity:

[0140]

[0141] In the formula, is the comprehensive score, which is used to quantify the severity of the defect. The larger the value, the more severe the defect; is the weight coefficient, which is used to balance the influence degrees of area, depth, and edge complexity; these weights can be determined according to experience or actual detection requirements; 、 、

[0142] respectively represent the defect area, defect depth, and defect edge complexity;

[0143] Specifically, the defect area is calculated by summing all defect pixels to obtain the area size of the defect on the image plane; if it is necessary to convert the pixel coordinates to the real area, further conversion needs to be carried out in combination with camera calibration information (such as pixel size, working distance), and the formula is as follows:

[0144]

[0145] In the formula, n’ is the number of detected defect pixels (or the pixels included in the defect area), is the contribution value of the i-th defect pixel to the defect area, or the area value after actual proportion conversion.

[0146] Specifically, the calculation of the defect depth is carried out by comparing the characteristic values (such as gray scale, depth or height) of the defect area and the background area, finding the maximum value of the difference between the two, so as to measure the maximum deviation of the defect in the vertical direction (or the reference measurement direction), which is usually used to characterize the concavity and convexity or depth of the defect. The formula is as follows:

[0147]

[0148] In the formula, is the defect depth, which is used to measure the protrusion or depression degree of the paint surface defect in the depth or height direction, is the characteristic value of the defect area, usually obtained from a depth camera or optical measurement, is the reference characteristic value corresponding to the adjacent normal background area.

[0149] Specifically, is the defect edge complexity, which can be measured by an edge detection operator or a shape-based complexity metric (such as contour length, fractal dimension, etc.).

[0150] Specifically, the defect types include the following:

[0151] a. Particle

[0152] Particle-like defects refer to the appearance of tiny and uneven material deposits or material defects on the paint surface. These defects usually appear as discrete small spots, which may be caused by particulate contamination or uneven raw materials during the manufacturing process. For such defects, the model needs to focus on local texture changes and weak feature differences to ensure accurate detection of particles.

[0153] b. Scratch

[0154] Scratches are mainly caused by mechanical actions such as friction and impact, and appear as long and diverse-shaped traces. These traces may be straight or curved, and their presence has a significant impact on the aesthetic appearance. When identifying scratches, the model needs to capture the edge continuity and subtle changes in the lines to accurately determine their presence and scope.

[0155] c. Stain

[0156] Stains are caused by factors such as oil stains, dust or liquid residues, and usually appear as irregular patches with various colors and shapes, and often have blurred edges. Due to the complex and variable characteristics of stains, color distribution, texture features and edge information need to be considered comprehensively for accurate classification when identifying them.

[0157] Embodiment 2

[0158] This embodiment provides an aqueous paint surface defect detection system based on the threshold of a biomimetic human eye, including:

[0159] A data acquisition module for acquiring an image of the water-based paint surface to be detected;

[0160] A defect detection module for inputting the image of the water-based paint surface to be detected into a trained paint surface defect detection model to obtain a paint surface defect processing diagram;

[0161] A defect judgment module for judging whether there are defects, the type of defects, and the severity of the defects on the water-based paint surface to be detected according to the paint surface defect processing diagram.

[0162] Embodiment 3

[0163] This embodiment provides a computer-readable storage medium storing a computer program, and when the computer program is executed, it implements the water-based paint surface defect detection method described in Claim Embodiment 1.

[0164] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0165] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram can be implemented by computer program instructions, and the combination of the processes and / or blocks in the flowchart and / or block diagram can also be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.

[0166] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device, and the instruction device implements the functions specified in Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.

[0167] The embodiments of the present invention have been described above in conjunction with the accompanying drawings. However, the present invention is not limited to the above specific embodiments. The above specific embodiments are merely illustrative rather than restrictive. Under the inspiration of the present invention, those of ordinary skill in the art can also make many forms without departing from the spirit of the present invention and the scope protected by the claims. All of these fall within the protection scope of the present invention.

Claims

1. A method for detecting paint surface defects of water-based paint, characterized in that: include: Acquire a paint surface image of a water-based paint to be tested; Input the paint surface image of the water-based paint to be detected into the trained paint surface defect detection model to obtain a paint surface defect processing map; Determine whether there are defects on the water-based paint surface to be tested, the type of defects, and the severity of the defects based on the paint surface defect processing diagram; The paint defect detection model is improved according to the YOLOv8 model, and the YOLOv8 model includes a backbone network, a neck network and a head network connected in sequence; The Concat layer in the upsampling stage of the neck network is replaced with the AFM module, and an attention mechanism module is added between the backbone network and the neck network, and after the C2f layer of the neck network to obtain the paint defect detection model.

2. The method for detecting paint surface defects of water-based paint according to claim 1, characterized in that: The backbone network includes sequentially connected convolutional layers, four stage modules and an SPFF layer; according to the connection order of the backbone network, the second stage module is connected to the attention mechanism module to output a small-scale feature map after attention enhancement, and the third stage module is connected to the attention mechanism module to output a medium-scale feature map after attention enhancement; the SPFF layer is connected to the attention mechanism module to output a large-scale feature map after attention enhancement; wherein the four stage modules all include sequentially connected convolutional layers and C2f layers.

3. The method for detecting paint surface defects of water-based paint according to claim 2, characterized in that: The neck network includes an upsampling stage and a downsampling stage, wherein the upsampling stage includes a first upsampling module and a second upsampling module connected in sequence, and the first upsampling module and the second upsampling module both include an upsampling layer, a Concat layer and a C2f layer connected in sequence; the Concat layer in the upsampling stage is replaced with an AFM module, and an attention mechanism module is added after the C2f layer in the upsampling stage to obtain an improved upsampling stage, that is, an improved first upsampling module and a first downsampling module; In the improved first upsampling module, the upsampling layer receives the large-scale feature map after attention enhancement and performs upsampling to obtain the feature map A1; the AFM module performs feature fusion on the feature map A1 and the medium-scale feature map after attention enhancement to obtain the feature map A2; the feature map A2 is processed by the C2f layer and the attention mechanism module in turn to obtain the feature map F1; In the improved first upsampling module: the upsampling layer receives the feature map F1 and performs upsampling to obtain the feature map B1; the AFM module fuses the feature map B1 and the small-scale feature map after attention enhancement to obtain the feature map B2; the feature map B2 is processed by the C2f layer and the attention mechanism module in turn to obtain the feature map T1.

4. The method for detecting paint surface defects of water-based paint according to claim 3, characterized in that: The downsampling stage includes a first downsampling module and a second downsampling module connected in sequence, and the first downsampling module and the second downsampling module both include a convolution layer, a Concat layer and a C2f layer connected in sequence; an attention mechanism module is added after the C2f layer of the downsampling stage to obtain an improved downsampling stage, that is, the improved first downsampling module and the second downsampling module; In the improved first downsampling module, the convolution layer receives the feature map T1 and performs convolution to obtain the feature map C1; the Concat layer fuses the row features of the feature map C1 and the feature map F1 to obtain the feature map C2; the feature map C2 is processed by the C2f layer and the attention mechanism module in turn to obtain the feature map T2; In the improved second downsampling module, the convolution layer receives the feature map T2 and performs convolution to obtain the feature map D1; the Concat layer fuses the feature map D1 and the large-scale feature map row features after attention enhancement to obtain the feature map D2; the feature map D2 is processed by the C2f layer and the attention mechanism module in turn to obtain the feature map T3.

5. The method for detecting paint surface defects of water-based paint according to claim 4, characterized in that: The AFM module includes a first branch module, a second branch module and an output module; the first branch module includes an average pooling layer, a bottleneck layer and an activation function layer 2 connected in sequence, and is used to take the concatenation of two feature maps as input, and obtain a first branch output after being processed by the first branch module; The second branch module includes a bottleneck layer and an activation function layer 2, which are used to take the concatenation of the two feature maps as input, and obtain the second branch output after processing by the second branch module; the bottleneck layer includes a convolution layer 1, an activation function layer 1 and a convolution layer 1 connected in sequence; the output module is used to add the two feature maps to the product results of the first branch output and the second branch output respectively to obtain the output result of the AFM module.

6. The method for detecting paint surface defects of water-based paint according to claim 5, characterized in that: The data processing expressions of the AFM module include the following: ; ; ; in, Represents the output result of the AFM module; and Represent two feature maps respectively; and Respectively represent the first branch output and the second branch output; represents element-wise multiplication, represents element addition; cat represents concatenation operation; Avg represents average pooling operation; SiLU represents the activation function in activation function layer 1; Sigmiod represents the activation function in activation function layer 2; Conv 1×1 Represents the convolution operation of convolutional layer 1.

7. The method for detecting paint surface defects of water-based paint according to claim 1, characterized in that: The training process of the paint defect detection model includes: S01: Obtain water-based paint surface image dataset; S02: labeling defect categories and performing data enhancement on the water-based paint surface image dataset to obtain a preprocessed water-based paint surface image dataset; S03: Divide the preprocessed water-based paint surface image dataset into a training set, a test set, and a validation set; S04: input the training set data into the paint defect detection model for training, and use the loss function to adjust the model parameters during the training process; input the validation set data into the paint defect detection model for validation, obtain the validation results, and adjust the hyperparameters according to the validation results; S05: Use the test set data as input, test the paint defect detection model to obtain test results, calculate the evaluation index based on the test results, if the evaluation index is higher than the preset value, the training is completed, and a trained paint defect detection model is obtained; if the evaluation index is lower than the preset value, repeat the above S04~S05 until the evaluation index is higher than the preset value, and a trained paint defect detection model is obtained.

8. The method for detecting paint surface defects of water-based paint according to claim 7, characterized in that: The formula of the loss function is as follows: ; ; ; ; in, is the loss function; They are detection loss, classification loss and regression loss respectively; are the weight coefficients of detection loss, classification loss, and regression loss respectively; IOU is the intersection-over-union ratio between the detection box and the true box; are the coordinates of the predicted bounding box; are the coordinates of the true bounding box; is the Euclidean distance between the center point of the detection box and the real box; is the diagonal length of the minimum circumscribed rectangle of the detection frame; It is a measurement item for the consistency of the aspect ratio of the detection box; is the weight coefficient; is the predicted probability of the target category; is a modulation factor used to adjust the loss weight of difficult and easy samples in the training set; is the balance factor, which is used to balance the ratio of positive and negative samples in the training set; is the coordinate value of the predicted point; is the real point coordinate value; is the L1 norm, which is used to calculate the absolute difference between the predicted value and the true value.

9. The method for detecting paint surface defects of water-based paint according to claim 7, characterized in that: During the training process of the paint defect detection model, a deep Q network is also used to optimize the hyperparameters of the paint defect detection model to obtain the optimal hyperparameters, including: Confirm the target parameters of the deep Q network optimization and initialize the target parameters; the target parameters are the hyperparameters of the paint defect detection model, including the detection threshold, the bounding box regression coefficient, and the feature fusion weight; Define state space, action space, and reward function; The target parameters are input into the deep Q network for training, and the Q network loss function is used to optimize the variables of the deep Q network to obtain the optimal target parameters, that is, the optimal hyperparameters.

10. A water-based paint surface defect detection system based on bionic human eye threshold, characterized in that: include: A data acquisition module, used to acquire the paint surface image of the water-based paint to be tested; A defect detection module is used to input the paint surface image of the water-based paint to be detected into the trained paint surface defect detection model to obtain a paint surface defect processing map; The defect judgment module is used to judge whether there are defects on the paint surface of the water-based paint to be tested, the type of defects and the severity of the defects according to the paint surface defect processing diagram.

Citation Information

Cited By

  • Semiconductor defective product processing method and system

    CN121075946A

  • A method and system for handling semiconductor defects

    CN121075946B