Semi-supervised bearing surface defect detection method based on improved YOLOv7

By improving the YOLOv7 algorithm, combined with semi-supervised learning and teacher-student network framework, the problem of large number of model parameters and high labeling cost in bearing surface defect detection is solved, the detection accuracy and generalization ability are improved, and efficient bearing surface defect detection is achieved .

CN118799267APending Publication Date: 2024-10-18CHANGCHUN UNIV OF SCI & TECH
View PDF 0 Cites 16 Cited by

Patent Information

Application Number
CN202410776177.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-17
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

The existing bearing surface defect detection model has a large number of parameters, small defect scale, and high cost of data set annotation, making it difficult to improve detection accuracy and generalization ability under small sample conditions.

Method used

Using a semi-supervised learning method based on YOLOv7, by improving the network structure, including the introduction of heavy parameter convolution, bidirectional feature pyramid and Focal-EIOU loss function, and using the teacher-student network framework to combine labeled and unlabeled data for training, reducing model parameters and improve detection accuracy and generalization ability.

Benefits of technology

It improves the accuracy and speed of bearing surface defect detection under limited samples, reduces data preparation costs, and enhances the robustness and generalization ability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118799267A_ABST
    Figure CN118799267A_ABST
Patent Text Reader

Abstract

The invention discloses a semi-supervised bearing surface defect detection method based on improved YOLOv7, and the method comprises the following steps: S1, collecting a bearing surface defect image, dividing a data set, and marking the data set; s2, optimization and improvement are carried out based on a YOLOv7 algorithm, and an improved YOLOv7-RBE defect detection algorithm is obtained; s3, a YOLOv7-RBE model is used as a reference detection network, and a teacher network and a student network are constructed; s4, in a supervision stage, inputting label data into the student network for pre-training, and copying a pre-training weight to the teacher network; s5, in a semi-supervised stage, inputting label-free data into the teacher network for result prediction to obtain a preliminary pseudo label; and S6, jointly training a detection model by the data with the labels and the data without the labels with the pseudo labels, and transmitting weight parameters of the student network to the teacher network in real time. The method is used for solving the problems that an existing bearing surface defect detection model is large in parameter quantity and small in bearing defect scale, and a current public data set is insufficient and high in marking cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of target detection, and in particular relates to a bearing surface defect detection method based on semi-supervised learning. Background Art

[0002] As a key component in mechanical equipment, the surface quality of bearings directly affects the performance and service life of the equipment. Effective detection of defects on the bearing surface, such as cracks, pits and scratches, can not only improve product quality, reduce equipment failures and downtime, but also reduce maintenance costs and extend the service life of the equipment. However, under the conditions of industrial production lines, only a small number of representative defect samples can be obtained, which is difficult to cover all possible defects. Collecting and labeling defect samples at the same time is a labor-intensive task, especially for high-precision labeling requirements, which is a huge burden in terms of economic and time costs. In addition, under small sample conditions, traditional machine learning algorithms are prone to overfitting and are difficult to generalize to unseen defect types, and cannot meet the needs of efficient and accurate detection. Therefore, by studying and applying advanced image processing and deep learning technologies, automatic detection and classification of bearing surface defects can be achieved, which will help improve detection efficiency and accuracy and promote the development of manufacturing industry towards intelligence and efficiency. This is not only of great significance to improving production efficiency and product quality, but also can enhance the market competitiveness of enterprises and promote technological progress in the entire industry.

[0003] In recent years, with the rapid development of deep learning technology, deep learning-based defect target detection algorithms have gradually replaced traditional machine learning methods. Although advanced technologies such as deep learning have shown excellent performance in areas such as image recognition, their success is often based on big data support. At present, surface defect detection based on deep learning usually adopts a fully supervised model, which relies on a large number of accurate manually labeled samples for training and requires a lot of time and human resources. How to reduce the number of model parameters and improve the detection accuracy of subtle defects in the small sample scenario of defect detection has become a key issue that needs to be solved urgently.

[0004] Therefore, the present invention proposes a semi-supervised bearing surface defect detection method based on YOLOv7 to solve the problems of large number of parameters in the existing bearing surface defect detection model, small scale of bearing defects, insufficient public data set and high annotation cost, so as to improve the detection accuracy, speed and generalization ability based on limited samples. Summary of the invention

[0005] 1. Technical issues to be solved

[0006] In order to overcome the shortcomings of the prior art, the present invention proposes a semi-supervised bearing surface defect detection method based on YOLOv7 to solve the problems of large number of parameters in the existing bearing surface defect detection model, small scale of bearing defects, and insufficient public data sets and high annotation cost. This method can effectively improve the detection accuracy, speed and generalization ability based on limited samples.

[0007] (II) Technical solution

[0008] In order to achieve the above-mentioned purpose, the present invention specifically adopts the following technical solutions:

[0009] A semi-supervised bearing surface defect detection method based on improved YOLOv7, the method comprising the following steps:

[0010] S1. Collect bearing surface defect images, divide the data set and annotate them;

[0011] S2. Based on the YOLOv7 algorithm, the improved YOLOv7-RBE defect detection algorithm is obtained;

[0012] S3. Use the YOLOv7-RBE model as the benchmark detection network and build a teacher network and a student network;

[0013] S4. In the supervision phase, labeled data is input into the student network for pre-training, and the pre-trained weights are copied to the teacher network;

[0014] S5. In the semi-supervised stage, unlabeled data is input into the teacher network for result prediction to obtain preliminary pseudo labels;

[0015] S6. The detection model is trained jointly with labeled data and unlabeled data with pseudo labels, and the weight parameters of the student network are passed to the teacher network in real time.

[0016] Furthermore, the S1: collecting bearing surface defect images, dividing the data set and annotating them, specifically includes:

[0017] The experimental data set is a self-made bearing surface defect data set. A total of 2174 bearing surface defect images were collected from different lighting directions. The image pixel size is 1280×1024. The data set contains four defect types: notches, abrasions, scratches, and rust spots. There are 436 notch images, 602 abrasion images, 611 scratch images, and 525 rust spot images.

[0018] The bearing surface defect dataset is divided into unlabeled dataset and labeled dataset according to the set ratio of 9:1. The images divided into labeled dataset are annotated using labelimg software to mark the types and locations of bearing surface defects. The labels of notches are Breath, abrasions are Abrade, scratches are Scratch, and rust spots are Rust. After the annotation is completed, a txt annotation file in YOLO format is obtained. Finally, the labeled dataset is divided into training set and test set according to the ratio of 8:2.

[0019] Further, the improved YOLOv7 network structure described in S2 includes the following steps:

[0020] Step 1: Replace the four ELAN modules in the backbone network with ELAN-REP modules containing re-parameterized convolution (RepConv) to reduce the number of model parameters;

[0021] Step 2: In the feature fusion stage, a bidirectional feature pyramid is introduced to reconstruct the neck network, so that the network has higher feature fusion efficiency and ability, and improves the model's detection performance for small targets;

[0022] Step 3: Use Focal-EIOU as the bounding box regression loss function in the prediction stage. By adjusting the impact of low-quality and high-quality samples on the loss function, fine-tune the bounding box regression, so that the model pays more attention to high-quality anchor boxes and improves detection performance and stability.

[0023] Furthermore, the four ELAN modules in the backbone network described in step 1 are replaced by an ELAN-REP module including a re-parameterized convolution (RepConv), specifically:

[0024] The original YOLOv7 architecture uses a large number of ELAN modules. Although this design can enhance feature expression, its dense stacking greatly increases the number of parameters and complexity of the model, affecting the detection performance. In order to solve this problem and promote more efficient feature extraction, the ELAN module is optimized. The introduction of efficient re-parameterized convolution improves the feature extraction efficiency and detection accuracy of the model. By simplifying the model architecture, the inference process is effectively accelerated, achieving dual optimization of performance and efficiency.

[0025] Reparameterization mainly optimizes the network during the training and inference stages to improve the model's computational efficiency and performance. Reparameterization mainly includes two steps: first, the multi-branch structure of the training stage, such as Figure 1As shown in the figure, in the training phase, a convolutional structure containing multiple branches is used to increase the expressiveness and training effect of the model. These branches can include convolution (Conv) and different normalization layers (BN) and activation functions. The second is the single-branch structure in the reasoning phase. In the reasoning phase, the multi-branch structure in the training phase is merged into a single-branch convolutional structure through parameter rearrangement. This step merges the weights and biases of multiple branches into a standard convolutional layer through mathematical transformation, thereby reducing computational overhead and improving reasoning efficiency while maintaining the performance advantage of the training phase.

[0026] In order to further improve the efficiency of the YOLOv7 network in the inference stage, the present invention designs the ELAN-REP module by adopting heavy parameter convolution to replace the specific ordinary convolution layers in the four ELAN modules of the original algorithm backbone network.

[0027] Furthermore, in step 2, a bidirectional feature pyramid is introduced in the feature fusion stage to reconstruct the neck network, specifically:

[0028] The original YOLOv7 algorithm uses feature pyramids and path aggregation networks in the neck layer to extract information from different feature layers. However, when faced with tiny defects on the bearing surface, there is a problem of reduced detection accuracy due to the loss of feature details. In order to enhance feature fusion between different scales and improve detection accuracy, the present invention introduces a weighted bidirectional feature fusion network, which intelligently weights and fuses features at different levels and constructs cross-scale feature connections, thereby significantly enhancing the accuracy of the model in small-scale target detection and optimizing feature utilization efficiency.

[0029] Compared with the superposition of traditional feature pyramid and path aggregation network, the bidirectional feature pyramid (BiFPN) deletes nodes with only one input edge, reducing redundant calculations; all nodes in the bidirectional feature pyramid have more than two input edges, which increases the feature fusion capability of the model; in addition, by adding jump connections, more features can be fused at a lower cost. The bidirectional feature pyramid can discriminate and fuse different input features, assign different weights to them, and use fast normalized weighted feature fusion. The weighted feature fusion calculation method of the bidirectional feature pyramid is:

[0030]

[0031] Among them, ω is the learnable weight; I i is the input feature; ε = 0.0001.

[0032] The present invention optimizes the neck structure of the YOLOv7 model and replaces the original feature pyramid and path aggregation structure with a weighted bidirectional feature pyramid network, thereby achieving more efficient fusion of the three feature maps output by the backbone network and enhancing the feature fusion efficiency and capability of the model.

[0033] Furthermore, in step 3, Focal-EIOU is used as the bounding box regression loss function in the prediction stage, specifically:

[0034] The loss function of the YOLO series consists of three parts: bounding box regression loss, confidence loss, and classification loss. YOLOv7 uses CIOU loss to optimize bounding box regression to overcome the limitation that the GIOU loss function degenerates into IOU loss in some situations, such as when the predicted box is completely surrounded by the real box. CIOU introduces the aspect ratio of the predicted box and the real box into the loss value for calculation, which effectively solves the problem of guiding the correct movement direction of the bounding box when the predicted box does not overlap with the real box. However, like the GIOU loss, neither of them fully considers the directional deviation between the predicted box and the real box, which limits the convergence efficiency and positioning accuracy.

[0035] The present invention adopts the Focal-EIOU loss function. This loss function adjusts the influence of low-quality and high-quality samples on the loss function by performing IOU weighting on the EIOU loss value, and finely optimizes the bounding box regression, so that the model can focus more on high-quality anchor boxes, improve detection performance and stability, and accelerate the convergence speed of the model.

[0036] Furthermore, the YOLOv7-RBE model described in S3 is used as a benchmark detection network to construct a teacher network and a student network, specifically:

[0037] The core idea of ​​the teacher-student network is to use existing labeled data as a "teacher" to guide the learning process of unlabeled data, so that unlabeled data can also actively participate in model training. In this process, the teacher network is often first trained on a small, labeled dataset to obtain a more mature model, and then assigns pseudo-labels (pseudo-labels), i.e. predicted category labels, to the unlabeled data based on its existing knowledge. Then, the student network is trained using these unlabeled data with pseudo-labels and the original labeled data. In order to promote the robustness of the model weights and the stability of prediction, the teacher network is updated using the exponential moving average of the student network parameters. With the deepening of the iterative process, the weights of the teacher network will become more stable, thereby gradually improving the quality of the pseudo-labels and the generalization ability of the model.

[0038] In order to enhance the robustness of the semi-supervised defect detection model, strong and weak data augmentation strategies were adopted at different stages. Strong augmentation includes covering, blurring, changing chromaticity, etc., while weak augmentation includes rotation, translation, mirroring, etc.

[0039] Furthermore, in the supervision phase described in S4, labeled data is input into the student network for pre-training, and the pre-training weights are copied to the teacher network, specifically:

[0040] First, the labeled data is weakly enhanced and then input into the student network for supervised training to obtain a pre-trained weight, and then the pre-trained weight is copied to the teacher network for teacher network learning. The number of training rounds is set to 200, the group size is set to 32, and the image size is set to 640×640. The loss at this stage is the supervised loss, i.e., Ls, which is defined as:

[0041]

[0042] in, represents the i-th labeled cloth image, is the confidence loss, L cls is the defect classification loss, L box is the candidate box regression loss, K l is the number of labeled images.

[0043] Furthermore, in the semi-supervised stage described in S5, the unlabeled data is input into the teacher network for result prediction to obtain preliminary pseudo labels, specifically:

[0044] After weak enhancement, the unlabeled data is input into the teacher network, and the teacher network with updated weight parameters is used for inference prediction. The prediction results are then filtered through NMS (Non-Maximum Suppression) to remove redundant boxes and obtain preliminary pseudo labels. The variance filtering algorithm in Box Jittering is then used to filter the pseudo labels. The high-quality pseudo-label data after filtering is strongly enhanced to guide the student network to learn the features of unlabeled data. The loss at this stage is the unsupervised loss, i.e., Lu, which is defined as:

[0045]

[0046] in, Indicates Unlabeled cloth images, is the confidence loss, L cls is the defect classification loss, L box is the candidate box regression loss, K u is the number of unlabeled images.

[0047] The box jittering method used in this paper is proposed by Soft Teacher, which determines whether the positioning of a bounding box is reliable by measuring the consistency of the regression results. Given a pseudo bounding box b generated by the teacher network i , sample a jitter box around it, and input the jitter box into the teacher model to obtain a refined bounding box

[0048]

[0049] By repeating the above operation, a series of finely adjusted frames can be collected. The smaller the variance of these frames, the higher the positioning reliability. This method effectively improves the reliability of pseudo labels. The following is the formula of the variance filter algorithm used to filter jitter frames:

[0050]

[0051] Where σ k is to extract the jitter frame set, {b i,j The standard derivation rule for the kth coordinate in} is: is k Normalization, h(b i ) and w(b i ) are the height and width of the candidate box respectively, is the candidate box b i The jitter box regression variance mean is also the basis for jitter box generation.

[0052] Furthermore, the labeled data and the unlabeled data with pseudo labels described in S6 are used to jointly train the detection model, and the weight parameters of the student network are transferred to the teacher network in real time, specifically:

[0053] The detection model is trained with labeled data and unlabeled data with pseudo labels, and the weight parameters of the student network are passed to the teacher network for update in real time through the exponential moving average method (EMA). This cycle is repeated to obtain more stable and reliable pseudo labels, gradually improving the detection accuracy of the entire model. The loss at this stage is the semi-supervised loss, which is the sum of the supervised loss and the unsupervised loss. The semi-supervised loss is defined as:

[0054] L=L S +λ μ L u

[0055] Among them, L S There is supervision loss, L u is the unsupervised loss, λ μ is the unsupervised loss weight, which is used to balance the supervised loss and the unsupervised loss.

[0056] The present invention adopts the exponential moving average (EMA) strategy to update the teacher model with the student model, so that the pseudo label can reinforce the defect detection network and improve the robustness of the detection model. The formula is as follows:

[0057] EMA[t]=α*x[t]+(1-α)*EMA[t-1]

[0058] Where t represents the time step, x[t] represents the original data at the tth time point, α is the smoothing factor, which usually takes a value between 0 and 1, indicating the weight of the current sample. In this experiment, it is set to 0.999, (1-α) represents the weight of historical data, and EMA[t-1] represents the EMA value at the previous time point.

[0059] (III) Beneficial effects

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

[0061] 1. The present invention introduces re-parameterized convolution to optimize the network and improve the computational efficiency and performance of the model. In the training phase, RepConv increases the expressiveness of the model by using a multi-branch convolution structure, enabling it to better capture and represent complex features, thereby improving the overall performance of the model. In the inference phase, RepConv re-parameterizes the multi-branch convolution structure into a single-branch convolution. This greatly reduces computational complexity and memory consumption, thereby speeding up inference, making it more efficient and easy to deploy.

[0062] 2. The present invention introduces a bidirectional feature pyramid, which captures more contextual information through bidirectional feature fusion and weighted connection, and improves the model's ability to detect small-scale targets. At the same time, the bidirectional feature pyramid reduces computational redundancy and improves computational efficiency by deleting nodes with only one input edge, making the model more lightweight. The weighted feature fusion mechanism is introduced to assign different weights to different input features, and perform fast normalized weighted fusion, making the feature fusion process more flexible and sophisticated, further improving detection accuracy.

[0063] 3. The present invention replaces the loss function with Focal-EIOU, and can perform weighted processing on the EIOU loss, so that the model can more finely optimize the positioning of the border during border regression, while reducing the loss contribution of easy samples, so that the model pays more attention to the detection of difficult samples and small objects. Focal-EIOU can adjust the impact of low-quality samples and high-quality samples on the loss function, so that the model pays more attention to high-quality anchor boxes, which helps the model converge faster.

[0064] 4. The present invention uses the teacher-student network as a semi-supervised learning framework. By combining a small amount of labeled data and a large amount of unlabeled data for training, the model can more comprehensively understand the distribution characteristics of the data, which not only improves the learning efficiency and the generalization ability of the model, but also significantly reduces the dependence on labeled data and reduces the cost of data preparation. In different stages, two data enhancement strategies, strong and weak, are used to enhance the robustness of the semi-supervised defect model; the box jitter variance filter algorithm is used to screen the pseudo-labels, which effectively improves the reliability of the pseudo-labels; the exponential moving average (EMA) strategy is used to update the teacher model with the student model, so as to achieve mutual promotion between the pseudo-labels and the bearing defect detection network and enhance the robustness of the detection model. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] Figure 1 It is a flow chart of a semi-supervised bearing surface defect detection method based on improved YOLOv7 of the present invention;

[0066] Figure 2 It is a network structure diagram of the improved YOLOv7-RBE model of the present invention;

[0067] Figure 3 Schematic diagram of the multi-branch fusion module of heavy parameter convolution adopted by the present invention;

[0068] Figure 4 It is a schematic diagram of the structure of the improved ELAN-REP module of the present invention;

[0069] Figure 5 It is a weighted bidirectional feature pyramid network structure diagram in the present invention;

[0070] Figure 6 This is the overall architecture diagram of the semi-supervised defect detection network based on the teacher-student network of the present invention. DETAILED DESCRIPTION

[0071] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0072] Example

[0073] As reference Figure 1 As shown, this embodiment is a semi-supervised bearing surface defect detection method based on improved YOLOv7, including the following steps:

[0074] S1: Collect bearing surface defect images, divide the data set and annotate them;

[0075] The experimental data set is a self-made bearing surface defect data set. A total of 2174 bearing surface defect images were collected from different lighting directions. The image pixel size is 1280×1024. The data set contains four defect types: notches, abrasions, scratches, and rust spots. There are 436 notch images, 602 abrasion images, 611 scratch images, and 525 rust spot images.

[0076] The bearing surface defect dataset is divided into unlabeled dataset and labeled dataset according to the set ratio of 9:1. The images divided into labeled dataset are annotated using labelimg software to mark the types and locations of bearing surface defects. The labels of notches are Breath, abrasions are Abrade, scratches are Scratch, and rust spots are Rust. After the annotation is completed, a txt annotation file in YOLO format is obtained. Finally, the labeled dataset is divided into training set and test set according to the ratio of 8:2.

[0077] S2: Based on the YOLOv7 algorithm, the improved YOLOv7-RBE defect detection algorithm is obtained;

[0078] like Figure 2 As shown in the figure, the process of improving the YOLOv7 network structure includes: first, replacing the four ELAN modules in the backbone network with the ELAN-REP module containing the heavy parameter convolution (RepConv) to reduce the number of model parameters; second, introducing a bidirectional feature pyramid reconstruction neck network in the feature fusion stage to make the network have higher feature fusion efficiency and ability, and improve the model's detection performance for small targets; finally, using Focal-EIOU as the border regression loss function in the prediction stage, by adjusting the influence of low-quality samples and high-quality samples on the loss function, finely optimizing the border regression, so that the model pays more attention to high-quality anchor boxes, and improves detection performance and stability.

[0079] like Figure 3 Figure 4 As shown, the four ELAN modules in the backbone network are replaced by ELAN-REP modules containing re-parameterized convolution (RepConv), specifically:

[0080] The original YOLOv7 architecture uses a large number of ELAN modules. Although this design can enhance feature expression, its dense stacking greatly increases the number of parameters and complexity of the model, affecting the detection performance. In order to solve this problem and promote more efficient feature extraction, the ELAN module is optimized. The introduction of efficient re-parameterized convolution improves the feature extraction efficiency and detection accuracy of the model. By simplifying the model architecture, the inference process is effectively accelerated, achieving dual optimization of performance and efficiency.

[0081] Reparameterization mainly optimizes the network during the training and inference stages to improve the model's computational efficiency and performance. Reparameterization mainly includes two steps: first, the multi-branch structure of the training stage, such as Figure 1 As shown in the figure, in the training phase, a convolutional structure containing multiple branches is used to increase the expressiveness and training effect of the model. These branches can include convolution (Conv) and different normalization layers (BN) and activation functions. The second is the single-branch structure in the reasoning phase. In the reasoning phase, the multi-branch structure in the training phase is merged into a single-branch convolutional structure through parameter rearrangement. This step merges the weights and biases of multiple branches into a standard convolutional layer through mathematical transformation, thereby reducing computational overhead and improving reasoning efficiency while maintaining the performance advantage of the training phase.

[0082] In order to further improve the efficiency of the YOLOv7 network in the inference stage, the present invention designs the ELAN-REP module by adopting heavy parameter convolution to replace the specific ordinary convolution layers in the four ELAN modules of the original algorithm backbone network.

[0083] like Figure 5 As shown, the bidirectional feature pyramid is introduced in the feature fusion stage to reconstruct the neck network, specifically:

[0084] The original YOLOv7 algorithm uses feature pyramids and path aggregation networks in the neck layer to extract information from different feature layers. However, when faced with tiny defects on the bearing surface, there is a problem of reduced detection accuracy due to the loss of feature details. In order to enhance feature fusion between different scales and improve detection accuracy, the present invention introduces a weighted bidirectional feature fusion network, which intelligently weights and fuses features at different levels and constructs cross-scale feature connections, thereby significantly enhancing the accuracy of the model in small-scale target detection and optimizing feature utilization efficiency.

[0085] Compared with the superposition of traditional feature pyramid and path aggregation network, the bidirectional feature pyramid (BiFPN) deletes nodes with only one input edge, reducing redundant calculations; all nodes in the bidirectional feature pyramid have more than two input edges, which increases the feature fusion capability of the model; in addition, by adding jump connections, more features can be fused at a lower cost. The bidirectional feature pyramid can discriminate and fuse different input features, assign different weights to them, and use fast normalized weighted feature fusion. The weighted feature fusion calculation method of the bidirectional feature pyramid is:

[0086]

[0087] Among them, ω is the learnable weight; I i is the input feature; ε = 0.0001.

[0088] The present invention optimizes the neck structure of the YOLOv7 model and replaces the original feature pyramid and path aggregation structure with a weighted bidirectional feature pyramid network, thereby achieving more efficient fusion of the three feature maps output by the backbone network and enhancing the feature fusion efficiency and capability of the model.

[0089] The Focal-EIOU is used as the border regression loss function in the prediction stage, specifically:

[0090] The loss function of the YOLO series consists of three parts: bounding box regression loss, confidence loss, and classification loss. YOLOv7 uses CIOU loss to optimize bounding box regression to overcome the limitation that the GIOU loss function degenerates into IOU loss in some situations, such as when the predicted box is completely surrounded by the real box. CIOU introduces the aspect ratio of the predicted box and the real box into the loss value for calculation, which effectively solves the problem of guiding the correct movement direction of the bounding box when the predicted box does not overlap with the real box. However, like the GIOU loss, neither of them fully considers the directional deviation between the predicted box and the real box, which limits the convergence efficiency and positioning accuracy.

[0091] The present invention adopts the Focal-EIOU loss function. This loss function adjusts the influence of low-quality and high-quality samples on the loss function by performing IOU weighting on the EIOU loss value, and finely optimizes the bounding box regression, so that the model can focus more on high-quality anchor boxes, improve detection performance and stability, and accelerate the convergence speed of the model.

[0092] As described in S3, the YOLOv7-RBE model is used as the benchmark detection network to build a teacher network and a student network, specifically:

[0093] The core idea of ​​the teacher-student network is to use existing labeled data as a "teacher" to guide the learning process of unlabeled data, so that unlabeled data can also actively participate in model training. In this process, the teacher network is often first trained on a small, labeled dataset to obtain a more mature model, and then assigns pseudo-labels (pseudo-labels), i.e. predicted category labels, to the unlabeled data based on its existing knowledge. Then, the student network is trained using these unlabeled data with pseudo-labels and the original labeled data. In order to promote the robustness of the model weights and the stability of prediction, the teacher network is updated using the exponential moving average of the student network parameters. With the deepening of the iterative process, the weights of the teacher network will become more stable, thereby gradually improving the quality of the pseudo-labels and the generalization ability of the model.

[0094] In order to enhance the robustness of the semi-supervised defect detection model, strong and weak data augmentation strategies were adopted at different stages. Strong augmentation includes covering, blurring, changing chromaticity, etc., while weak augmentation includes rotation, translation, mirroring, etc.

[0095] In the supervision phase described in S4, labeled data is input into the student network for pre-training, and the pre-trained weights are copied to the teacher network, specifically:

[0096] First, the labeled data is weakly enhanced and then input into the student network for supervised training to obtain a pre-trained weight, and then the pre-trained weight is copied to the teacher network for teacher network learning. The number of training rounds is set to 200, the group size is set to 32, and the image size is set to 640×640. The loss at this stage is the supervised loss, i.e., Ls, which is defined as:

[0097]

[0098] in, represents the i-th labeled cloth image, is the confidence loss, L cls is the defect classification loss, L box is the candidate box regression loss, K l is the number of labeled images.

[0099] In the semi-supervised stage described in S5, unlabeled data is input into the teacher network for result prediction to obtain preliminary pseudo labels, specifically:

[0100] After weak enhancement, the unlabeled data is input into the teacher network, and the teacher network with updated weight parameters is used for inference prediction. The prediction results are then filtered through NMS (Non-Maximum Suppression) to remove redundant boxes and obtain preliminary pseudo labels. The variance filtering algorithm in Box Jittering is then used to filter the pseudo labels. The high-quality pseudo-label data after filtering is strongly enhanced to guide the student network to learn the features of unlabeled data. The loss at this stage is the unsupervised loss, i.e., Lu, which is defined as:

[0101]

[0102] in, Indicates Unlabeled cloth images, is the confidence loss, L cls is the defect classification loss, L box is the candidate box regression loss, K u is the number of unlabeled images.

[0103] The box jittering method used in this paper is proposed by Soft Teacher, which determines whether the positioning of a bounding box is reliable by measuring the consistency of the regression results. Given a pseudo bounding box b generated by the teacher network i , sample a jitter box around it, and input the jitter box into the teacher model to obtain a refined bounding box

[0104]

[0105] By repeating the above operation, a series of finely adjusted frames can be collected. The smaller the variance of these frames, the higher the positioning reliability. This method effectively improves the reliability of pseudo labels. The following is the formula of the variance filter algorithm used to filter jitter frames:

[0106]

[0107] Where σ k is to extract the jitter frame set, {b i,j The standard derivation rule for the kth coordinate in} is: is k Normalization, h(b i ) and w(b i ) are the height and width of the candidate box respectively, is the candidate box b i The jitter box regression variance mean is also the basis for jitter box generation.

[0108] The labeled data and the unlabeled data with pseudo labels described in S6 jointly train the detection model, and the weight parameters of the student network are passed to the teacher network in real time, specifically:

[0109] The detection model is trained with labeled data and unlabeled data with pseudo labels, and the weight parameters of the student network are passed to the teacher network for update in real time through the exponential moving average method (EMA). This cycle is repeated to obtain more stable and reliable pseudo labels, gradually improving the detection accuracy of the entire model. The loss at this stage is the semi-supervised loss, which is the sum of the supervised loss and the unsupervised loss. The semi-supervised loss is defined as:

[0110] L=L S +λ μ L u

[0111] Among them, L S is the supervised loss, L u is the unsupervised loss, λ μ is the unsupervised loss weight, which is used to balance the supervised loss and the unsupervised loss.

[0112] The present invention adopts the exponential moving average (EMA) strategy to update the teacher model with the student model, so that the pseudo label can reinforce the defect detection network and improve the robustness of the detection model. The formula is as follows:

[0113] EMA[t]=α*x[t]+(1-α)*EMA[t-1]

[0114] Where t represents the time step, x[t] represents the original data at the tth time point, α is the smoothing factor, which usually takes a value between 0 and 1, indicating the weight of the current sample. In this experiment, it is set to 0.999, (1-α) represents the weight of historical data, and EMA[t-1] represents the EMA value at the previous time point.

[0115] Summary: The present invention provides a semi-supervised bearing surface defect detection method based on improved YOLOv7, which is used to solve the problems of large number of parameters in the existing bearing surface defect detection model, small scale of bearing defects, insufficient public data set and high annotation cost, so as to improve the detection accuracy, speed and generalization ability based on limited samples.

[0116] Finally, it should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A semi-supervised bearing surface defect detection method based on improved YOLOv7, characterized in that: The method comprises the following steps: S1. Collect bearing surface defect images, divide the data set and annotate them; S2. Based on the YOLOv7 detection algorithm, the improved YOLOv7-RBE target detection algorithm is obtained; S3. Use the YOLOv7-RBE model as the benchmark detection network and build a teacher network and a student network; S4. In the supervision phase, labeled data is input into the student network for pre-training, and the pre-trained weights are copied to the teacher network; S5. In the semi-supervised stage, unlabeled data is input into the teacher network for result prediction to obtain preliminary pseudo labels; S6. The detection model is trained jointly with labeled data and unlabeled data with pseudo labels, and the weight parameters of the student network are passed to the teacher network in real time.

2. According to claim 1, a semi-supervised bearing surface defect detection method based on improved YOLOv7 is characterized in that: The specific process of S1 is as follows: The experimental data set is a self-made bearing surface defect data set. A total of 2174 bearing surface defect images were collected from different lighting directions. The image pixel size is 1280×1024. The data set contains four defect types: notches, abrasions, scratches, and rust spots. There are 436 notch images, 602 abrasion images, 611 scratch images, and 525 rust spot images. The bearing surface defect dataset is divided into an unlabeled dataset and a labeled dataset according to the set ratio of 9:

1. The images divided into the labeled dataset are annotated using labelimg software to mark the types and locations of bearing surface defects. The labels of notches are Breath, abrasions are Abrade, scratches are Scratch, and rust spots are Rust. After the labeling is completed, a txt annotation file in YOLO format is obtained. Finally, the labeled dataset is divided into a training set and a test set according to the ratio of 8:

2.

3. A semi-supervised bearing surface defect detection method based on improved YOLOv7 according to claim 1, characterized in that: The improved YOLOv7 network structure described in S2 includes the following steps: Step 1: Replace the four ELAN modules in the backbone network with ELAN-REP modules containing re-parameterized convolution (RepConv) to reduce the number of model parameters; Step 2: In the feature fusion stage, a bidirectional feature pyramid is introduced to reconstruct the neck network, so that the network has higher feature fusion efficiency and ability, and improves the model's detection performance for small targets; Step 3: Use Focal-EIOU as the bounding box regression loss function in the prediction stage. By adjusting the impact of low-quality and high-quality samples on the loss function, fine-tune the bounding box regression, so that the model pays more attention to high-quality anchor boxes and improves detection performance and stability.

4. A semi-supervised bearing surface defect detection method based on improved YOLOv7 according to claim 1, characterized in that: S3: Use the YOLOv7-RBE model as the benchmark detection network to build a teacher network and a student network, specifically: The core idea of ​​the teacher-student network is to use existing labeled data as a "teacher" to guide the learning process of unlabeled data, so that unlabeled data can also actively participate in model training. In this process, the teacher network is often first trained on a small, labeled dataset to obtain a more mature model, and then assigns pseudo labels, i.e. predicted category labels, to the unlabeled data based on its existing knowledge. The student network is then trained using these unlabeled data with pseudo labels and the original labeled data. In order to promote the robustness of the model weights and the stability of prediction, the teacher network is updated using the exponential moving average of the student network parameters. As the iterative process deepens, the weights of the teacher network will become more stable, thereby gradually improving the quality of the pseudo labels and the generalization ability of the model. In order to enhance the robustness of the semi-supervised defect detection model, strong and weak data augmentation strategies were adopted at different stages. Strong augmentation includes covering, blurring, changing chromaticity, etc., while weak augmentation includes rotation, translation, mirroring, etc.

5. A semi-supervised bearing surface defect detection method based on improved YOLOv7 according to claim 1, characterized in that: The specific process of S4 is as follows: First, the labeled data is weakly enhanced and then input into the student network for supervised training to obtain a pre-trained weight, and then the pre-trained weight is copied to the teacher network for teacher network learning. The number of training rounds is set to 200, the group size is set to 32, and the image size is set to 640×640. The loss at this stage is the supervised loss, i.e., Ls, which is defined as: in, represents the i-th labeled cloth image, is the confidence loss, L cls is the defect classification loss, L box is the candidate box regression loss, K l is the number of labeled images.

6. A semi-supervised bearing surface defect detection method based on improved YOLOv7 according to claim 1, characterized in that: The specific process of S5 is as follows: After weak enhancement, the unlabeled data is input into the teacher network, and the teacher network with updated weight parameters is used for inference prediction. The prediction results are then filtered through NMS (Non-Maximum Suppression) to remove redundant boxes and obtain preliminary pseudo labels. The variance filtering algorithm in Box Jittering is then used to filter the pseudo labels. The high-quality pseudo-label data after filtering is strongly enhanced to guide the student network to learn the features of unlabeled data. The loss at this stage is the unsupervised loss, i.e., Lu, which is defined as: in, Indicates Unlabeled cloth images, is the confidence loss, L cls is the defect classification loss, L box is the candidate box regression loss, K u is the number of unlabeled images.

7. A semi-supervised bearing surface defect detection method based on improved YOLOv7 according to claim 1, characterized in that: The specific process of S6 is as follows: The detection model is trained with labeled data and unlabeled data with pseudo labels, and the weight parameters of the student network are passed to the teacher network for update in real time through the exponential moving average method (EMA). This cycle is repeated to obtain more stable and reliable pseudo labels, gradually improving the detection accuracy of the entire model. The loss at this stage is the semi-supervised loss, which is the sum of the supervised loss and the unsupervised loss. The semi-supervised loss is defined as: L=L s +λ μ L u Among them, Ls is the supervised loss, L u is the unsupervised loss, λ μ is the unsupervised loss weight, which is used to balance the supervised loss and the unsupervised loss.

Citation Information

Cited By

  • Semi-supervised microcrack detection method based on SSMD

    CN119048511A

  • A semi-supervised microcrack detection method based on SSMD

    CN119048511B

  • Multi-source partial discharge intelligent identification method and system based on YOLOv7 algorithm

    CN119295831A

  • Mangrove forest carbon reserve prediction method, electronic equipment and storage medium

    CN119475046A

  • A method for predicting mangrove carbon reserves, electronic equipment and storage medium

    CN119475046B