Target detection method and system based on YOLO architecture
By obtaining labeled and unlabeled training images, using the initial YOLO model to generate detection results and generate pseudo-labels, dynamically adjust the detection head weight, and combining the loss function to update the model, the problem of insufficient detection accuracy of the YOLO architecture in complex scenarios is solved, and the recognition ability and robustness of multi-scale targets are improved.
Patent Information
- Application Number
- CN202510529323.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2045-04-25
AI Technical Summary
The existing YOLO architecture-based object detection methods have the problem of insufficient detection accuracy in complex scenarios or small object detection, especially in scenarios where occlusion, lighting changes or target overlap, and the detection box deduplication algorithm has low screening efficiency for dense targets.
By obtaining labeled and untagged training images, the detection results are generated using the initial YOLO model, and pseudo-labels are generated based on the teacher model, the weight coefficient of the detection head is dynamically adjusted, and the model is iteratively updated with supervised and unsupervised loss functions to optimize the detection accuracy.
It improves the multi-scale object detection accuracy and robustness of the model in complex scenarios, enhances the adaptability to different scenario features, and solves the problem of limited multi-scale object recognition capabilities of traditional YOLO models.
Smart Images

Figure CN120451497A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a target detection method and system based on the YOLO architecture. Background Art
[0002] Existing object detection methods based on the YOLO architecture generally suffer from insufficient detection accuracy in complex scenes or for small targets. Specifically, the traditional YOLO model's detection head has fixed weights, making it difficult to adapt to the feature distribution of targets of different scales, resulting in limited recognition of multi-scale targets. Furthermore, the multi-scale feature fusion mechanism does not adequately combine shallow detail features with deep semantic features, making missed detections or false detections more likely, especially in scenarios with occlusion, changing lighting, or overlapping targets. Furthermore, the detection box deduplication algorithm is inefficient in screening densely packed targets, further reducing the accuracy of detection results.
[0003] The disclosure of the above background technology content is only used to assist in understanding the concept and technical solution of the present invention. It does not necessarily belong to the prior art of this patent application. In the absence of clear evidence that the above content has been disclosed on the filing date of this patent application, the above background technology should not be used to evaluate the novelty and creativity of this application. Summary of the Invention
[0004] This application provides a target detection method and system based on the YOLO architecture, which can effectively improve the detection accuracy of multi-scale targets in complex scenes.
[0005] To achieve the above objectives, the present application discloses the following technical solutions:
[0006] In a first aspect, an embodiment of the present application provides a target detection method based on the YOLO architecture, comprising the following steps:
[0007] Obtain labeled training images and unlabeled training images;
[0008] Perform target detection on labeled training images and unlabeled training images using the initial YOLO model to generate a first detection result, which includes a classification result, detection box coordinates, and confidence level.
[0009] Classify unlabeled training images based on the teacher model and generate pseudo labels;
[0010] According to the confidence of the first detection result, high-confidence detection boxes that exceed a preset confidence threshold are screened, and based on the number distribution of high-confidence detection boxes, the weight coefficients of the classification detection head, regression detection head, and confidence detection head in the initial YOLO model are dynamically adjusted to generate a weight-optimized target detection model;
[0011] The supervised loss function and the unsupervised loss function are used to calculate the detection error of the labeled training images and the pseudo-label error of the unlabeled training images respectively, and the weighted sum of the detection error and the pseudo-label error is used to iteratively update the target detection model after weight optimization;
[0012] Based on the updated target detection model, target detection is performed on the image to be detected to obtain a recognition result of the image to be detected.
[0013] In an embodiment of the present application, first, an image to be detected, a labeled training image, and an unlabeled training image are obtained, and the initial YOLO model is used to perform target detection on the two types of training data to generate a first detection result including classification results, detection frame coordinates, and confidence. The teacher model generates pseudo labels for the classification of unlabeled training images to expand the effective coverage of the training data. After screening high-confidence detection frames that exceed the threshold based on confidence, the weight coefficients of the classification, regression, and confidence detection heads are dynamically allocated according to the distribution of the number of detection frames, so that the model can automatically enhance the contribution of key detection heads for different scene features. For example, in a target overlapping scene, increasing the weight of the confidence detection head can optimize the reliability screening of the frame; in a small target scene, increasing the weight of the regression detection head can enhance positioning accuracy.
[0014] In addition, the detection error of labeled data is calculated by using a supervised loss function, and the pseudo-label error is jointly optimized with an unsupervised loss function. The model parameters are iteratively updated using a weighted summation strategy. This can improve the model's efficiency in utilizing labeled data and fully tap the potential of unlabeled data, thereby improving the overall detection accuracy.
[0015] In summary, by introducing pseudo-labels, dynamically adjusting weights, and combining learning strategies with different loss functions, we effectively solved the problem of insufficient detection accuracy of the traditional YOLO model in complex scenarios, and enhanced the recognition ability of multi-scale objects and overall robustness.
[0016] In some possible implementations of the first aspect, the steps of dynamically adjusting the weight coefficients of the classification detection head, the regression detection head, and the confidence detection head in the initial YOLO model based on the number distribution of high-confidence detection boxes to generate a weight-optimized object detection model include:
[0017] Count the number of detection frames output by the classification detection head, regression detection head, and confidence detection head that exceed a preset confidence threshold;
[0018] The weight ratio of the classification detection head, regression detection head and confidence detection head is calculated based on the number of detection frames output by the classification detection head, regression detection head and confidence detection head that exceed the preset confidence threshold, and the weight ratio is normalized into a weight coefficient;
[0019] The weight coefficients are then weighted and fused with the output features of the corresponding detection heads to generate a weighted object detection model. By focusing on the distribution of high-confidence detection boxes, the model can capture the effective feature expression capabilities of each detection head in the current scenario, thereby optimizing the feature fusion process. This effectively addresses the problem of feature utilization rigidity caused by traditional fixed weight allocation and improves the detection stability of the model in complex scenarios such as overlapping objects and small-scale objects.
[0020] In addition, the normalization process ensures that the sum of the weight coefficients is 1, preventing a single detection head from excessively dominating the model output and maintaining the balance of multi-task learning.
[0021] In some possible implementations of the first aspect, the steps of calculating weight ratios of the classification detection head, the regression detection head, and the confidence detection head based on the number of detection frames output by the statistical classification detection head, the regression detection head, and the confidence detection head that exceed a preset confidence threshold, and normalizing the weight ratios into weight coefficients include:
[0022] The initial weight ratio of each detection head is calculated by the following formula:
[0023]
[0024] Where r i represents the initial weight ratio of the i-th detection head, i = 1, 2, 3 correspond to the classification, regression, and confidence detection heads respectively; n i represents the number of high-confidence detection boxes counted by the i-th detection head; N is the total number of all detection heads, satisfying N = n1 + n2 + n3;
[0025] The initial weight ratio is normalized by the Softmax function to generate the normalized weight coefficient. The Softmax function satisfies:
[0026]
[0027] Where w i Represents the normalized weight coefficient of the i-th detection head; j is the detection head index, and its value range is consistent with i.
[0028] In some possible implementations of the first aspect, the process of adjusting the detection head weight coefficient further includes:
[0029] Get the weight coefficients of the classification detection head, regression detection head, and confidence detection head of the initial YOLO model in the historical training phase;
[0030] Perform sliding weighted average calculation on the weight coefficients of each detection head calculated in the current training phase and the corresponding historical weight coefficients to generate a smoothed weight coefficient. The sliding weighted average calculation satisfies:
[0031]
[0032] Where, represents the smoothing weight coefficient of the t-th training stage; Represents the current weight coefficient calculated at the t-th training stage; represents the historical weight coefficient of the t-1th training stage; α is a dynamic attenuation factor, whose value increases linearly from the preset initial value to the preset upper limit as the number of iterations in the training stage increases;
[0033] The smoothed weight coefficients are replaced with the weight coefficients from the current training phase, and a weighted fusion step is performed. This optimizes the stability and convergence efficiency of the model training process by fusing the historical weight coefficients with the current weight coefficients using a sliding weighted average. Specifically, during training, the weight coefficients of each detector head in the current training phase and the weight coefficients stored in previous training phases are extracted and weighted fused using a dynamic attenuation factor. The dynamic attenuation factor is set to a low value in the initial training phase, making the smoothed weight coefficients more dependent on historical weights and suppressing weight fluctuations in the early stages of training caused by data noise or model immaturity. As the number of training iterations increases, the dynamic attenuation factor increases linearly to a preset upper limit, gradually increasing the fusion ratio of the current weight coefficients. This allows the model to focus more on the feature distribution of the current data in the later stages of training, accelerating convergence and improving adaptability to new scenarios. By balancing the influence of historical experience and real-time data, training instability caused by sudden weight changes is effectively alleviated, while avoiding the model's over-reliance on historical data and reducing the risk of overfitting.
[0034] In some possible implementations of the first aspect, the process of determining the preset confidence threshold includes:
[0035] Extract the detection results of the initial YOLO model on the validation set. The validation set is randomly divided from the labeled training images, and the detection results include the confidence of all detection boxes;
[0036] Calculate the sum of the mean and standard deviation of the confidence level to generate the initial confidence threshold;
[0037] During the training process, the initial confidence threshold is dynamically adjusted according to the pseudo-label score distribution of the unlabeled training images in the current training stage to generate an updated confidence threshold. The specific formula is as follows:
[0038] T new =μ+βσ
[0039] Where, T newis the updated confidence threshold; μ is the mean of the current pseudo-label scores; σ is the standard deviation of the current pseudo-label scores; and β is the preset coefficient. By dynamically adjusting the confidence threshold, we address the unstable pseudo-label quality caused by traditional fixed thresholds, thereby improving semi-supervised learning efficiency and detection accuracy.
[0040] The initial confidence threshold is determined based on the detection results of the initial YOLO model on the validation set. It is generated by calculating the mean and standard deviation of the confidence scores of all detection boxes in the validation set. This ensures that the threshold setting matches the data distribution and avoids subjective bias caused by manual pre-setting. During training, the confidence threshold is dynamically updated based on the mean pseudo-label scores of the current unlabeled training images and a preset coefficient. The confidence threshold can adapt to changes in the model's training state. In the early stages of training, when the model's predictive ability is weak, the threshold is lowered to utilize more pseudo-labels for learning. As the model optimizes, the threshold is gradually increased to filter out noisy samples. This balance between the quantity and quality of pseudo-labels is achieved, preventing low-quality pseudo-labels from interfering with model training while also preventing underfitting caused by excessive elimination of valid samples.
[0041] In some possible implementations of the first aspect, the storage and call process of the historical weight coefficient includes:
[0042] Construct a circular buffer to store the weight coefficients of each detection head in the most recent N training stages, where N is a preset initial value and increases by a preset increment every time a preset number of training stages pass until a preset maximum value is reached;
[0043] When performing the sliding weighted average calculation, M historical weight coefficients adjacent to the current training stage are extracted from the ring buffer, where M is dynamically adjusted according to the preset ratio of the total number of model training stages, satisfying:
[0044]
[0045] Where T is the total number of training stages; -λ is the preset scaling factor; Represents the floor operator. This constructs a circular buffer to store the weight coefficients of the classification, regression, and confidence detection heads from the most recent training phases, and dynamically adjusts the call range of historical weight coefficients based on training progress, optimizing the stability and generalization of model training. The circular buffer's storage capacity is initially set to a preset value and gradually expands to a preset upper limit as the number of training phases increases, preventing memory overflow while preserving critical historical information.
[0046] During the model weight update process, when extracting historical weight coefficients adjacent to the current training stage from the buffer, the number of extractions is dynamically calculated based on a preset scale factor of the total number of training stages. In the later stages of training, the historical reference range is increased to smooth weight fluctuations. By fusing the current weights with historical weights through a sliding weighted average, the model is able to suppress the interference of single-stage training noise on the weight distribution while maintaining the consistency of long-term learning trends. As the training stage progresses, the coordinated expansion mechanism of the buffer capacity and the number of extractions balances the model's ability to capture new features with the efficiency of inheriting historical experience, ultimately improving the convergence speed and generalization performance of the object detection model in complex scenarios.
[0047] In a second aspect, an embodiment of the present application provides a target detection system based on the YOLO architecture, including:
[0048] An image acquisition module is used to acquire labeled training images and unlabeled training images;
[0049] An initial detection module is used to perform target detection on labeled training images and unlabeled training images using an initial YOLO model to generate a first detection result. The first detection result includes a classification result, detection box coordinates, and confidence level.
[0050] The pseudo-label generation module is used to classify unlabeled training images based on the teacher model and generate pseudo-labels;
[0051] A dynamic weight allocation module is used to screen high-confidence detection boxes that exceed a preset confidence threshold based on the confidence of the first detection result, and dynamically adjust the weight coefficients of the classification detection head, regression detection head, and confidence detection head in the initial YOLO model based on the number distribution of high-confidence detection boxes to generate a weight-optimized object detection model;
[0052] The joint training module uses supervised loss functions and unsupervised loss functions to calculate the detection error of labeled training images and the pseudo-label error of unlabeled training images, respectively. It then iteratively updates the weighted sum of the detection error and the pseudo-label error to update the target detection model after weight optimization.
[0053] The recognition module is used to perform target detection on the image to be detected based on the updated target detection model to obtain a recognition result of the image to be detected.
[0054] In some possible implementations of the second aspect, the dynamic weight allocation module is specifically configured to:
[0055] Count the number of detection frames output by the classification detection head, regression detection head, and confidence detection head that exceed a preset confidence threshold;
[0056] The weight ratio of the classification detection head, regression detection head and confidence detection head is calculated based on the number of detection frames output by the classification detection head, regression detection head and confidence detection head that exceed the preset confidence threshold, and the weight ratio is normalized into a weight coefficient;
[0057] The weight coefficients are weightedly fused with the output features of the corresponding detection heads to generate a weight-optimized target detection model.
[0058] In some possible implementations of the second aspect, the dynamic weight allocation module is further configured to:
[0059] The initial weight ratio of each detection head is calculated by the following formula:
[0060]
[0061] Where r i represents the initial weight ratio of the i-th detection head, i = 1, 2, 3 correspond to the classification, regression, and confidence detection heads respectively; n i represents the number of high-confidence detection boxes counted by the i-th detection head; N is the total number of all detection heads, satisfying N = n1 + n2 + n3;
[0062] The initial weight ratio is normalized by the Softmax function to generate the normalized weight coefficient. The Softmax function satisfies:
[0063]
[0064] Where w i Represents the normalized weight coefficient of the i-th detection head; j is the detection head index, and its value range is consistent with i.
[0065] In some possible implementations of the second aspect, the dynamic weight allocation module is further configured to:
[0066] Get the weight coefficients of the classification detection head, regression detection head, and confidence detection head of the initial YOLO model in the historical training phase;
[0067] Perform sliding weighted average calculation on the weight coefficients of each detection head calculated in the current training phase and the corresponding historical weight coefficients to generate a smoothed weight coefficient. The sliding weighted average calculation satisfies:
[0068]
[0069] Where, represents the smoothing weight coefficient of the t-th training stage; Represents the current weight coefficient calculated at the t-th training stage; represents the historical weight coefficient of the t-1th training stage; α is a dynamic attenuation factor, whose value increases linearly from the preset initial value to the preset upper limit as the number of iterations in the training stage increases;
[0070] The smoothed weight coefficients are replaced by the weight coefficients of the current training phase and the weighted fusion step is performed.
[0071] In some possible implementations of the second aspect, the process of determining the preset confidence threshold includes:
[0072] Extract the detection results of the initial YOLO model on the validation set. The validation set is randomly divided from the labeled training images, and the detection results include the confidence of all detection boxes;
[0073] Calculate the sum of the mean and standard deviation of the confidence level to generate the initial confidence threshold;
[0074] During the training process, the initial confidence threshold is dynamically adjusted according to the pseudo-label score distribution of the unlabeled training images in the current training stage to generate an updated confidence threshold. The specific formula is as follows:
[0075] T new =μ+βσ
[0076] Where, T new is the updated confidence threshold; μ is the mean of the current pseudo-label score; σ is the standard deviation of the current pseudo-label score; β is the preset coefficient.
[0077] In some possible implementations of the second aspect, the storage and call process of the historical weight coefficient includes:
[0078] Construct a circular buffer to store the weight coefficients of each detection head in the most recent N training stages, where N is a preset initial value and increases by a preset increment every time a preset number of training stages pass until a preset maximum value is reached;
[0079] When performing the sliding weighted average calculation, M historical weight coefficients adjacent to the current training stage are extracted from the ring buffer, where M is dynamically adjusted according to the preset ratio of the total number of model training stages, satisfying:
[0080]
[0081] Where T is the total number of training stages; -λ is the preset scaling factor; Represents the floor operator.
[0082] In a third aspect, an embodiment of the present application provides an electronic device comprising one or more processors; a storage device on which one or more programs are stored; when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any technical solution of the first aspect.
[0083] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method described in any technical solution of the first aspect is implemented.
[0084] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the method described in any technical solution of the first aspect.
[0085] Among them, the technical effects brought about by any design method in the second to fifth aspects can refer to the technical effects brought about by different design methods in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0086] To more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments or the description of the prior art. Obviously, the drawings described below are merely exemplary, and those skilled in the art can derive other implementation drawings based on the provided drawings without inventive effort.
[0087] Figure 1 A flowchart of a target detection method based on the YOLO architecture provided in some embodiments of the present application;
[0088] Figure 2 A schematic diagram of module interaction of an object detection system based on the YOLO architecture provided in some embodiments of the present application;
[0089] Figure 3 It is a schematic structural diagram of an electronic device suitable for implementing some embodiments of the present application. DETAILED DESCRIPTION
[0090] Specific embodiments of the present invention will now be mentioned in detail. Although the present invention is described in conjunction with these specific embodiments, it should be appreciated that the present invention is not intended to be limited to these specific embodiments. On the contrary, these embodiments are intended to cover substitutions, changes, or equivalent embodiments that may be included within the spirit and scope of the invention defined by the claims. In the following description, a large number of specific details are set forth in order to provide a comprehensive understanding of the present invention. The present invention may be implemented without some or all of these specific details.
[0091] When used in conjunction with "including," "methods comprising," or similar language in this specification and the appended claims, the singular forms "a," "an," and "the" include plural references unless the context clearly dictates otherwise. Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0092] Application Overview: Existing object detection methods based on the YOLO architecture generally suffer from insufficient detection accuracy in complex scenes or for small targets. Specifically, the traditional YOLO model's detection head has fixed weights, making it difficult to adapt to the feature distribution of targets of different scales, resulting in limited recognition of multi-scale targets. At the same time, the multi-scale feature fusion mechanism does not fully combine shallow detail features with deep semantic features, making missed detections or false detections more likely, especially in scenarios with occlusion, changing lighting, or overlapping targets. In addition, the detection box deduplication algorithm is inefficient in screening dense targets, further reducing the accuracy of the detection results.
[0093] In response to the above technical problems, the overall idea of the technical solution provided by this application is as follows: a target detection method based on the YOLO architecture is provided, comprising the following steps: obtaining labeled training images and unlabeled training images; performing target detection on the labeled training images and the unlabeled training images through the initial YOLO model to generate a first detection result, the first detection result including the classification result, the detection box coordinates and the confidence; classifying the unlabeled training images based on the teacher model to generate a pseudo label; screening high-confidence detection boxes that exceed a preset confidence threshold according to the confidence of the first detection result, and dynamically adjusting the weight coefficients of the classification detection head, the regression detection head and the confidence detection head in the initial YOLO model based on the number distribution of the high-confidence detection boxes to generate a weight-optimized target detection model; using a supervised loss function and an unsupervised loss function to respectively calculate the detection error of the labeled training images and the pseudo-label error of the unlabeled training images, and iteratively updating the weight-optimized target detection model according to the weighted sum of the detection error and the pseudo-label error; performing target detection on the image to be detected based on the updated target detection model to obtain the recognition result of the image to be detected.
[0094] This method first obtains labeled training images and unlabeled training images, uses the initial YOLO model to perform target detection on the two types of training data, and generates a first detection result containing classification results, detection box coordinates, and confidence. The teacher model generates pseudo labels for the classification of unlabeled training images, expanding the effective coverage of the training data. After filtering high-confidence detection boxes that exceed the threshold based on confidence, the weight coefficients of the classification, regression, and confidence detection heads are dynamically allocated according to the distribution of the number of detection boxes, enabling the model to automatically strengthen the contribution of key detection heads based on different scene characteristics. For example, in scenes with overlapping targets, increasing the weight of the confidence detection head can optimize the reliability screening of the box; in scenes with small targets, increasing the weight of the regression detection head can enhance positioning accuracy.
[0095] After introducing the basic principles of this application, various non-limiting implementation methods of this application will be specifically introduced in conjunction with the accompanying drawings. Figure 1 , the embodiment of the present application provides a target detection method based on the YOLO architecture, comprising the following steps:
[0096] S101: Obtain labeled training images and unlabeled training images;
[0097] S102: Performing target detection on the labeled training image and the unlabeled training image using the initial YOLO model to generate a first detection result, where the first detection result includes a classification result, detection box coordinates, and confidence level;
[0098] S103: Classify the unlabeled training images based on the teacher model and generate pseudo labels;
[0099] S104: Filter high-confidence detection frames that exceed a preset confidence threshold based on the confidence of the first detection result, and dynamically adjust the weight coefficients of the classification detection head, regression detection head, and confidence detection head in the initial YOLO model based on the number distribution of the high-confidence detection frames to generate a weight-optimized object detection model;
[0100] In some embodiments, the execution entity of the object detection method based on the YOLO architecture can dynamically adjust the weight coefficients of the classification detection head, regression detection head, and confidence detection head in the initial YOLO model based on the number distribution of high-confidence detection boxes through the following steps to generate a weight-optimized object detection model:
[0101] The first step is to count the number of detection frames output by the classification detection head, regression detection head, and confidence detection head that exceed the preset confidence threshold;
[0102] The second step is to calculate the weight ratio of the classification detection head, regression detection head and confidence detection head based on the number of detection frames output by the classification detection head, regression detection head and confidence detection head that exceed the preset confidence threshold, and normalize the weight ratio into a weight coefficient;
[0103] Specifically, in some embodiments, the execution entity may calculate the weight ratios of the classification detection head, the regression detection head, and the confidence detection head based on the number of detection frames output by the classification detection head, the regression detection head, and the confidence detection head that exceed a preset confidence threshold through the following steps, and normalize the weight ratios into weight coefficients:
[0104] In the first sub-step, the initial weight ratio of each detection head is calculated using the following formula:
[0105]
[0106] Where r i represents the initial weight ratio of the i-th detection head, i = 1, 2, 3 correspond to the classification, regression, and confidence detection heads respectively; n i represents the number of high-confidence detection boxes counted by the i-th detection head; N is the total number of all detection heads, satisfying N = n1 + n2 + n3;
[0107] In the second sub-step, the initial weight ratio is normalized by the Softmax function to generate the normalized weight coefficient. The Softmax function satisfies:
[0108]
[0109] Where w i Represents the normalized weight coefficient of the i-th detection head; j is the detection head index, and its value range is consistent with i.
[0110] In the third step, the weight coefficients are weightedly fused with the output features of the corresponding detection head to generate a weight-optimized target detection model.
[0111] Specifically, the original output features of the classification detection head, regression detection head, and confidence detection head in the initial YOLO model, as well as the normalized weight coefficients, are weighted by element-by-element multiplication with the feature maps of the corresponding detection heads to generate a weighted feature map; the weighted feature map replaces the original feature map in the initial YOLO model to generate a weight-optimized target detection model; the specific weighting formula is:
[0112]
[0113] Where, represents the original output features of the i-th detection head, w iis the normalized weight coefficient of the i-th detection head, ⊙ represents element-by-element multiplication, is the weighted feature map.
[0114] Among them, by focusing on the number distribution of high-confidence detection frames, the model can capture the effective feature expression capabilities of each detection head in the current scene, thereby optimizing the feature fusion process, effectively solving the problem of feature utilization rigidity caused by traditional fixed weight allocation, and improving the detection stability of the model in complex scenes such as target overlap and small-scale targets.
[0115] In addition, the normalization process ensures that the sum of the weight coefficients is 1, preventing a single detection head from excessively dominating the model output and maintaining the balance of multi-task learning.
[0116] Based on the above embodiment, the process of adjusting the detection head weight coefficient further includes:
[0117] The first step is to obtain the weight coefficients of the classification detection head, regression detection head, and confidence detection head of the initial YOLO model in the historical training phase;
[0118] In the second step, the weight coefficients of each detection head calculated in the current training phase and the corresponding historical weight coefficients are calculated by sliding weighted average to generate smoothed weight coefficients. The sliding weighted average calculation satisfies:
[0119]
[0120] Where, represents the smoothing weight coefficient of the t-th training stage; Represents the current weight coefficient calculated at the t-th training stage; represents the historical weight coefficient of the t-1th training stage; α is a dynamic attenuation factor, whose value increases linearly from the preset initial value to the preset upper limit as the number of iterations in the training stage increases;
[0121] In the third step, the smoothed weight coefficients replace the weight coefficients from the current training phase, and a weighted fusion step is performed. This optimizes the stability and convergence efficiency of the model training process by fusing the historical weight coefficients with the current weight coefficients using a sliding weighted average. Specifically, during training, the weight coefficients of each detector head in the current training phase and the weight coefficients stored from previous training phases are extracted and weighted fused using a dynamic attenuation factor. The dynamic attenuation factor is set to a low value in the initial training phase, making the smoothed weight coefficients more dependent on historical weights and suppressing weight fluctuations in the early stages of training caused by data noise or model immaturity. As the number of training iterations increases, the dynamic attenuation factor increases linearly to a preset upper limit, gradually increasing the fusion ratio of the current weight coefficients. This allows the model to focus more on the feature distribution of the current data in the later stages of training, accelerating convergence and improving adaptability to new scenarios. By balancing the influence of historical experience and real-time data, training instability caused by sudden weight changes is effectively mitigated, while avoiding the model's over-reliance on historical data and reducing the risk of overfitting.
[0122] Based on the above embodiment, the process of determining the preset confidence threshold includes:
[0123] The first step is to extract the detection results of the initial YOLO model on the validation set. The validation set is randomly divided from the labeled training images, and the detection results include the confidence of all detection boxes;
[0124] The second step is to calculate the sum of the mean and standard deviation of the confidence level to generate the initial confidence threshold;
[0125] In the third step, during the training process, the initial confidence threshold is dynamically adjusted according to the pseudo-label score distribution of the unlabeled training images in the current training stage to generate an updated confidence threshold. The specific formula is as follows:
[0126] T new =μ+βσ
[0127] Where, T new is the updated confidence threshold; μ is the mean of the current pseudo-label scores; σ is the standard deviation of the current pseudo-label scores; and β is the preset coefficient. By dynamically adjusting the confidence threshold, we address the unstable pseudo-label quality caused by traditional fixed thresholds, thereby improving semi-supervised learning efficiency and detection accuracy.
[0128] The initial confidence threshold is determined based on the detection results of the initial YOLO model on the validation set. It is generated by calculating the mean and standard deviation of the confidence scores of all detection boxes in the validation set. This ensures that the threshold setting matches the data distribution and avoids subjective bias caused by manual pre-setting. During training, the confidence threshold is dynamically updated based on the mean pseudo-label scores of the current unlabeled training images and a preset coefficient. The confidence threshold can adapt to changes in the model's training state. In the early stages of training, when the model's predictive ability is weak, the threshold is lowered to utilize more pseudo-labels for learning. As the model optimizes, the threshold is gradually increased to filter out noisy samples. This balance between the quantity and quality of pseudo-labels is achieved, preventing low-quality pseudo-labels from interfering with model training while also preventing underfitting caused by excessive elimination of valid samples.
[0129] Based on the above embodiment, the storage and call process of the historical weight coefficient includes:
[0130] The first step is to build a ring buffer to store the weight coefficients of each detection head in the last N training stages, where N is a preset initial value and increases by a preset increment every time a preset number of training stages are passed until a preset maximum value is reached;
[0131] In the second step, when performing the sliding weighted average calculation, M historical weight coefficients adjacent to the current training stage are extracted from the ring buffer, where M is dynamically adjusted according to the preset ratio of the total number of model training stages to meet the following requirements:
[0132]
[0133] Where T is the total number of training stages; -λ is the preset scaling factor; Represents the floor operator. This constructs a circular buffer to store the weight coefficients of the classification, regression, and confidence detection heads from the most recent training phases, and dynamically adjusts the call range of historical weight coefficients based on training progress, optimizing the stability and generalization of model training. The circular buffer's storage capacity is initially set to a preset value and gradually expands to a preset upper limit as the number of training phases increases, preventing memory overflow while preserving critical historical information.
[0134] During the model weight update process, when extracting historical weight coefficients adjacent to the current training stage from the buffer, the number of extractions is dynamically calculated based on a preset scale factor of the total number of training stages. In the later stages of training, the historical reference range is increased to smooth weight fluctuations. By fusing the current weights with historical weights through a sliding weighted average, the model is able to suppress the interference of single-stage training noise on the weight distribution while maintaining the consistency of long-term learning trends. As the training stage progresses, the coordinated expansion mechanism of the buffer capacity and the number of extractions balances the model's ability to capture new features with the efficiency of inheriting historical experience, ultimately improving the convergence speed and generalization performance of the object detection model in complex scenarios.
[0135] S105: Calculate the detection error of the labeled training image and the pseudo-label error of the unlabeled training image using the supervised loss function and the unsupervised loss function respectively, and iteratively update the weight-optimized target detection model according to the weighted sum of the detection error and the pseudo-label error;
[0136] S106: Performing target detection on the image to be detected based on the updated target detection model to obtain a recognition result of the image to be detected. It is understood that the updated target detection model is a target detection model that satisfies a weighted sum of a detection error and a pseudo-label error less than a preset threshold.
[0137] See also Figure 2 Based on the same inventive concept as the target detection method based on the YOLO architecture in the aforementioned embodiment, the present embodiment provides a target detection system based on the YOLO architecture, including:
[0138] Image acquisition module 201, used to acquire labeled training images and unlabeled training images;
[0139] An initial detection module 202 is configured to perform target detection on labeled training images and unlabeled training images using an initial YOLO model to generate a first detection result, where the first detection result includes a classification result, detection box coordinates, and a confidence level.
[0140] A pseudo label generation module 203 is used to classify unlabeled training images based on the teacher model and generate pseudo labels;
[0141] A dynamic weight allocation module 204 is configured to select high-confidence detection frames exceeding a preset confidence threshold based on the confidence of the first detection result, and dynamically adjust the weight coefficients of the classification detection head, regression detection head, and confidence detection head in the initial YOLO model based on the number distribution of the high-confidence detection frames to generate a weight-optimized object detection model;
[0142] The joint training module 205 calculates the detection error of the labeled training images and the pseudo-label error of the unlabeled training images using the supervised loss function and the unsupervised loss function, and iteratively updates the weight-optimized target detection model based on the weighted sum of the detection error and the pseudo-label error.
[0143] The recognition module 206 is configured to perform target detection on the image to be detected based on the updated target detection model to obtain a recognition result of the image to be detected.
[0144] In some embodiments, the dynamic weight allocation module 203 is specifically configured to:
[0145] Count the number of detection frames output by the classification detection head, regression detection head, and confidence detection head that exceed a preset confidence threshold;
[0146] The weight ratio of the classification detection head, regression detection head and confidence detection head is calculated based on the number of detection frames output by the classification detection head, regression detection head and confidence detection head that exceed the preset confidence threshold, and the weight ratio is normalized into a weight coefficient;
[0147] The weight coefficients are weightedly fused with the output features of the corresponding detection heads to generate a weight-optimized target detection model.
[0148] In some embodiments, the dynamic weight allocation module 203 is further configured to:
[0149] The initial weight ratio of each detection head is calculated by the following formula:
[0150]
[0151] Where r i represents the initial weight ratio of the i-th detection head, i = 1, 2, 3 correspond to the classification, regression, and confidence detection heads respectively; n i represents the number of high-confidence detection boxes counted by the i-th detection head; N is the total number of all detection heads, satisfying N = n1 + n2 + n3;
[0152] The initial weight ratio is normalized by the Softmax function to generate the normalized weight coefficient. The Softmax function satisfies:
[0153]
[0154] Where w i Represents the normalized weight coefficient of the i-th detection head; j is the detection head index, and its value range is consistent with i.
[0155] In some embodiments, the dynamic weight allocation module 203 is further configured to:
[0156] Get the weight coefficients of the classification detection head, regression detection head, and confidence detection head of the initial YOLO model in the historical training phase;
[0157] Perform sliding weighted average calculation on the weight coefficients of each detection head calculated in the current training phase and the corresponding historical weight coefficients to generate a smoothed weight coefficient. The sliding weighted average calculation satisfies:
[0158]
[0159] Where, represents the smoothing weight coefficient of the t-th training stage; Represents the current weight coefficient calculated at the t-th training stage; represents the historical weight coefficient of the t-1th training stage; α is a dynamic attenuation factor, whose value increases linearly from the preset initial value to the preset upper limit as the number of iterations in the training stage increases;
[0160] The smoothed weight coefficients are replaced by the weight coefficients of the current training phase and the weighted fusion step is performed.
[0161] In some embodiments, the process of determining the preset confidence threshold includes:
[0162] Extract the detection results of the initial YOLO model on the validation set. The validation set is randomly divided from the labeled training images, and the detection results include the confidence of all detection boxes;
[0163] Calculate the sum of the mean and standard deviation of the confidence level to generate the initial confidence threshold;
[0164] During the training process, the initial confidence threshold is dynamically adjusted according to the pseudo-label score distribution of the unlabeled training images in the current training stage to generate an updated confidence threshold. The specific formula is as follows:
[0165] T new =μ+βσ
[0166] Where, T new is the updated confidence threshold; μ is the mean of the current pseudo-label score; σ is the standard deviation of the current pseudo-label score; β is the preset coefficient.
[0167] In some embodiments, the storage and call process of historical weight coefficients includes:
[0168] Construct a circular buffer to store the weight coefficients of each detection head in the most recent N training stages, where N is a preset initial value and increases by a preset increment every time a preset number of training stages pass until a preset maximum value is reached;
[0169] When performing the sliding weighted average calculation, M historical weight coefficients adjacent to the current training stage are extracted from the ring buffer, where M is dynamically adjusted according to the preset ratio of the total number of model training stages, satisfying:
[0170]
[0171] Where T is the total number of training stages; -λ is the preset scaling factor; Represents the floor operator.
[0172] It is understandable that the modules recorded in the target detection system based on the YOLO architecture are similar to those in the reference Figure 1The steps in the target detection method based on the YOLO architecture described above correspond to each other. Therefore, the operations, features, and beneficial effects described above for the method are also applicable to the target detection system based on the YOLO architecture and the modules contained therein, and will not be repeated here.
[0173] See also Figure 3 , based on the inventive concept of a target detection method based on the YOLO architecture in the aforementioned embodiment, an embodiment of the present application provides an electronic device. The electronic device may include but is not limited to mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), etc., and fixed terminals such as digital TVs, desktop computers, etc. The electronic device includes a processing device 301 (such as a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a ROM 302 (read-only memory) or a program loaded from a storage device 308 into a RAM 303 (random access memory). Various programs and data required for the operation of the electronic device are also stored in the RAM 303. The processing device 301, ROM 302, and RAM 303 are connected to each other via a bus 304. An input / output interface (i.e., an I / O interface 305) is also connected to the bus 304.
[0174] Typically, the following devices may be connected to the I / O interface 305: an input device 306 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 308 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 309. The communication device 309 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data.
[0175] In particular, according to some embodiments of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, some embodiments of the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes program code for executing the method shown in the flowchart. In some such embodiments, the computer program can be downloaded and installed from the network via the communication device 309, or installed from the storage device 308, or installed from the ROM 302. When the computer program is executed by the processing device 301, the above-mentioned functions defined in the method of some embodiments of the present application are performed.
[0176] It should be noted that the computer-readable medium described in some embodiments of the present application may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. The computer-readable storage medium may be an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In some embodiments of the present application, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device, or component. In some embodiments of the present application, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0177] In some embodiments, the client and server can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an adhoc peer-to-peer network), as well as any currently known or future developed network.
[0178] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device. The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device can implement the method steps of any of the above technical solutions.
[0179] Computer program code for performing the operations of some embodiments of the present application can be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0180] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, program segment or a part of code, and the module, program segment or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.
[0181] The modules described in some embodiments of the present application may be implemented in software or hardware. The modules described may also be provided in a processor. It is understood that the names of these modules do not limit the modules themselves.
[0182] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0183] Some embodiments of the present application also provide a computer program product, including a computer program, which implements any of the above-mentioned target detection methods based on the YOLO architecture when executed by a processor.
[0184] Although the present invention has been described in detail above using general descriptions and specific embodiments, it will be apparent to those skilled in the art that modifications and improvements may be made thereto. Therefore, such modifications and improvements, without departing from the spirit of the present invention, are intended to be within the scope of protection claimed herein.
Claims
1. A target detection method based on the YOLO architecture, characterized in that: The following steps are involved: Obtain labeled training images and unlabeled training images; Performing target detection on the labeled training image and the unlabeled training image using an initial YOLO model to generate a first detection result, where the first detection result includes a classification result, detection box coordinates, and a confidence level; classifying the unlabeled training images based on the teacher model to generate pseudo labels; screening high-confidence detection frames exceeding a preset confidence threshold according to the confidence of the first detection result, and dynamically adjusting the weight coefficients of the classification detection head, the regression detection head, and the confidence detection head in the initial YOLO model based on the number distribution of the high-confidence detection frames to generate a weight-optimized object detection model; Calculating the detection error of the labeled training image and the pseudo-label error of the unlabeled training image using a supervised loss function and an unsupervised loss function, respectively, and iteratively updating the weight-optimized target detection model according to a weighted sum of the detection error and the pseudo-label error; The target detection is performed on the image to be detected based on the updated target detection model to obtain a recognition result of the image to be detected.
2. The target detection method based on the YOLO architecture according to claim 1, characterized in that The steps of dynamically adjusting the weight coefficients of the classification detection head, the regression detection head, and the confidence detection head in the initial YOLO model based on the number distribution of high-confidence detection frames to generate a weight-optimized target detection model include: According to the confidence of the first detection result, counting the number of detection frames output by the classification detection head, the regression detection head, and the confidence detection head that exceed a preset confidence threshold; Calculating the weight ratios of the classification detection head, the regression detection head, and the confidence detection head based on the number of detection frames output by the classification detection head, the regression detection head, and the confidence detection head that exceed a preset confidence threshold, and normalizing the weight ratios into weight coefficients; The weight coefficients are weightedly fused with the output features of the corresponding detection heads to generate a weight-optimized target detection model.
3. The target detection method based on the YOLO architecture according to claim 2, characterized in that The step of calculating the weight ratio of the classification detection head, the regression detection head, and the confidence detection head based on the number of detection frames output by the classification detection head, the regression detection head, and the confidence detection head that exceed a preset confidence threshold, and normalizing the weight ratio into a weight coefficient includes: The initial weight ratio of each detection head is calculated by the following formula: Where r i represents the initial weight ratio of the i-th detection head, i = 1, 2, 3 correspond to the classification, regression, and confidence detection heads respectively; n i represents the number of high-confidence detection boxes counted by the i-th detection head; N is the total number of all detection heads, satisfying N = n1 + n2 + n3; The initial weight ratio is normalized by a Softmax function to generate a normalized weight coefficient, and the Softmax function satisfies: Where w i Represents the normalized weight coefficient of the i-th detection head; j is the detection head index, and its value range is consistent with i.
4. The target detection method based on the YOLO architecture according to any one of claims 1 to 3, characterized in that The process of adjusting the detection head weight coefficient also includes: Obtain weight coefficients of the classification detection head, regression detection head, and confidence detection head of the initial YOLO model in the historical training phase; Perform a sliding weighted average calculation on the weight coefficients of each detection head calculated in the current training phase and the corresponding historical weight coefficients to generate a smoothed weight coefficient. The sliding weighted average calculation satisfies: Where, represents the smoothing weight coefficient of the t-th training stage; Represents the current weight coefficient calculated at the t-th training stage; represents the historical weight coefficient of the t-1th training stage; α is a dynamic attenuation factor, whose value increases linearly from the preset initial value to the preset upper limit as the number of iterations in the training stage increases; The smoothed weight coefficients are used to replace the weight coefficients of the current training phase, and a weighted fusion step is performed.
5. The target detection method based on the YOLO architecture according to claim 2 or 3, characterized in that The process of determining the preset confidence threshold includes: Extracting detection results of the initial YOLO model on a validation set, where the validation set is randomly divided from the labeled training images, and the detection results include confidence scores of all detection boxes; Calculating the sum of the mean and standard deviation of the confidence level to generate an initial confidence threshold; During the training process, the initial confidence threshold is dynamically adjusted according to the pseudo-label score distribution of the unlabeled training images in the current training stage to generate an updated confidence threshold. The specific formula is as follows: T new =μ+βσ Where, T new is the updated confidence threshold; μ is the mean of the current pseudo-label score; σ is the standard deviation of the current pseudo-label score; β is the preset coefficient.
6. The target detection method based on the YOLO architecture according to claim 4, characterized in that The storage and call process of the historical weight coefficient includes: Construct a circular buffer to store the weight coefficients of each detection head in the most recent N training stages, where N is a preset initial value and increases by a preset increment every time a preset number of training stages pass until a preset maximum value is reached; When performing the sliding weighted average calculation, M historical weight coefficients adjacent to the current training stage are extracted from the ring buffer, where M is dynamically adjusted according to a preset ratio of the total number of model training stages to satisfy: Where T is the total number of training stages; -λ is the preset scaling factor; Represents the floor operator.
7. A target detection system based on the YOLO architecture, characterized in that: include: An image acquisition module is used to acquire labeled training images and unlabeled training images; An initial detection module is configured to perform target detection on the labeled training image and the unlabeled training image using an initial YOLO model to generate a first detection result, where the first detection result includes a classification result, detection box coordinates, and a confidence level; a pseudo label generation module, configured to classify the unlabeled training images based on a teacher model and generate pseudo labels; a dynamic weight allocation module, configured to screen high-confidence detection frames exceeding a preset confidence threshold according to the confidence of the first detection result, and dynamically adjust the weight coefficients of the classification detection head, the regression detection head, and the confidence detection head in the initial YOLO model based on the number distribution of the high-confidence detection frames, to generate a weight-optimized object detection model; A joint training module calculates the detection error of the labeled training image and the pseudo-label error of the unlabeled training image using a supervised loss function and an unsupervised loss function, and iteratively updates the weight-optimized target detection model according to a weighted sum of the detection error and the pseudo-label error; The recognition module is used to perform target detection on the image to be detected based on the updated target detection model to obtain a recognition result of the image to be detected.
8. An electronic device, characterized in that: include: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which implements the method according to any one of claims 1 to 6 when executed by a processing device.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processing device, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Small sample target detection method based on twin network and related equipment
CN115731420A
Detection method based on multi-task detection model and vehicle
CN115984804A
Industrial character recognition method and device based on small sample target detection and storage medium
CN117809306A
Model training method, cross-domain target detection method and electronic equipment
CN118038163A
Target detection method and device based on YOLO architecture
CN119251471A
Cited By
YOLO-based avalanche monitoring self-improvement system and method
CN121482659A