An improved method for detecting surface defects of aluminum profiles
By improving the data augmentation and loss function of the YOLOv5 model and combining it with StyleGAN to generate simulated images, the problem of low detection accuracy of small targets on the surface of aluminum profiles was solved, achieving efficient detection of surface defects in aluminum profiles and improving detection accuracy and speed.
Patent Information
- Application Number
- CN202310868006.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-14
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2043-07-14
AI Technical Summary
In the detection of surface defects of aluminum profiles, the detection accuracy of small targets is low and the ability to extract small target features is insufficient. Existing technologies are difficult to effectively detect minute defects on the surface of aluminum profiles.
An improved Yolov5 model is adopted, combined with traditional methods and the BBHE algorithm for data augmentation. Simulation images are generated through the StyleGAN network. The anchor box mechanism, data augmentation method, attention mechanism and loss function of the model are improved to construct the Yolov5-CA-GFPN model, which improves the feature extraction capability of small targets.
It significantly improves the accuracy and speed of surface defect detection for aluminum profiles, enhances the detection capability for small target defects, reduces human resource costs, and promotes the intelligent development of the aluminum profile industry.
Smart Images

Figure CN117252806B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of aluminum profile surface defect detection technology, specifically to an improved method for detecting aluminum profile surface defects. Background Technology
[0002] Aluminum is abundant and offers numerous advantages. With the development of new products and processes, its applications will continue to expand. Based on their form, aluminum products can be divided into three categories: the first category is processed materials, such as plates, strips, foils, tubes, bars, forgings, and powders; the second category is cast aluminum alloys or wire rods, cables, etc.; and the third category is various aluminum products used in daily life. Currently, the production process of aluminum profiles consists of three important steps: melting and casting, extrusion, and oxidation. Melting and casting includes batching, smelting, and casting; extrusion includes extrusion, air-cooling quenching, and artificial aging; and oxidation includes surface pretreatment, anodizing, and sealing.
[0003] The aluminum profile industry is developing rapidly, with continuously expanding production. However, in the actual production process, aluminum profiles are often affected by factory environment, equipment, and other conditions, inevitably resulting in surface defects. Among these surface defects are many small-target defects, such as dirt spots, scratches, and paint bubbles. These minor defects make the produced aluminum profiles unsightly and seriously affect product quality and subsequent use. Therefore, research on the detection of small-target aluminum profile surface defects is of great significance to industrial development and improving product quality.
[0004] Before the maturity of computer technology, surface defect detection technology for aluminum profiles relied on manual visual inspection. This method was labor-intensive, had low accuracy, and the manual contact could easily cause secondary damage to the metal surface, leading to more defects. With the development of physics, surface inspection technologies based on physical properties emerged, mainly including ultrasonic flaw detection, magnetic flux leakage detection, and infrared detection. However, these methods have certain limitations in detecting surface defects in metals. Furthermore, they require a high level of physical knowledge from the inspectors and lack generalization ability. With the development of computers, surface defect detection technology has two approaches: one based on traditional image processing and the other based on machine vision. Image processing methods mainly rely on algorithms such as image segmentation and transformation, while machine vision relies on machine learning and deep learning algorithms, representing an intelligent defect detection method.
[0005] While traditional image processing algorithms are suitable for scenarios with low computing power and few defect samples, they require high image quality, and uneven light source distribution can worsen detection results. Since different defect features have varying representational abilities for defect images, the limitations of this method become increasingly apparent as the number of defect types increases. Furthermore, although machine learning algorithms significantly improve detection performance compared to traditional image processing algorithms, their performance deteriorates noticeably when there is severe background interference. Moreover, most machine learning models can only classify defects, not pinpoint their exact location, requiring image processing methods to segment the defect itself based on its specific features. However, in industrial settings, the location of defects is often needed to analyze their causes, thus machine learning methods have certain limitations in surface defect detection. Deep learning-based surface defect detection technology effectively addresses these issues. In the field of surface defect detection, the main deep learning network models include Faster-RCNN, MobileNet, and the YOLO series of algorithms. YOLO, in particular, exhibits significantly superior performance, overcoming many problems of traditional methods, and improving the detection accuracy of small target defects has always been a focus of the YOLO series of algorithms. Summary of the Invention
[0006] (a) Technical problems to be solved
[0007] The purpose of this invention is to provide an improved method for detecting surface defects in aluminum profiles. It solves the problems in the field of aluminum profile surface defect detection technology, such as low detection accuracy and insufficient feature extraction capability for some small targets.
[0008] (II) Technical Solution
[0009] To achieve the above objectives, the present invention provides the following technical solution: an improved method for detecting surface defects in aluminum profiles, specifically implemented according to the following steps:
[0010] Step 1: Data preprocessing stage;
[0011] Step 1 is implemented in the following steps:
[0012] Step 1.1: Select the Alibaba Cloud Tianchi Competition dataset. This dataset includes three types of images: single-defect images, multi-defect images, and flawless images. The aluminum profile surface defect dataset contains 4356 images, including 1210 flawless images and 3146 single-defect and multi-defect images, all with a resolution of 2560×1920. The single-defect and multi-defect images contain 10 types of defects, including non-conductive, scratches, corner defects, orange peel, bottom defects, spraying, paint bubbles, pitting, discoloration, and dirt spots. Each image contains one or more defects.
[0013] Step 1.2: Perform flipping, rotating, and Gaussian noise addition operations on images with single defects, multiple defects, and no defects;
[0014] Step 1.3: Use the mean-preserving dual histogram equalization algorithm to enhance images with low contrast in the dataset;
[0015] Step 1.4: Use oversampling to enhance the images of dirty points in the dataset;
[0016] Step 2: Dataset generation stage;
[0017] Step 2 is implemented in the following steps:
[0018] Step 2.1: For the four types of defects—scrubbing, orange peel, jetting, and discoloration—the StyleGAN network is used to generate simulation images to augment the data of these four defects.
[0019] Step 2.2: Use the open-source LabelImg bounding box annotation tool to annotate the expanded dataset;
[0020] Step 2.3: The expanded dataset is divided into training set, validation set and test set using the hold-out method, with a ratio of 8:1:1. The training set contains 6130 images, the validation set contains 766 images, and the test set contains 766 images.
[0021] Step 3: Yolov5 model improvement stage;
[0022] In step 3, the anchor box mechanism, data augmentation method, attention mechanism, loss function and structure of the Yolov5-s minimum network model are improved to enhance the feature extraction capability of small targets, and the Yolov5-CA-GFPN model is proposed.
[0023] Step 3 is implemented in the following steps:
[0024] Step 3.1: Replace the Euclidean distance in the original K-Means of the Yolov5 model with 1-IoU;
[0025] Step 3.2: Improve the data augmentation method of the Yolov5 model using Mosaic-9.
[0026] Step 3.3: Add the CA attention mechanism to the minimum network model of Yolov5 to form the Yolov5-CA model;
[0027] Step 3.3: Improve the loss function of the YOLOv5-CA model using normalized Wasserstein distance;
[0028] Step 3.4: Improve the neck module of the Yolov5-CA model using a generalized feature pyramid network structure;
[0029] Step 3.5: Propose the Yolov5-CA-GFPN model;
[0030] Step 4: Defect Detection Stage;
[0031] Step 4 is implemented in the following steps:
[0032] Step 4.1: Set the hyperparameters of the Yolov5-CA-GFPN model;
[0033] Step 4.2: Train the Yolov5-CA-GFPN model using the dataset divided in Step 2, and save the network weights;
[0034] Step 4.3: Load the trained Yolov5-CA-GFPN model weights and use the test set for prediction;
[0035] Step 4.4: Obtain the prediction results.
[0036] Preferably, the principle of the average-preserving dual-histogram equalization algorithm in step 1 is as follows:
[0037] Let the input image be I, with a size of M×N and a gray level range of [0,L-1], where L represents the number of gray levels.
[0038] (1) Calculate the histogram H(c) of the original image:
[0039]
[0040] Where δ(a,b) is the Kronecker Delta function, which is 1 when a = b and 0 otherwise. i represents the row index of the image, usually in the range [0,M-1], where M is the height of the image. j represents the column index of the image, usually in the range [0,N-1], where N is the width of the image. c represents the gray level in the image.
[0041] (2) Divide the histogram into bright and dark areas; select a threshold T such that the bright area contains gray levels in the range of [0,T] and the dark area contains gray levels in the range of [T+1,L-1].
[0042] (3) Perform histogram equalization on bright areas.
[0043] Calculate the total number of pixels N in the bright area bright :
[0044]
[0045] Calculate the cumulative distribution function C of the bright area.bright (c)(CDF):
[0046]
[0047] In the formula, H(i) represents the number of times or frequency of a pixel with gray level i appearing in the image;
[0048] Linearly map the CDF of the bright area to the gray level range [0, L-1]:
[0049] S bright (c)=(L-1)·C bright (c), 0≤c≤T (4)
[0050] Where S bright (c) represents the gray level after brightness enhancement;
[0051] (4) Similarly, histogram equalization is performed on the dark areas.
[0052] Calculate the total number of pixels N in the dark area dark :
[0053]
[0054] Calculate the cumulative distribution function C of the dark area bright (c)(CDF):
[0055]
[0056] Linearly map the CDF of the bright area to the gray level range [0, L-1]:
[0057] S dark (c)=(L-1)·C dark (c), T+1≤c≤L-1 (7)
[0058] Where S dark (c) represents the gray level after the darkness is enhanced;
[0059] (5) Finally, the equalization results of the bright and dark areas are merged by linear interpolation:
[0060] For each pixel position (i, j), determine whether it belongs to a bright area or a dark area based on its gray level I(i, j);
[0061] The pixel grayscale mapping in the dark area is as follows:
[0062] F dark (i, j) = S dark (I(i,j)) (8)
[0063] Where F dark(i, j) represents the pixel value at position (i, j) in the image after darkening; S dark (I(i,j)) represents the new pixel value calculated using the darkness enhancement formula based on the pixel value I(i,j) at position (i,j) in the original image; S dark The () function performs a darkness enhancement operation on the pixel value I(i,j) in the original image to obtain the corresponding pixel intensity value;
[0064] The pixel grayscale mapping in the bright area is as follows:
[0065] F bright (i, j) = S bright (I(i,j)) (9)
[0066] Where F bright (i, j) represents the pixel value at position (i, j) in the enhanced image; S bright (I(i,j)) represents the new pixel value calculated by the brightness enhancement formula based on the pixel value I(i,j) at position (i,j) in the original image during the brightness enhancement process;
[0067] The final equalized image F is obtained by linear interpolation of the two parts. final (i, j):
[0068]
[0069] Where I(i,j) is the gray level of each pixel;
[0070] The F obtained by calculating using the above formula is... final This is the image after average preserving bihistogram equalization;
[0071] After the above four data augmentation operations—flipping, rotating, adding Gaussian noise, and average-preserving dual histogram equalization—a total of 7,162 original and newly added images were used, and a total of 9,111 defective targets were identified.
[0072] After step 1, the number of each type of defect has become nearly balanced compared to before the addition, but there are still four types of defects, namely scratches, orange peel, jets, and discoloration, which are insufficient in number. The StyleGAN network is used to augment the data, then the data is labeled, and finally the data is segmented.
[0073] Preferably, the principle of NWD distance in step 3 is as follows:
[0074] Assuming (cx, cy) are the center coordinates of the horizontal bounding box, w represents the width of the bounding box, and h represents the height of the bounding box, the inscribed ellipse of the bounding box is represented as:
[0075]
[0076] The probability density function of a two-dimensional Gaussian distribution is determined by the following equation:
[0077]
[0078] In equations (11) and (12):
[0079] X represents the coordinates (x, y) of a Gaussian distribution; μ represents the mean vector of the Gaussian distribution; T denotes the transpose of the matrix; ∑ represents the covariance matrix of the Gaussian distribution; ∑ -1 ∑ represents the inverse of the covariance matrix ∑; the exp function is an exponential function with the natural constant e as its base.
[0080] When equation (13) is satisfied, the inscribed ellipse of equation (11) is the probability density function of a two-dimensional Gaussian distribution:
[0081] (X-μ) T ∑ -1 (X-μ)=1 (13)
[0082] Therefore, the horizontal bounding box is modeled as a two-dimensional Gaussian distribution following N(μ, ∑), where the values of μ and ∑ are given by the following equation:
[0083]
[0084] From the above analysis, we can see that the similarity between bounding boxes can be converted into the distance between their corresponding Gaussian distributions. Assuming Gaussian distributions μ1 = N1(m1, ∑1) and μ2 = N2(m2, ∑2), the distribution distance between them can be calculated using the second-order Wasserstein distance, as shown in the following formula:
[0085]
[0086] In the formula: ||·|| F It is the Frobenius norm; For distance measurement, m1 and m2 represent the means of two two-dimensional Gaussian distributions, respectively; m1 is the mean vector of the first Gaussian distribution, and m2 is the mean vector of the second Gaussian distribution. These vectors are composed of two real numbers, representing the means in the x and y dimensions, respectively; ∑1 and ∑2 represent the covariance matrices of the two two-dimensional Gaussian distributions, respectively.
[0087] Based on the Gaussian distributions of μ1 and μ2, equation (15) simplifies to the following equation:
[0088]
[0089] Where cx1 and cy1 are the center coordinates of the first bounding box, cx2 and cy2 are the center coordinates of the second bounding box, w1 and h1 are the width and height of the first bounding box, and w2 and h2 are the width and height of the second bounding box.
[0090] because It is a measure of distance and cannot be directly used as a measure of similarity between Gaussian distributions. Therefore, for Using exponential change, Fixed within the interval [0, 1], and the NWD distance is defined as shown in equation (17):
[0091]
[0092] In the formula: C is a constant related to the dataset; NWD(N1, N2) is a new metric for normalized Wasserstein distance (NWD);
[0093] The NWD distance is used to replace the IoU in Yolov5-CA to calculate the target loss function as follows:
[0094]
[0095] Among them, L oss N is the regression loss function based on NWD, N is the number of samples, and P i Let G be the probability distribution of the predicted bounding box for the i-th sample. i Let NWD(P) be the probability distribution of the predicted bounding box for the i-th sample. i G i Var(P) is the normalized Wasserstein distance between the predicted bounding box probability distribution and the true bounding box probability distribution. i ) and Var(G i ) represent the total changes in the predicted bounding box probability distribution and the true bounding box probability distribution, respectively;
[0096] The generalized feature pyramid network (GFPN) in step 3 works on the following principle:
[0097] The GFPN concept comprises two parts: skip-layer connections and cross-scale connections. Regarding skip-layer connections, GFPN proposes a log2n skip-layer connection method. In this method, at each level k, the l-th layer receives feature maps from at most log2+1 previous layers. The calculation method is shown in Equation (19).
[0098]
[0099] in This is the feature map of the l-th layer after skip connections in level k. For the (l-2)th in level k n Feature maps of each layer;
[0100] Regarding cross-scale connectivity, unlike the cross-scale connectivity method of path aggregation networks, GFPN adopts a full cross-scale connectivity method, namely the queen fusion method, which considers the features of the same level and adjacent levels at the same time.
[0101] By employing two skip-layer connection methods and a Queen-fusion connection method, the deep network can still learn important small target feature information;
[0102] The Yolov5 model improvement stage: After improving the anchor box mechanism, data augmentation method, attention mechanism, loss function and structure of the network model, the model is called Yolov5-CA-GFPN.
[0103] The input size of the defect image is set to 640*640, the batch size is set to 64, and the number of training epochs is set to 300. The trained weights are saved and loaded during testing to predict defects.
[0104] (III) Beneficial Effects
[0105] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0106] This paper presents an improved YOLOv5-based method for detecting small-target aluminum profile surface defects. Taking aluminum profile surface defect detection as a background, and based on deep learning-based surface defect detection technology, this method utilizes a YOLOv5 network model. First, it combines traditional methods and the BBHE algorithm to augment the dataset, and then generates simulated images using a StyleGAN network. Next, it improves and optimizes the model's anchor box mechanism, data augmentation methods, attention mechanism, loss function, and structure, ultimately achieving a significant improvement in the detection accuracy of small-target aluminum profile surface defects. The improved YOLOv5-CA-GFPN model effectively improves the detection accuracy and speed of aluminum profile surface defects, enhances the feature extraction capability of small-target defects, overcomes the low accuracy of traditional detection techniques for small targets, and reduces human resource costs. This method is of great significance for the aluminum profile industry, the intelligent development of small-target surface defect detection, and the improvement of detection accuracy. Attached Figure Description
[0107] Figure 1 This is a flowchart of an improved aluminum profile surface defect detection method according to the present invention.
[0108] Figure 2This is a flowchart of the BBHE algorithm for an improved aluminum profile surface defect detection method according to the present invention;
[0109] Figure 3 This is a flowchart of the improved IOU distance algorithm for an improved aluminum profile surface defect detection method according to the present invention;
[0110] Figure 4 This is a flowchart of the improved Mosaic-9 data enhancement method for detecting surface defects in aluminum profiles according to the present invention;
[0111] Figure 5 This is a flowchart of the Yolov5-s attention mechanism for an improved aluminum profile surface defect detection method according to the present invention.
[0112] Figure 6 This is a flowchart of the improved Yolov5-CA-GFPN model for an improved method for detecting surface defects in aluminum profiles according to the present invention. Detailed Implementation
[0113] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0114] This invention is based on an improved YOLOv5 method for detecting surface defects in small-target aluminum profiles. The flowchart is as follows: Figure 1 As shown, please follow these steps:
[0115] Step 1: Data preprocessing stage;
[0116] Combination Figure 2 In step 1, the data is first subjected to traditional image preprocessing operations: flipping, rotating and adding Gaussian noise. Then, the Brightness Preserving Bi-Histogram Equalization (BBHE) algorithm is used to enhance the images with low contrast in the dataset. Finally, oversampling is used to enhance the data.
[0117] Step 1 is implemented in the following steps:
[0118] Step 1.1: Select the Alibaba Cloud Tianchi Competition dataset. This dataset includes three types of images: single-defect images, multi-defect images, and flawless images. The aluminum profile surface defect dataset contains 4356 images, including 1210 flawless images and 3146 single-defect and multi-defect images, all with a resolution of 2560×1920. The single-defect and multi-defect images contain 10 types of defects: non-conductive (defect1), scratches (defect2), corner bottom exposure (defect3), orange peel (defect4), bottom exposure (defect5), spurs (defect6), paint bubbles (defect7), pitting (defect8), discoloration (defect9), and dirt spots (defect10). Each image contains one or more defects.
[0119] Step 1.2: Perform flipping, rotating, and Gaussian noise addition operations on images with single defects, multiple defects, and no defects;
[0120] Step 1.3: Use the Brightness Preserving Bi-Histogram Equalization (BBHE) algorithm to enhance images with low contrast in the dataset;
[0121] Step 1.4: Use oversampling to enhance the images of dirty points in the dataset.
[0122] The principle of the BBHE algorithm in step 1 is as follows:
[0123] Let the input image be I, with a size of M×N and a gray level range of [0, L-1], where L represents the number of gray levels.
[0124] (1) Calculate the histogram of the original image:
[0125]
[0126] Where δ(a, b) is the Kronecker Delta function, which is 1 when a = b and 0 otherwise. i represents the row index of the image, usually in the range [0, M-1], where M is the height of the image. j represents the column index of the image, usually in the range [0, N-1], where N is the width of the image. c represents the gray level (or pixel value) in the image. (2) Divide the histogram into bright and dark areas. Select a threshold T such that the bright area contains gray levels in the range [0, T] and the dark area contains gray levels in the range [T+1, L-1].
[0127] (3) Perform histogram equalization on bright areas.
[0128] Calculate the total number of pixels in the bright area:
[0129]
[0130] Calculate the cumulative distribution function (CDF) of the bright area:
[0131]
[0132] In the formula, H(i) represents the number of times or frequency of a pixel with gray level i appearing in the image.
[0133] Linearly map the CDF of the bright area to the gray level range [0, L-1]:
[0134] S bright (c)=(L-1)·C bright (c), 0≤c≤T (4)
[0135] Where S bright (c) represents the gray level after brightness enhancement.
[0136] (4) Similarly, histogram equalization is performed on the dark areas.
[0137] Calculate the total number of pixels in the dark area:
[0138]
[0139] Calculate the cumulative distribution function (CDF) of the dark area:
[0140]
[0141] Linearly map the CDF of the bright area to the gray level range [0, L-1]:
[0142] S dark (c)=(L-1)·C dark (c), T+1≤c≤L-1 (7)
[0143] Where S dark (c) represents the gray level after the darkness is enhanced.
[0144] (5) Finally, the equalization results of the bright and dark areas are merged by linear interpolation:
[0145] For each pixel position (i, j), determine whether it belongs to a bright area or a dark area based on its gray level I(i, j).
[0146] The pixel grayscale mapping in the dark area is as follows:
[0147] F dark (i, j) = S dark (I(i,j)) (8)
[0148] Where Fdark (i, j) represents the pixel value at position (i, j) in the image after darkening; S dark (I(i,j)) represents the new pixel value calculated using the darkness enhancement formula based on the pixel value I(i,j) at position (i,j) in the original image during the darkness enhancement process. dark The () function performs a darkness enhancement operation on the pixel values I(i,j) in the original image to obtain the corresponding pixel intensity values.
[0149] The pixel grayscale mapping in the bright area is as follows:
[0150] F bright (i, j) = S bright (I(i,j)) (9)
[0151] The two parts are linearly interpolated to obtain the final equalized image:
[0152]
[0153] Where I(i,j) is the gray level of each pixel.
[0154] The F obtained by calculating using the above formula is... final This is the image after average preserving bihistogram equalization.
[0155] After the above data augmentation operations, a total of 7,162 original and newly added images were used, and a total of 9,111 defective targets were identified.
[0156] Step 2: Dataset generation stage;
[0157] After step 1, the number of each type of defect has approached equilibrium compared to before the addition, but there are still four types of defects—scuffing, orange peel, jetting, and discoloration—that are insufficient in number. First, a StyleGAN network is needed to augment the data, then the data is labeled, and finally, the data is segmented. Step 2 is implemented as follows:
[0158] Step 2.1: For the four types of defects—scrubbing, orange peel, jetting, and discoloration—the StyleGAN network is used to generate simulation images to augment the data of these four defects.
[0159] Step 2.2: Use the open-source LabelImg bounding box annotation tool to annotate the expanded dataset;
[0160] Step 2.3: The expanded dataset is divided into training set, validation set and test set using the hold-out method, with a ratio of 8:1:1. The training set contains 6130 images, the validation set contains 766 images, and the test set contains 766 images.
[0161] Step 3: Yolov5 model improvement stage;
[0162] Combination Figures 3-6 In step 3, the anchor box mechanism, data augmentation method, attention mechanism, loss function and structure of the Yolov5-s (minimum) network model are improved to enhance the feature extraction capability of small targets, and finally the Yolov5-CA-GFPN model is proposed.
[0163] Step 3 is implemented in the following steps:
[0164] Step 3.1: Replace the Euclidean distance of the original K-Means in the Yolov5 model with (1-IoU);
[0165] Step 3.2: Improve the data augmentation method of the Yolov5 model using Mosaic-9.
[0166] Step 3.3: Add the CA attention mechanism to the minimum network model of Yolov5 to form the Yolov5-CA model;
[0167] Step 3.3: Improve the loss function of the Yolov5-CA model by using Normalized Wasserstein Distance (NWD);
[0168] Step 3.4: Improve the neck module of the Yolov5-CA model using the Generalized Feature Pyramid Network (GFPN) structure;
[0169] Step 3.5: Propose the Yolov5-CA-GFPN model.
[0170] The principle of NWD distance in step 3 is as follows:
[0171] Assuming (cx, cy) are the center coordinates of the horizontal bounding box, w represents the width of the bounding box, and h represents the height of the bounding box, the inscribed ellipse of the bounding box can be represented as:
[0172]
[0173] The probability density function of a two-dimensional Gaussian distribution is determined by the following equation:
[0174]
[0175] In equation (12):
[0176] X represents the coordinates (x, y) of a Gaussian distribution; μ is the mean vector of the Gaussian distribution; T denotes the transpose of the matrix; Σ is the covariance matrix of the Gaussian distribution; Σ -1 Σ represents the inverse of the covariance matrix Σ; the exp function is an exponential function with the natural constant e as its base.
[0177] When equation (13) is satisfied, the inscribed ellipse of equation (11) is the probability density function of a two-dimensional Gaussian distribution.
[0178] (X-μ) T Σ -1 (X-μ)=1 (13)
[0179] Therefore, the horizontal bounding box can be modeled as a two-dimensional Gaussian distribution following N(μ,Σ), where the values of μ and Σ are given by the following equation:
[0180]
[0181] As the above analysis shows, the similarity between bounding boxes can be converted into the distance between their corresponding Gaussian distributions. Assuming Gaussian distributions μ1 = N1(m1, Σ1) and μ2 = N2(m2, Σ2), the distribution distance between them can be calculated using the second-order Wasserstein distance, as shown in the following formula:
[0182]
[0183] In the formula: ||·|| F It is the Frobenius norm; For distance measurement, m1 and m2 represent the means of two two-dimensional Gaussian distributions, respectively. m1 is the mean vector of the first Gaussian distribution, and m2 is the mean vector of the second Gaussian distribution. These vectors consist of two real numbers, representing the means in the x and y dimensions, respectively. ∑1 and ∑2 represent the covariance matrices of the two two-dimensional Gaussian distributions, respectively. Based on the Gaussian distributions of μ1 and μ2, equation (15) can be simplified to the following equation:
[0184]
[0185] because It is a measure of distance and cannot be directly used as a measure of similarity between Gaussian distributions. Therefore, an exponential change is applied to it to make... Fixed within the interval [0,1], and defined as the NWD distance, as shown in equation (17):
[0186]
[0187] In the formula: C is a constant related to the dataset; NWD(N1, N2) is a new metric for normalized Wasserstein distance (NWD).
[0188] The NWD distance replaces the IoU calculation method for the target loss function in Yolov5-CA, as shown in the following equation:
[0189]
[0190] Where L oss N is the regression loss function based on NWD, N is the number of samples, and P i Let G be the probability distribution of the predicted bounding box for the i-th sample. i Let NWD(P) be the probability distribution of the predicted bounding box for the i-th sample. i G i Var(P) is the normalized Wasserstein distance between the predicted bounding box probability distribution and the true bounding box probability distribution. i ) and Var(G i ) represent the total changes in the predicted bounding box probability distribution and the true bounding box probability distribution, respectively.
[0191] The principle of the Generalized Feature Pyramid Network (GFPN) in step 3:
[0192] The GFPN concept mainly comprises two parts: skip-layer connections and cross-scale connections. Regarding skip-layer connections, GFPN proposes a log₂n skip-layer connection scheme. In this scheme, at each level k, the l-th layer receives connections from the most... The feature map of the previous layer is calculated as shown in equation (19):
[0193]
[0194] in This is the feature map of the l-th layer after skip connections in level k. For the (l-2)th in level k n Feature maps of each layer.
[0195] Regarding cross-scale connectivity, unlike the cross-scale connectivity approach of the Path Aggregation Network (PANet), GFPN employs a fully integrated cross-scale connectivity approach (“Queen-fusion”), which considers features at both the same and adjacent levels.
[0196] By employing two skip-layer connection methods and a Queen-fusion connection method, deep networks can still learn important small target feature information.
[0197] The Yolov5 model improvement stage: After improving the anchor box mechanism, data augmentation method, attention mechanism, loss function and structure of the network model, the model is called Yolov5-CA-GFPN.
[0198] Step 4: Defect Detection Stage;
[0199] Step 4 is implemented in the following steps:
[0200] Step 4.1: Set the hyperparameters of the Yolov5-CA-GFPN model;
[0201] Step 4.2: Train the Yolov5-CA-GFPN model using the dataset divided in Step 2, and save the network weights;
[0202] Step 4.3: Load the trained Yolov5-CA-GFPN model weights and use the test set for prediction;
[0203] Step 4.4: Obtain the prediction results.
[0204] The input size of the defect image is set to 640*640, the batch size is set to 64, and the number of training rounds is set to 300.
[0205] After testing, the prediction results of the Yolov5-CA-GFPN model of this invention are shown in Table 1 below:
[0206] Table 1 Prediction results of the Yolov5-CA-GFPN model
[0207]
[0208] The defect images contain 10 types of defects: non-conductive (defect 1), scratches (defect 2), corner defects (defect 3), orange peel (defect 4), bottom defects (defect 5), jetting (defect 6), paint bubbles (defect 7), pitting (defect 8), discoloration (defect 9), and dirt spots (defect 10). The AP values detected by the YOLOv5-CA-GFPN model on the validation set are shown in the figure below.
[0209] Table 2 AP values for defect detection in the Yolov5-CA-GFPN model
[0210]
[0211]
[0212] The evaluation metrics for the Yolov5-CA-GFPN model are shown in Table 3 below:
[0213] Table 3 Evaluation metrics for the Yolov5-CA-GFPN model
[0214] index Yolov5-CA-GFPN mAP 0.92 FLOPs / G 35.7 FPS / s 0.012
[0215] Example 1:
[0216] The data preprocessing stage of the improved Yolov5-based method for detecting surface defects in small-target aluminum profiles in this invention is implemented according to the following steps:
[0217] Step 1.1: Select the Alibaba Cloud Tianchi Competition dataset. This dataset includes three types of images: single-defect images, multi-defect images, and flawless images. The aluminum profile surface defect dataset contains 4356 images, including 1210 flawless images and 3146 single-defect and multi-defect images, all with a resolution of 2560×1920. The single-defect and multi-defect images contain 10 types of defects: non-conductive (defect1), scratches (defect2), corner bottom exposure (defect3), orange peel (defect4), bottom exposure (defect5), spurs (defect6), paint bubbles (defect7), pitting (defect8), discoloration (defect9), and dirt spots (defect10). Each image contains one or more types of defects.
[0218] Step 1.2: Perform flipping, rotating, and Gaussian noise addition operations on images with single defects, multiple defects, and no defects;
[0219] Step 1.3: Use the Brightness Preserving Bi-Histogram Equalization (BBHE) algorithm to enhance images with low contrast in the dataset;
[0220] Step 1.4: Use oversampling to enhance the images of dirty points in the dataset.
[0221] The principle of the BBHE algorithm in step 1 is as follows:
[0222] Let the input image be I, with a size of M×N and a gray level range of [0,L-1], where L represents the number of gray levels.
[0223] (1) Calculate the histogram of the original image:
[0224]
[0225] Where δ(a, b) is the Kronecker Delta function, which is 1 when a = b and 0 otherwise. i represents the row index of the image, usually in the range [0, M-1], where M is the height of the image. j represents the column index of the image, usually in the range [0, N-1], where N is the width of the image. c represents the gray level (or pixel value) in the image. (2) Divide the histogram into bright and dark areas. Select a threshold T such that the bright area contains gray levels in the range [0, T] and the dark area contains gray levels in the range [T+1, L-1].
[0226] (3) Perform histogram equalization on bright areas.
[0227] Calculate the total number of pixels in the bright area:
[0228]
[0229] Calculate the cumulative distribution function (CDF) of the bright area:
[0230]
[0231] In the formula, H(i) represents the number of times or frequency of a pixel with gray level i appearing in the image.
[0232] Linearly map the CDF of the bright area to the gray level range [0, L-1]:
[0233] S bright (c)=(L-1)·C bright (c), 0≤c≤T (4)
[0234] Where S bright (c) represents the gray level after brightness enhancement.
[0235] (4) Similarly, histogram equalization is performed on the dark areas.
[0236] Calculate the total number of pixels in the dark area:
[0237]
[0238] Calculate the cumulative distribution function (CDF) of the dark area:
[0239]
[0240] Linearly map the CDF of the bright area to the gray level range [0, L-1]:
[0241] S dark (c)=(L-1)·C dark (c), T+1≤c≤L-1 (7)
[0242] Where S dark(c) represents the gray level after the darkness is enhanced.
[0243] (5) Finally, the equalization results of the bright and dark areas are merged by linear interpolation:
[0244] For each pixel position (i, j), determine whether it belongs to a bright area or a dark area based on its gray level I(i, j).
[0245] The pixel grayscale mapping in the dark area is as follows:
[0246] F dark (i, j) = S dark (I(i,j)) (8)
[0247] Where F dark (i, j) represents the pixel value at position (i, j) in the image after darkening; S dark (I(i,j)) represents the new pixel value calculated using the darkness enhancement formula based on the pixel value I(i,j) at position (i,j) in the original image during the darkness enhancement process. dark The () function performs a darkness enhancement operation on the pixel values I(i,j) in the original image to obtain the corresponding pixel intensity values.
[0248] The pixel grayscale mapping in the bright area is as follows:
[0249] F bright (i,j)=S bright (I(i,j)) (9)
[0250] The two parts are linearly interpolated to obtain the final equalized image:
[0251]
[0252] Where I(i,j) is the gray level of each pixel.
[0253] The F obtained by calculating using the above formula is... final This is the image after average preserving bihistogram equalization.
[0254] After the above data augmentation operations, a total of 7,162 original and newly added images were used, and a total of 9,111 defective targets were identified.
[0255] Example 2:
[0256] The dataset generation stage of the improved YOLOv5-based method for detecting small-target aluminum profile surface defects in this invention is as follows: After step 1, the number of each type of defect has approached equilibrium compared to before the addition, but the number of four types of defects—scratching, orange peel, jetting, and discoloration—is still insufficient. First, a StyleGAN network is used to augment the data, then the data is labeled, and finally, the data is segmented. Step 2 is implemented according to the following steps:
[0257] Step 2.1: For the four types of defects—scrubbing, orange peel, jetting, and discoloration—the StyleGAN network is used to generate simulation images to augment the data of these four defects.
[0258] Step 2.2: Use the open-source LabelImg bounding box annotation tool to annotate the expanded dataset;
[0259] Step 2.3: The expanded dataset is divided into training set, validation set and test set using the hold-out method, with a ratio of 8:1:1. The training set contains 6130 images, the validation set contains 766 images, and the test set contains 766 images.
[0260] Example 3:
[0261] This invention is based on the YOLOv5 model improvement stage in the improved YOLOv5 small target aluminum profile surface defect detection method, combined with... Figures 3-6 Step 3 primarily involves improving the anchor box mechanism, data augmentation methods, attention mechanism, loss function, and structure of the Yolov5-s (minimum) network model to enhance its feature extraction capability for small targets, ultimately proposing the Yolov5-CA-GFPN model. Step 3 is implemented specifically according to the following steps:
[0262] Step 3.1: Replace the Euclidean distance of the original K-Means in the Yolov5 model with (1-IoU);
[0263] Step 3.2: Improve the data augmentation method of the Yolov5 model using Mosaic-9.
[0264] Step 3.3: Add the CA attention mechanism to the minimum network model of Yolov5 to form the Yolov5-CA model;
[0265] Step 3.3: Improve the loss function of the Yolov5-CA model by using Normalized Wasserstein Distance (NWD);
[0266] Step 3.4: Improve the neck module of the Yolov5-CA model using the Generalized Feature Pyramid Network (GFPN) structure;
[0267] Step 3.5: Propose the Yolov5-CA-GFPN model.
[0268] The principle of NWD distance in step 3 is as follows:
[0269] Assuming (cx, cy) are the center coordinates of the horizontal bounding box, w represents the width of the bounding box, and h represents the height of the bounding box, the inscribed ellipse of the bounding box can be represented as:
[0270]
[0271] The probability density function of a two-dimensional Gaussian distribution is determined by the following equation:
[0272]
[0273] In equation (12):
[0274] X represents the coordinates (x, y) of a Gaussian distribution; μ is the mean vector of the Gaussian distribution; T denotes the transpose of the matrix; Σ is the covariance matrix of the Gaussian distribution; Σ -1 Σ represents the inverse of the covariance matrix Σ; the exp function is an exponential function with the natural constant e as its base.
[0275] When equation (13) is satisfied, the inscribed ellipse of equation (11) is the probability density function of a two-dimensional Gaussian distribution.
[0276] (X-μ) T Σ -1 (X-μ)=1 (13)
[0277] Therefore, the horizontal bounding box can be modeled as a two-dimensional Gaussian distribution following N(μ,Σ), where the values of μ and Σ are given by the following equation:
[0278]
[0279] As the above analysis shows, the similarity between bounding boxes can be converted into the distance between their corresponding Gaussian distributions. Assuming Gaussian distributions μ1 = N1(m1, Σ1) and μ2 = N2(m2, Σ2), the distribution distance between them can be calculated using the second-order Wasserstein distance, as shown in the following formula:
[0280]
[0281] In the formula: ||·|| FIt is the Frobenius norm; For distance measurement, m1 and m2 represent the means of two two-dimensional Gaussian distributions, respectively. m1 is the mean vector of the first Gaussian distribution, and m2 is the mean vector of the second Gaussian distribution. These vectors consist of two real numbers, representing the means in the x and y dimensions, respectively. ∑1 and ∑2 represent the covariance matrices of the two two-dimensional Gaussian distributions, respectively. Based on the Gaussian distributions of μ1 and μ2, equation (15) can be simplified to the following equation:
[0282]
[0283] because It is a measure of distance and cannot be directly used as a measure of similarity between Gaussian distributions. Therefore, an exponential change is applied to it to make... Fixed within the interval [0,1], and defined as the NWD distance, as shown in equation (17):
[0284]
[0285] In the formula: C is a constant related to the dataset; NWD(N1, N2) is a new metric for normalized Wasserstein distance (NWD).
[0286] The NWD distance replaces the IoU calculation method for the target loss function in Yolov5-CA, as shown in the following equation:
[0287]
[0288] Where L oss N is the regression loss function based on NWD, N is the number of samples, and P i Let G be the probability distribution of the predicted bounding box for the i-th sample. i Let NWD(P) be the probability distribution of the predicted bounding box for the i-th sample. i G i Var(P) is the normalized Wasserstein distance between the predicted bounding box probability distribution and the true bounding box probability distribution. i ) and Var(G i ) represent the total changes in the predicted bounding box probability distribution and the true bounding box probability distribution, respectively.
[0289] The principle of the Generalized Feature Pyramid Network (GFPN) in step 3:
[0290] The GFPN concept mainly comprises two parts: skip-layer connections and cross-scale connections. Regarding skip-layer connections, GFPN proposes a log₂n skip-layer connection scheme. In this scheme, at each level k, the l-th layer receives connections from the most... The feature map of the previous layer is calculated as shown in equation (19):
[0291]
[0292] in This is the feature map of the l-th layer after skip connections in level k. For the (l-2)th in level k n Feature maps of each layer.
[0293] Regarding cross-scale connectivity, unlike the cross-scale connectivity approach of the Path Aggregation Network (PANet), GFPN employs a fully integrated cross-scale connectivity approach (“Queen-fusion”), which considers features at both the same and adjacent levels.
[0294] By employing two skip-layer connection methods and a Queen-fusion connection method, deep networks can still learn important small target feature information.
[0295] The Yolov5 model improvement stage: After improving the anchor box mechanism, data augmentation method, attention mechanism, loss function and structure of the network model, the model is called Yolov5-CA-GFPN.
[0296] Example 4:
[0297] The defect detection stage of the improved YOLOv5-based method for detecting surface defects in small-target aluminum profiles is implemented according to the following steps:
[0298] Step 4.1: Set the hyperparameters of the Yolov5-CA-GFPN model;
[0299] Step 4.2: Train the Yolov5-CA-GFPN model using the dataset divided in Step 2, and save the network weights;
[0300] Step 4.3: Load the trained Yolov5-CA-GFPN model weights and use the test set for prediction;
[0301] Step 4.4: Obtain the prediction results.
[0302] The input size of the defect image is set to 640*640, the batch size is set to 64, and the number of training epochs is set to 300. The trained weights are saved and loaded during testing to predict defects.
[0303] The above description is merely an embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the present invention should be included within the scope of the claims of the present invention.
Claims
1. An improved method of detecting surface defects in an aluminum profile, characterized in that, Specifically, the following steps are implemented: Step 1, data preprocessing stage; Step 1 is implemented according to the following steps: Step 1.1, select the Aliyun Tianchi contest dataset, which includes single defect pictures, multiple defect pictures and no defect pictures; there are 4356 pictures in the aluminum profile surface defect dataset, including 1210 no defect pictures, 3146 single defect pictures and multiple defect pictures, and the resolution is 2560x1920; single defect pictures and multiple defect pictures contain 10 types of defects, including non-conductive, scratch, corner position missing bottom, orange peel, missing bottom, jet, paint bubble, pit, color and dirt spot, and each picture contains one or more defects; Step 1.2, flip, rotate and add Gaussian noise to single defect pictures, multiple defect pictures and no defect pictures; Step 1.3, use the average preserving double histogram equalization algorithm to enhance the contrast of the pictures in the dataset; Step 1.4, use oversampling method to enhance the image of the dirt spot in the dataset; Step 2, data set generation stage; Step 2 is implemented according to the following steps: Step 2.1, for the four defects of scratch, orange peel, jet and color, use StyleGAN network to generate simulation images to expand the data of the four defects; Step 2.2, use the LabelImg open source bounding box annotation tool to annotate the expanded dataset; Step 2.3, divide the expanded dataset using the leave-out method, divide the dataset into: training set, validation set and test set, the division ratio is: 8:1:1, the number of pictures in the training set is 6130, the number of pictures in the validation set is 766, and the number of pictures in the test set is 766; Step 3, Yolov5 model improvement stage; In step 3, the anchor box mechanism, data enhancement method, attention mechanism, loss function and structure of the Yolov5-s minimum network model are improved to enhance the feature extraction ability of small targets, and the Yolov5-CA-GFPN model is proposed; Step 3 is implemented according to the following steps: Step 3.1, replace the original K-Means Euclidean distance in the Yolov5 model with 1-IoU; Step 3.2, improve the data enhancement method of the Yolov5 model in the mosaic-9 way; Step 3.3, add CA attention mechanism to the minimum network model of Yolov5 to form Yolov5-CA model; Step 3.3, use normalized Wasserstein distance NWD to improve the loss function of Yolov5-CA model; Step 3.4, use the general feature pyramid network structure to improve the neck module of Yolov5-CA model; Step 3.5, propose Yolov5-CA-GFPN model; Step 4, defect detection stage; Step 4 is implemented according to the following steps: Step 4.1, set the Yolov5-CA-GFPN model hyperparameters; Step 4.2, use the dataset divided in step 2 to train the Yolov5-CA-GFPN model and save the network weight; Step 4.3, load the trained Yolov5-CA-GFPN model weight, use the test set to predict; Step 4.4, get the prediction result.
2. The improved method of detecting surface defects in aluminum shapes as claimed in claim 1 wherein, The principle of the average preserving bivariate histogram equalization algorithm in step 1 is as follows: Let the input image be I, with a size of M x N, and a gray level range of [0, L-1], where L represents the number of gray levels. (1) Calculate the histogram H(c) of the original image: where δ(a, b) is the Kronecker Delta function, which is 1 when a = b and 0 otherwise, i represents the row index of the image, which is usually in the range of [0, M-1], where M is the height of the image, j represents the column index of the image, which is usually in the range of [0, N-1], where N is the width of the image, and c represents the gray level in the image. (2) Divide the histogram into light and dark regions; select a threshold T so that the light region contains [0, T] and the dark region contains [T+1, L-1] gray levels. (3) Perform histogram equalization on the light region where H(i) in the formula represents the number of times or frequency of pixels with gray level i appearing in the image. Linearly map the CDF of the light region to the gray level range [0, L-1]: calculating the total number N of pixels of the bright region bright : calculating a cumulative distribution function C of the bright regions bright (c): (4) Similarly, perform histogram equalization on the dark region Linearly map the CDF of the dark region to the gray level range [0, L-1]: S bright (c) = (L - 1) - C bright (c), 0 < c < T (4) where S bright (c) represents the gray level after brightness enhancement; (5) Finally, linearly interpolate the equalization results of the light and dark regions: calculating the total number of pixels N of the dark region dark : calculating a cumulative distribution function C of the dark regions bright (c): For each pixel position (i, j), determine whether it belongs to the light region or the dark region based on its gray level I(i, j); S dark (c) = (L - 1) - C dark (c), T + 1≤ c≤ L - 1 (7) where S dark (c) represents the gray level after darkness enhancement; The gray level of a pixel in the dark region is mapped to: The gray level of a pixel in the light region is mapped to: Linearly interpolate the two parts to obtain the final equalized image j: F dark (i,j) = S dark (I(i,j)) (8) where F dark (i,j) represents the pixel value of the position (i,j) in the dark intensity enhanced image; S dark (I(i,j)) represents the new pixel value calculated according to the pixel value I(i,j) of the position (i,j) in the original image through the dark intensity enhancement formula in the dark intensity enhancement process; S dark The () function performs a dark intensity enhancement operation according to the pixel value I(i,j) in the original image to obtain the corresponding pixel intensity value; where I(i, j) is the gray level of each pixel. F bright (i,j) = S bright (I(i,j)) (9) where F bright (i,j) represents the pixel value of the position (i,j) in the image after brightness enhancement; S bright (I(i,j)) represents the new pixel value calculated according to the pixel value I(i,j) of the position (i,j) in the original image through the brightness enhancement formula in the brightness enhancement process. After the above four data augmentation operations of flipping, rotating, adding Gaussian noise, and average preserving bivariate histogram equalization, the total number of original images and newly added images is 7162, and the total number of defect targets is 9111. After step 1, the number of each type of defect has approached balance compared to before the addition, but there are still not enough numbers for the four defects of scratches, orange peel, jet flow, and miscellaneous colors. Use the StyleGAN network to expand the data, then label the data, and finally divide the data. Through the calculation of the above formula, the F final is the average of the image after the double histogram equalization The principle of NWD distance in step 3 is as follows: Assume that (cx, cy) is the center coordinate of the horizontal bounding box, w represents the width of the bounding box, and h represents the height of the bounding box. The inscribed ellipse of the bounding box is represented as:
3. The improved method of detecting surface defects in aluminum shapes as claimed in claim 1 wherein, The probability density function of the two-dimensional Gaussian distribution is determined by the following formula: In formulas (11) and (12): When formula (13) is satisfied, the inscribed ellipse of formula (11) is the probability density function of the two-dimensional Gaussian distribution: Therefore, the horizontal bounding box is modeled as a two-dimensional Gaussian distribution subject to N(mu, Sigma), and the values of mu and Sigma are given by the following formula: X is a coordinate (x, y) of a Gaussian distribution; μ is a mean vector of the Gaussian distribution; T denotes the transpose of a matrix; Σ is a covariance matrix of the Gaussian distribution; Σ -1 denotes the inverse matrix of the covariance matrix Σ; the exp function is an exponential function with the natural constant e as the base; From the above analysis, the similarity between bounding boxes can be converted into the distance between corresponding Gaussian distributions. Assume that there are Gaussian distributions mu1 = N1(m1, Sigma1) and mu2 = N2(m2, Sigma2). The distribution distance between them is calculated using the second-order Wasserstein distance, as shown in the following formula: (X - μ) T ∑ -1 (X - μ) = 1 (13) According to the Gaussian distribution of mu1 and mu2, formula (15) is simplified to the following formula: where || · || F is the Frobenius norm; is a distance metric, m1 and m2 represent the mean of two two-dimensional Gaussian distributions, respectively; m1 is the mean vector of the first Gaussian distribution and m2 is the mean vector of the second Gaussian distribution, which are composed of two real numbers representing the mean in x and y dimensions, respectively; ∑1 and ∑2 represent the covariance matrix of two two-dimensional Gaussian distributions, respectively; Where cx1 and cy1 are the center coordinates of the first bounding box, cx2 and cy2 are the center coordinates of the second bounding box, w1 and h1 are the width and height of the first bounding box, w2 and h2 are the width and height of the second bounding box; Since is a measure of distance, it cannot be directly used as a measure of similarity between Gaussian distributions, therefore, we use an exponential transformation to make fixed in the interval [0, 1] and define the NWD distance as shown in equation (17): Where C is a constant related to the data set; NWD(N1, N2) is a new measure of NWD distance; The NWD distance replaces the way of calculating the target loss function of IoU in Yolov5-CA as follows: wherein L oss is a regression loss function based on NWD, N is the number of samples, P i is the probability distribution of the predicted bounding box of the i-th sample, G i is the probability distribution of the ground truth bounding box of the i-th sample, NWD(P i , G i ) is the normalized Wasserstein distance between the probability distribution of the predicted bounding box and the probability distribution of the ground truth bounding box, Var(P i ) and Var(G i ) are the total variation of the probability distribution of the predicted bounding box and the probability distribution of the ground truth bounding box, respectively. The principle of the generalized feature pyramid network, GFPN, in step 3 is as follows: The GFPN thought includes two parts of contents of jump layer connection and cross-scale connection. In the aspect of jump layer connection, the GFPN proposes a log2n jump layer connection mode. In each level k, the lth layer accepts the feature maps from the previous layers at most The calculation mode is shown in equation (19). wherein is a feature map of the l-th layer in the level k after the skip connection, is a feature map of the l-2 n th layer in the level k. Regarding cross-scale connection, unlike the cross-scale connection method of the path aggregation network, GFPN adopts a sufficient cross-scale connection, namely the queen fusion method, which considers features of the same level and adjacent levels at the same time; Through the two kinds of jump layer connection methods and the Queen-fusion connection method, the deep network can still learn important small target feature information; After improving the anchor box mechanism, data enhancement method, attention mechanism, loss function and structure of the network model, the network model is called Yolov5-CA-GFPN.
Citation Information
Patent Citations
Aluminum profile surface defect visual detection method based on improved yolov3
CN112991271A
Steel surface defect detection method based on improved YOLOv5s
CN115829991A