A target detection method and system based on YOLO architecture
By acquiring labeled and unlabeled training images, using a teacher model to generate pseudo-labels and dynamically adjusting the detection head weights, and combining this with a loss function to update the model, the problem of insufficient detection accuracy of the YOLO architecture in complex scenes is solved, and the recognition ability and detection stability of multi-scale targets are improved.
Patent Information
- Application Number
- CN202510529323.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2045-04-25
AI Technical Summary
Existing object detection methods based on the YOLO architecture suffer from insufficient detection accuracy in complex scenes or small object detection, especially in scenes with occlusion, changes in lighting, or overlapping objects, which are prone to missed detections or false detections. Furthermore, multi-scale feature fusion is insufficient, and the deduplication algorithm for detection boxes is inefficient.
By acquiring labeled and unlabeled training images, detection results are generated using an initial YOLO model, pseudo-labels are generated based on a teacher model, the weight coefficients of the detection head are dynamically adjusted, and the model is iteratively updated by combining supervised and unsupervised loss functions to optimize detection accuracy.
The model improves the accuracy and robustness of multi-scale target detection in complex scenarios, enhances its adaptability to different scene features, optimizes the feature fusion process, and improves the stability and accuracy of detection.
Smart Images

Figure CN120451497B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and particularly relates to a target detection method and system based on a YOLO architecture. BACKGROUND
[0002] The existing target detection method based on the YOLO architecture generally has the problem of insufficient detection accuracy in complex scenes or small target detection. Specifically, the detection head weight of the traditional YOLO model is fixed, and it is difficult to adapt to the feature distribution of targets of different scales, which limits the recognition ability of multi-scale targets. At the same time, the multi-scale feature fusion mechanism is not sufficient in combining shallow detail features and deep semantic features, especially in scenes of occlusion, light changes or target overlap, which is prone to missed detection or false detection. In addition, the detection frame deduplication algorithm has low efficiency in screening dense targets, which further reduces the accuracy of the detection result.
[0003] The disclosure of the above background art content is only used to assist in understanding the concept and technical solution of the present application, and it does not necessarily belong to the prior art of the present patent application. In the absence of explicit evidence that the above content has been disclosed on the filing date of the present patent application, the above background art should not be used to evaluate the novelty and inventiveness of the present application. SUMMARY
[0004] The present application provides a target detection method and system based on a YOLO architecture, which can effectively improve the detection accuracy of multi-scale targets in complex scenes.
[0005] To achieve the above-mentioned purpose, the embodiments of the present application disclose the following technical solutions:
[0006] In a first aspect, the embodiments of the present application provide a target detection method based on a YOLO architecture, comprising the following steps:
[0007] Obtaining labeled training images and unlabeled training images;
[0008] Performing target detection on the labeled training images and the unlabeled training images through an initial YOLO model to generate a first detection result, the first detection result including a classification result, detection frame coordinates and a confidence level;
[0009] Classifying the unlabeled training images based on a teacher model to generate pseudo labels;
[0010] According to the confidence level of the first detection result, filtering high-confidence detection frames that exceed a pre-set confidence threshold, 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 target detection model with optimized weights;
[0011] The detection error of the labeled training image and the pseudo-label error of the unlabeled training image are calculated by using a supervised loss function and an unsupervised loss function respectively, and the weight-optimized target detection model is iteratively updated according to the weighted sum result of the detection error and the pseudo-label error.
[0012] The target detection model is updated based on the updated target detection model, and the target detection is performed on the to-be-detected image to obtain the recognition result of the to-be-detected image.
[0013] In the embodiments of the present application, first, the to-be-detected image, the labeled training image and the 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 the first detection result containing the classification result, the detection box coordinates and the confidence. The teacher model classifies the unlabeled training image to generate the pseudo-label, and expands the effective coverage range of the training data. After filtering the high-confidence detection box whose confidence exceeds the threshold based on the confidence, the weight coefficients of the classification, regression and confidence detection heads are dynamically allocated according to the number distribution of the detection boxes, so that the model can automatically strengthen the contribution of the key detection head according to different scene characteristics. For example, in the target overlapping scene, the weight of the confidence detection head is increased to optimize the reliability screening of the box; in the small target scene, the weight of the regression detection head is increased to enhance the positioning accuracy.
[0014] In addition, the detection error of the labeled data is calculated by using the supervised loss function, the pseudo-label error is optimized in combination with the unsupervised loss function, the model parameters are iteratively updated by using the weighted sum strategy, which can improve the utilization efficiency of the labeled data by the model, fully tap the potential of the unlabeled data, and further improve the detection accuracy.
[0015] In summary, by introducing the pseudo-label, dynamically adjusting the weight and combining the learning strategy of different loss functions, the problem of insufficient detection accuracy of the traditional YOLO model in complex scenes is effectively solved, and the recognition ability of multi-scale targets and the overall robustness are enhanced.
[0016] In some possible implementations of the first aspect, the step 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 the high-confidence detection boxes to generate the weight-optimized target detection model comprises:
[0017] Counting the number of detection boxes output by the classification detection head, the regression detection head and the confidence detection head that exceed the pre-set confidence threshold;
[0018] Calculating the weight proportions of the classification detection head, the regression detection head and the confidence detection head based on the counted number of the detection boxes output by the classification detection head, the regression detection head and the confidence detection head that exceed the pre-set confidence threshold, and normalizing the weight proportions into the weight coefficients;
[0019] The weight coefficients are respectively weighted and fused with the output features of the corresponding detection heads to generate a target detection model with optimized weights. Through focusing on the number distribution of high-confidence detection boxes, the model can capture the effective feature expression ability of each detection head in the current scene, thereby optimizing the feature fusion process, effectively solving the feature utilization rigidity problem caused by traditional fixed weight allocation, and improving the detection stability of the model in complex scenes such as target overlap and small-scale target.
[0020] In addition, the normalization processing ensures that the sum of the weight coefficients is 1, avoids the excessive dominance of a single detection head on the model output, and maintains the balance of multi-task learning.
[0021] In some possible implementation manners of the first aspect, the step of calculating the weight proportions of the classification detection head, the regression detection head and the confidence detection head based on the number of detection boxes 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 proportions into weight coefficients includes:
[0022] The initial weight proportions of the detection heads are calculated by the following formula:
[0023]
[0024] In the formula, r i represents the initial weight proportion of the i-th detection head, i = 1, 2, 3 respectively corresponding to the classification, regression and confidence detection heads; 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 proportions are normalized by a Softmax function to generate normalized weight coefficients, and the Softmax function satisfies:
[0026]
[0027] In the formula, w i represents the normalized weight coefficient of the i-th detection head; j is the detection head index, and the value range is consistent with i.
[0028] In some possible implementation manners of the first aspect, the process of adjusting the weight coefficients of the detection heads further includes:
[0029] obtaining the weight coefficients of the classification detection head, the regression detection head and the confidence detection head of the initial YOLO model in the historical training stage;
[0030] performing a sliding weighted average calculation on the weight coefficients of each detection head calculated in the current training stage and the corresponding historical weight coefficients to generate a smoothed weight coefficient, and the sliding weighted average calculation satisfies:
[0031]
[0032] In the formula, denotes the smoothing weight coefficient of the t-th training stage; denotes the current weight coefficient calculated in the t-th training stage; denotes the historical weight coefficient of the t-1-th training stage; and a is a dynamic attenuation factor, which is linearly increased from a preset initial value to a preset upper limit with the iteration number of the training stage;
[0033] The smoothing weight coefficient is substituted for the weight coefficient of the current training stage, and the weighted fusion step is performed. In this way, the sliding weighted average calculation of the over-fusion historical weight coefficient and the current weight coefficient optimizes the stability and convergence efficiency of the model training process. Specifically, in the training process, the weight coefficients of each detection head in the current training stage and the stored weight coefficients in the historical training stage are extracted, and the dynamic attenuation factor is used for weighted fusion. The dynamic attenuation factor is set to a lower value in the initial stage of training, so that the smoothing weight coefficient is more dependent on the historical weight, and the weight oscillation caused by data noise or immature model in the early training is suppressed. With the increase of the iteration number of the training stage, the dynamic attenuation factor is linearly increased to the preset upper limit, and the fusion proportion of the current weight coefficient is gradually increased. The model focuses more on the feature distribution of the current data in the later training, accelerates the convergence and improves the adaptability to new scenes. By balancing the influence of historical experience and real-time data, the training instability caused by weight mutation is effectively alleviated, and the over-reliance of the model on historical data is avoided, and the risk of overfitting is reduced.
[0034] In some possible implementations of the first aspect, the determination process of the preset confidence threshold value comprises:
[0035] The detection results of the initial YOLO model on the verification set are extracted, the verification set is randomly divided from the labeled training images, and the detection results contain the confidence of all detection boxes;
[0036] The sum of the mean and the standard deviation of the confidence is calculated to generate the initial confidence threshold value;
[0037] In the training process, the initial confidence threshold value 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 value, and the specific formula is as follows:
[0038] T new =μ+βσ
[0039] In the formula, T newis an updated confidence threshold; μ is a mean value of the current pseudo-label score; σ is a standard deviation of the current pseudo-label score; and β is a preset coefficient. In this way, by dynamically adjusting the confidence threshold, the problem of unstable pseudo-label quality caused by a traditional fixed threshold is solved, thereby improving the semi-supervised learning efficiency and detection accuracy.
[0040] wherein the determination of the initial confidence threshold is based on the detection result of the initial YOLO model on the verification set, and the threshold is generated by calculating the sum of the mean value and the standard deviation of the confidence of all detection boxes in the verification set, so that the threshold setting matches the data distribution and avoids subjective bias of manual preset. During the training process, the confidence threshold is dynamically updated in combination with the mean value of the pseudo-label score of the unlabeled training image in the current stage and the preset coefficient, and the confidence threshold can adapt to the change of the model training state. In the early training stage, the threshold is low when the model prediction ability is weak to utilize more pseudo-labels for learning; and as the model is optimized, the threshold is gradually increased to filter noise samples. In this way, the contradiction between the "quantity" and the "quality" of the pseudo-labels can be balanced, avoiding interference of low-quality pseudo-labels with the model training and preventing over-rejection of effective samples from causing underfitting.
[0041] In some possible implementations of the first aspect, the storage and calling process of the historical weight coefficient includes:
[0042] An annular buffer is constructed to store the weight coefficients of each detection head in the last N training stages, wherein N is a preset initial value, and is increased by a preset increment every preset number of training stages 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 annular buffer, wherein M is dynamically adjusted according to a preset proportion of the total number of model training stages, and satisfies:
[0044]
[0045] In the formula, T is the current total number of training stages; and -λ is a preset proportion factor; represents a floor operator. In this way, the annular buffer is constructed to store the weight coefficients of the classification, regression and confidence detection heads in the last several training stages, and the calling range of the historical weight coefficients is dynamically adjusted based on the training progress, which can optimize the stability and generalization ability of the model training. The storage capacity of the annular buffer is initially set to a preset value and is gradually expanded to a preset upper limit as the number of training stages increases, avoiding memory overflow while retaining key historical information.
[0046] In the model weight updating process, when extracting the historical weight coefficients adjacent to the current training stage from the buffer, the extraction quantity is dynamically calculated according to a preset proportion factor of the total training stage number, and the historical reference range is increased in the later training stage to smooth the weight fluctuation. By sliding weighted average fusion of the current weight and the historical weight, the model can suppress the interference of single-stage training noise on the weight distribution while retaining the consistency of long-term learning trend. With the advancement of the training stage, the cooperative expansion mechanism of the buffer capacity and the extraction quantity balances the model's ability to capture new features and the efficiency of inheriting historical experience, ultimately improving the convergence speed and generalization performance of the target detection model in complex scenes.
[0047] In a second aspect, the embodiments of the present application provide a target detection system based on a YOLO architecture, comprising:
[0048] An image acquisition module is configured to acquire labeled training images and unlabeled training images.
[0049] An initial detection module is configured to perform target detection on the labeled training images and the unlabeled training images by an initial YOLO model to generate a first detection result, wherein the first detection result includes a classification result, a bounding box coordinate, and a confidence score.
[0050] A pseudo-label generation module is configured to perform classification on the unlabeled training images based on a teacher model to generate pseudo-labels.
[0051] A dynamic weight distribution module is configured to filter high-confidence bounding boxes that exceed a preset confidence threshold according to the confidence scores of the first detection result, and dynamically adjust weight coefficients of a classification detection head, a regression detection head, and a confidence detection head in the initial YOLO model based on the number distribution of the high-confidence bounding boxes to generate a weight-optimized target detection model.
[0052] A joint training module is configured to calculate detection errors of the labeled training images and pseudo-label errors of the unlabeled training images using a supervised loss function and an unsupervised loss function respectively, and iteratively update the weight-optimized target detection model according to a weighted sum result of the detection errors and the pseudo-label errors.
[0053] An identification module is configured to perform target detection on a to-be-detected image based on the updated target detection model to obtain an identification result of the to-be-detected image.
[0054] In some possible implementation modes of the second aspect, the dynamic weight distribution module is specifically configured to:
[0055] Count the number of bounding boxes that exceed the preset confidence threshold among the bounding boxes output by the classification detection head, the regression detection head, and the confidence detection head.
[0056] The number of detection boxes exceeding the preset confidence threshold in the detection boxes output by the statistical classification detection head, the regression detection head and the confidence detection head is counted to calculate weight proportions of the classification detection head, the regression detection head and the confidence detection head, and the weight proportions are normalized into weight coefficients;
[0057] The weight coefficients are respectively weighted and fused with output features of the corresponding detection heads to generate a target detection model after weight optimization.
[0058] In some possible implementation manners of the second aspect, the dynamic weight distribution module is specifically further configured to:
[0059] The initial weight proportions of the detection heads are calculated through the following formula:
[0060]
[0061] In the formula, r i represents the initial weight proportion of the i-th detection head, i = 1, 2, 3 respectively corresponding to the classification, regression and confidence detection heads; 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 proportions are normalized through a Softmax function to generate normalized weight coefficients, and the Softmax function satisfies:
[0063]
[0064] In the formula, w i represents the normalized weight coefficient of the i-th detection head; j is the detection head index, and the value range is consistent with i.
[0065] In some possible implementation manners of the second aspect, the dynamic weight distribution module is specifically further configured to:
[0066] The weight coefficients of the classification detection head, the regression detection head and the confidence detection head of the initial YOLO model in the historical training stage are acquired;
[0067] The weight coefficients of the detection heads calculated in the current training stage and the corresponding historical weight coefficients are calculated through sliding weighted average to generate smooth weight coefficients, and the sliding weighted average calculation satisfies:
[0068]
[0069] In the formula, w represents the smooth weight coefficient of the t-th training stage; represents the current weight coefficient calculated in the t-th training stage; denotes the historical weight coefficient of the t-1th training stage; a is a dynamic attenuation factor, which is linearly increased from a preset initial value to a preset upper limit with the iteration number of the training stage;
[0070] The smoothing weight coefficient is substituted for the weight coefficient of the current training stage, and the weighted fusion step is performed.
[0071] In some possible implementation manners of the second aspect, the determination process of the preset confidence threshold value comprises:
[0072] The detection result of the initial YOLO model on the verification set is extracted, the verification set is randomly divided from the labeled training images, and the detection result comprises the confidence of all detection boxes;
[0073] The sum of the mean and the standard deviation of the confidence is calculated to generate an initial confidence threshold value;
[0074] In the training process, the initial confidence threshold value is dynamically adjusted according to the pseudo-label score distribution of the unlabeled training images of the current training stage to generate an updated confidence threshold value, and the specific formula is as follows:
[0075] T new =μ+βσ
[0076] In the formula, T new is the updated confidence threshold value; μ is the mean of the current pseudo-label score; σ is the standard deviation of the current pseudo-label score; and β is a preset coefficient.
[0077] In some possible implementation manners of the second aspect, the storage and calling process of the historical weight coefficient comprises:
[0078] An annular buffer is constructed to store the weight coefficients of each detection head in the last N training stages, wherein N is a preset initial value, and is increased by a preset increment every preset number of training stages until a preset maximum value is reached;
[0079] When the sliding weighted average calculation is performed, M historical weight coefficients adjacent to the current training stage are extracted from the annular buffer, wherein M is dynamically adjusted according to a preset proportion of the total number of training stages, and satisfies:
[0080]
[0081] In the formula, T is the current total number of training stages; -λ is a preset proportion factor; denotes a floor operator.
[0082] In a third aspect, an electronic device is provided, including one or more processors; a memory storing one or more programs; 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 the first aspect.
[0083] In a fourth aspect, a computer-readable storage medium is provided, and the computer-readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method according to any one of the first aspect.
[0084] In a fifth aspect, a computer program product is provided, and the computer program product includes a computer program, and the computer program is executed by a processor to implement the method according to any one of the first aspect.
[0085] The technical effects brought by any one of the second aspect to the fifth aspect can refer to the technical effects brought by different design manners in the first aspect, and will not be described here. BRIEF DESCRIPTION OF DRAWINGS
[0086] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are only exemplary, and for those skilled in the art, other drawings can be obtained without creative labor on the basis of the provided drawings.
[0087] Figure 1 A flowchart of a target detection method based on a YOLO architecture provided by some embodiments of the present application;
[0088] Figure 2 A module interaction diagram of a target detection system based on a YOLO architecture provided by some embodiments of the present application;
[0089] Figure 3 A structural diagram of an electronic device suitable for implementing some embodiments of the present application. DETAILED DESCRIPTION
[0090] Now specific embodiments of the present application will be described in detail. Although the present application is described in conjunction with these specific embodiments, it should be recognized that the present application is not limited to these specific embodiments. Instead, these embodiments are intended to cover alternatives, modifications and equivalents that can be included within the spirit and scope of the present application as defined by the claims. In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present application. The present application can be practiced without some or all of these specific details.
[0091] The singular forms "a," "an," and "the" include plural referents unless the context clearly dictates otherwise. Unless otherwise defined, 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 application belongs.
[0092] SUMMARY: The existing target detection method based on YOLO architecture generally has the problem of insufficient detection accuracy in complex scenes or small target detection. Specifically, the detection head weight of the traditional YOLO model is fixed, which is difficult to adapt to the feature distribution of targets of different scales, resulting in limited recognition ability of multi-scale targets; at the same time, the multi-scale feature fusion mechanism is not sufficient for the combination of shallow detail features and deep semantic features, especially in scenes of occlusion, light changes or target overlap, which is prone to missed detection or false detection. In addition, the detection frame deduplication algorithm has low efficiency in screening dense targets, which further reduces the accuracy of the detection result.
[0093] To solve the above technical problems, the technical scheme provided by the present application has the following general idea: a target detection method based on YOLO architecture is provided, including 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 an initial YOLO model to generate a first detection result, the first detection result including a classification result, detection frame coordinates and a confidence; performing classification on the unlabeled training images based on a teacher model to generate pseudo labels; filtering high-confidence detection frames that exceed a pre-set 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 target detection model after weight optimization; calculating the detection error of the labeled training images and the pseudo label error of the unlabeled training images using a supervised loss function and an unsupervised loss function respectively, and iteratively updating the target detection model after weight optimization according to the weighted sum result of the detection error and the pseudo label error; performing target detection on the to-be-detected images based on the updated target detection model to obtain the recognition result of the to-be-detected images.
[0094] The method first acquires labeled training images and unlabeled training images, uses an 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.
[0095] After introducing the basic principles of the present application, various non-limiting embodiments of the present application will be specifically introduced below in conjunction with the drawings of the specification. Please refer to Figure 1 The embodiment of the present application provides a target detection method based on a YOLO architecture, including the following steps:
[0096] S101: acquiring labeled training images and unlabeled training images;
[0097] S102: performing target detection on the labeled training images and the unlabeled training images by using an initial YOLO model to generate a first detection result, wherein the first detection result includes classification results, detection box coordinates, and confidence;
[0098] S103: performing classification on the unlabeled training images based on a teacher model to generate pseudo labels;
[0099] S104: screening high-confidence detection boxes that exceed a preset confidence threshold based on 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;
[0100] In some embodiments, the execution subject of the target detection method based on the YOLO architecture can 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 boxes to generate a weight-optimized target detection model by the following steps:
[0101] First, count the number of detection boxes that exceed the preset confidence threshold among the detection boxes output by the classification detection head, the regression detection head, and the confidence detection head;
[0102] Secondly, the weight proportions of the classification detection head, the regression detection head and the confidence detection head are calculated based on the number of detection frames exceeding the preset confidence threshold in the output of the classification detection head, the regression detection head and the confidence detection head, and the weight proportions are normalized into weight coefficients.
[0103] Specifically, in some embodiments, the above execution subject can calculate the weight proportions of the classification detection head, the regression detection head and the confidence detection head based on the number of detection frames exceeding the preset confidence threshold in the output of the classification detection head, the regression detection head and the confidence detection head, and normalize the weight proportions into weight coefficients by the following steps:
[0104] Firstly, the initial weight proportions of the detection heads are calculated by the following formula:
[0105]
[0106] In the formula, r i represents the initial weight proportion of the i-th detection head, i=1, 2, 3 respectively corresponding to the classification, regression and confidence detection heads; n i represents the number of high-confidence detection frames counted by the i-th detection head; N is the total number of all detection heads, satisfying N=n1+n2+n3;
[0107] Secondly, the initial weight proportions are normalized by the Softmax function to generate normalized weight coefficients, and the Softmax function satisfies:
[0108]
[0109] In the formula, w i represents the normalized weight coefficient of the i-th detection head; j is the detection head index, and the value range is consistent with i.
[0110] Thirdly, the weight coefficients are respectively weighted and fused with the output features of the corresponding detection heads to generate a target detection model optimized in weight.
[0111] Specifically, the original output features of the classification detection head, the regression detection head and the confidence detection head in the initial YOLO model, and the normalized weight coefficients are weighted by element-wise multiplication to generate weighted feature maps by weighting the feature maps of the corresponding detection heads, and the weighted feature maps replace the original feature maps in the initial YOLO model to generate a target detection model optimized in weight. The specific formula of weighting is:
[0112]
[0113] In the formula, represents the original output feature of the i-th detection head, w iis the normalized weight coefficient of the i-th detection head, and represents element-wise multiplication. is the weighted feature map.
[0114] By focusing on the number distribution of high-confidence bounding boxes, the model can capture the effective feature expression ability of each detection head in the current scene, thereby optimizing the feature fusion process and effectively solving the feature utilization rigidity problem caused by traditional fixed weight allocation, and improving the detection stability of the model in complex scenes such as target overlap and small-scale target.
[0115] In addition, the normalization process ensures that the sum of the weight coefficients is 1, avoiding the excessive dominance of a single detection head on the model output and maintaining the balance of multi-task learning.
[0116] On the basis of the above embodiment, the process of adjusting the weight coefficient of the detection head further comprises:
[0117] First, obtain the weight coefficients of the classification detection head, the regression detection head, and the confidence detection head of the initial YOLO model in the historical training stage;
[0118] Second, perform a sliding weighted average calculation on the weight coefficients of each detection head calculated in the current training stage and the corresponding historical weight coefficients to generate a smoothed weight coefficient, and the sliding weighted average calculation satisfies:
[0119]
[0120] In the formula, represents the smoothed weight coefficient of the t-th training stage; represents the current weight coefficient calculated in the t-th training stage; represents the historical weight coefficient of the t-1-th training stage; and a is a dynamic attenuation factor whose value increases linearly from a preset initial value to a preset upper limit with the iteration number of the training stage;
[0121] In the third step, the smoothing weight coefficient is replaced by the weight coefficient of the current training stage to perform the weighted fusion step. In this way, the sliding weighted average calculation of the over-fusion historical weight coefficient and the current weight coefficient optimizes the stability and convergence efficiency of the model training process. Specifically, during the training process, the weight coefficients of each detection head in the current training stage and the weight coefficients stored in the historical training stage are extracted, and a dynamic attenuation factor is used for weighted fusion. The dynamic attenuation factor is set to a lower value in the initial training stage, so that the smoothing weight coefficient is more dependent on the historical weight, and the weight oscillation caused by data noise or immature model in the early training is suppressed. As the number of training iterations increases, the dynamic attenuation factor linearly increases to a preset upper limit, gradually increasing the fusion proportion of the current weight coefficient. This makes the model focus more on the feature distribution of the current data in the later training, speeds up the convergence, and improves the adaptability to new scenarios. By balancing the influence of historical experience and real-time data, the training instability caused by weight mutation is effectively alleviated, while avoiding the excessive dependence of the model on historical data, reducing the risk of overfitting.
[0122] On the basis of the above embodiment, the determination process of the preset confidence threshold value comprises:
[0123] In the first step, the detection results of the initial YOLO model on the verification set are extracted, the verification set is randomly divided from the labeled training images, and the detection results include the confidence of all detection boxes;
[0124] In the second step, the sum of the mean and standard deviation of the confidence is calculated to generate the initial confidence threshold value;
[0125] In the third step, during the training process, the initial confidence threshold value 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 value, and the specific formula is as follows:
[0126] T new = μ + βσ
[0127] In the formula, T new is the updated confidence threshold value; μ is the mean of the current pseudo-label score; σ is the standard deviation of the current pseudo-label score; and β is a preset coefficient. In this way, by dynamically adjusting the confidence threshold value, the problem of unstable pseudo-label quality caused by the traditional fixed threshold value is solved, thereby improving the semi-supervised learning efficiency and detection accuracy.
[0128] The determination of the initial confidence threshold is based on the detection results of the initial YOLO model on the verification set, and the sum of the mean and standard deviation of the confidence of all detection boxes in the verification set is generated, so that the threshold setting matches the data distribution and avoids subjective bias of manual preset. In the training process, the confidence threshold is dynamically updated by combining the mean of the pseudo-label score of the unlabeled training image in the current stage and the preset coefficient. The confidence threshold can adapt to the changes of the model training state. In the early training stage, the model prediction ability is weak, and the threshold is low to learn more pseudo-labels; as the model is optimized, the threshold is gradually increased to filter out noise samples. In this way, the contradiction between the "quantity" and "quality" of the pseudo-labels can be balanced, avoiding interference of low-quality pseudo-labels in model training and preventing excessive removal of effective samples from causing underfitting.
[0129] On the basis of the above embodiment, the storage and calling process of the historical weight coefficient includes:
[0130] Firstly, a ring buffer is constructed to store the weight coefficients of each detection head in the last N training stages, wherein N is a preset initial value, and every preset training stage number is increased by a preset increment until a preset maximum value is reached;
[0131] Secondly, when performing the sliding weighted average calculation, M historical weight coefficients adjacent to the current training stage are extracted from the ring buffer, wherein M is dynamically adjusted according to a preset proportion of the total training stage number, satisfying:
[0132]
[0133] In the formula, T is the current total training stage number, and -λ is a preset proportion factor; The down arrow represents the floor operator. In this way, the ring buffer is constructed to store the weight coefficients of the classification, regression and confidence detection heads in the last several training stages, and the calling range of the historical weight coefficients is dynamically adjusted based on the training progress, which can optimize the stability and generalization ability of the model training. The storage capacity of the ring buffer is initially set to a preset value and gradually expanded to a preset upper limit as the training stage number increases, avoiding memory overflow while retaining key historical information.
[0134] In the model weight updating process, when the historical weight coefficients adjacent to the current training stage are extracted from the buffer, the extraction number is dynamically calculated according to the preset proportion factor of the total training stage number, and the historical reference range is increased in the later training stage to smooth the weight fluctuation. By fusing the current weight and the historical weight through the sliding weighted average, the model can suppress the interference of single-stage training noise on the weight distribution while retaining the consistency of long-term learning trend. As the training stage advances, the cooperative expansion mechanism of the buffer capacity and the extraction number balances the model's ability to capture new features and the efficiency of inheriting historical experience, ultimately improving the convergence speed and generalization performance of the target detection model in complex scenes.
[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 result of the detection error and the pseudo-label error.
[0136] S106: Perform target detection on the to-be-detected image based on the updated target detection model to obtain the recognition result of the to-be-detected image. It can be understood that the updated target detection model is a target detection model that meets the condition that the weighted sum result of the detection error and the pseudo-label error is less than a preset threshold.
[0137] Referring to Figure 2 , based on the same inventive concept as the target detection method based on the YOLO architecture in the foregoing embodiments, the embodiments of the present application provide a target detection system based on the YOLO architecture, comprising:
[0138] An image acquisition module 201 is configured to acquire labeled training images and unlabeled training images.
[0139] An initial detection module 202 is configured to perform target detection on the labeled training images and the unlabeled training images by using an initial YOLO model to generate a first detection result, wherein the first detection result includes a classification result, a bounding box coordinate, and a confidence score.
[0140] A pseudo-label generation module 203 is configured to perform classification on the unlabeled training images based on a teacher model to generate pseudo-labels.
[0141] A dynamic weight distribution module 204 is configured to filter high-confidence bounding boxes that exceed a preset confidence threshold according to the confidence scores 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 bounding boxes to generate a weight-optimized target detection model.
[0142] A joint training module 205 is configured to 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 result of the detection error and the pseudo-label error.
[0143] An identification module 206 is configured to perform target detection on the to-be-detected image based on the updated target detection model to obtain the recognition result of the to-be-detected image.
[0144] In some embodiments, the dynamic weight distribution module 203 is specifically configured to:
[0145] The number of detection boxes output by the statistical classification detection head, the regression detection head and the confidence detection head exceeding a preset confidence threshold;
[0146] The number of detection boxes output by the statistical classification detection head, the regression detection head and the confidence detection head exceeding a preset confidence threshold is used to calculate the weight proportion of the classification detection head, the regression detection head and the confidence detection head, and the weight proportion is normalized to a weight coefficient;
[0147] The weight coefficient is fused with the output feature of the corresponding detection head respectively to generate a target detection model with optimized weight.
[0148] In some embodiments, the dynamic weight distribution module 203 is specifically further configured to:
[0149] The initial weight proportion of each detection head is calculated by the following formula:
[0150]
[0151] In the formula, r i represents the initial weight proportion of the i-th detection head, i = 1, 2, 3 corresponding 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 proportion is normalized by a Softmax function to generate a normalized weight coefficient, and the Softmax function satisfies:
[0153]
[0154] In the formula, w i represents the normalized weight coefficient of the i-th detection head; j is the detection head index, and the value range is consistent with i.
[0155] In some embodiments, the dynamic weight distribution module 203 is specifically further configured to:
[0156] The weight coefficient of the classification detection head, the regression detection head and the confidence detection head of the initial YOLO model in the historical training stage is obtained;
[0157] The weight coefficient of each detection head calculated in the current training stage and the corresponding historical weight coefficient are calculated by sliding weighted average to generate a smooth weight coefficient, and the sliding weighted average calculation satisfies:
[0158]
[0159] In the formula, represents the smooth weight coefficient of the t-th training stage; denotes the current weight coefficient calculated in the t-th training stage; denotes the historical weight coefficient in the t-1-th training stage; a is a dynamic attenuation factor, which is linearly increased from a preset initial value to a preset upper limit with the iteration number of training stages;
[0160] The smoothing weight coefficient is used to replace the weight coefficient in the current training stage, and the weighted fusion step is performed.
[0161] In some embodiments, the determination process of the preset confidence threshold includes:
[0162] The detection results of the initial YOLO model on the validation set are extracted, the validation set is randomly divided from the labeled training images, and the detection results include the confidence of all detection boxes;
[0163] The sum of the mean and standard deviation of the confidence is calculated 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, and the specific formula is as follows:
[0165] T new = μ + βσ
[0166] In the formula, 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; and β is a preset coefficient.
[0167] In some embodiments, the storage and calling process of the historical weight coefficient includes:
[0168] A ring buffer is constructed to store the weight coefficients of each detection head in the last N training stages, wherein N is a preset initial value, and is increased by a preset increment every preset number of training stages until a preset maximum value is reached;
[0169] When performing a sliding weighted average calculation, M historical weight coefficients adjacent to the current training stage are extracted from the ring buffer, wherein M is dynamically adjusted according to a preset proportion of the total number of training stages, satisfying:
[0170]
[0171] In the formula, T is the current total number of training stages; -λ is a preset proportion factor; denotes a floor operator.
[0172] It can be understood that the modules described in the target detection system based on the YOLO architecture are recorded in the reference Figure 1The various steps in the described target detection method based on the YOLO architecture correspond. Thus, the operations, features and resulting benefits described above for the method also apply to the target detection system based on the YOLO architecture and the modules contained therein, which will not be described again here.
[0173] Referring to Figure 3 Based on the inventive concept of the above-described target detection method based on the YOLO architecture, the embodiments of the present application provide an electronic device. The electronic device can include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (Personal Digital Assistant), a PAD (Tablet Personal Computer), a PMP (Portable Multimedia Player), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device includes a processing device 301 (e.g., a central processing unit, a graphics processing unit, etc.) that can perform various appropriate actions and processes according to a program stored in a ROM 302 (Read Only Memory) or a program loaded into a RAM 303 (Random Access Memory) from a storage device 308. In the RAM 303, various programs and data required for the operation of the electronic device are also stored. The processing device 301, the ROM 302, and the RAM 303 are connected to each other through a bus 304. An input / output interface (i.e., I / O interface 305) is also connected to the bus 304.
[0174] In general, the following devices can be connected to the I / O interface 305: an input device 306 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, and the like; an output device 307 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, and the like; a storage device 308 including, for example, a magnetic tape, a hard disk, and the like; and a communication device 309. The communication device 309 can allow the electronic device to communicate wirelessly or wiredly with other devices to exchange data.
[0175] In particular, according to some embodiments of the present application, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, some embodiments of the present application include a computer program product including a computer program carried on a computer readable medium, the computer program containing program code for executing the method shown in the flowcharts. In some such embodiments, the computer program can be downloaded and installed from a network through 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-described functions defined in the method of some embodiments of the present application are performed.
[0176] Note that the computer readable medium in some embodiments of the present application can be a computer readable signal medium or a computer readable storage medium or any combination thereof. The computer readable storage medium can be an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any suitable combination thereof. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In some embodiments of the present application, the computer readable storage medium can be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus or device. In some embodiments of the present application, the computer readable signal medium can include a data signal propagated in baseband or propagated as a carrier wave in a propagated data signal, in which the computer readable program code is embodied. Such propagated data signal can take many forms, including but not limited to electro-magnetic, optical or any suitable combination thereof. The computer readable signal medium can also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate or transport a program for use by or in connection with an instruction execution system, apparatus or device. The program code contained on the computer readable medium can be transmitted by any suitable medium, including but not limited to wire, cable, RF (radio frequency), etc., or any suitable combination thereof.
[0177] In some embodiments, the client, server, or both can communicate using any current 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 local area networks ("LAN"), wide area networks ("WAN"), the Internet, and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any current known or future developed networks.
[0178] The computer readable medium described above can be included in the electronic device described above; or can exist separately from the electronic device and can be accessed via the electronic device. The computer readable medium described above carries one or more programs that, when executed by the electronic device, cause the electronic device to implement the method steps of any of the technical solutions described above.
[0179] Computer program code for carrying out operations of some embodiments of the application can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, 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 the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0180] The computer program instructions can also be loaded onto a computer or other programmable information processing apparatus to cause a series of operations to be performed on the computer or other programmable information processing apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable information processing apparatus implement the functions / acts specified in the flowchart and / or block diagram block or blocks.
[0181] The modules described in some embodiments of the present application can be implemented through software and / or hardware. The described modules can also be stored in a processor. It should be understood that the names of the modules do not limit the modules themselves.
[0182] The functions described above can be performed in part or in whole by one or more hardware logic components. For example, and without limitation, illustrative types of hardware logic components that can be used include Field-programmable Gate Arrays (FPGAs), Program-specific Integrated Circuits (ASICs), Program-specific Standard Products (ASSPs), System-on-a-chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc.
[0183] Some embodiments of the present application also provide a computer program product comprising a computer program which, when executed by a processor, implements any of the above-described target detection methods based on the YOLO architecture.
[0184] Although the present application has been described in detail with general description and specific embodiments above, some modifications or improvements can be made to the present application, which is obvious to those skilled in the art on the basis of the present application. Therefore, these modifications or improvements made on the basis of not deviating from the spirit of the present application, all belong to the scope of protection claimed by the present application.
Claims
1. A target detection method based on YOLO architecture, characterized in that, The method comprises 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 an initial YOLO model to generate a first detection result, wherein the first detection result comprises a classification result, a bounding box coordinate and a confidence level; performing classification on the unlabeled training images based on a teacher model to generate pseudo labels; screening high-confidence bounding boxes whose confidence levels exceed a preset confidence threshold according to the confidence levels of the first detection result, and dynamically adjusting weight coefficients of a classification detection head, a regression detection head and a confidence detection head in the initial YOLO model based on a number distribution of the high-confidence bounding boxes to generate a weight-optimized target detection model; calculating detection errors of the labeled training images and pseudo label errors of the unlabeled training images by 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 result of the detection errors and the pseudo label errors; performing target detection on a to-be-detected image based on the updated target detection model to obtain a recognition result of the to-be-detected image; the step 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 the high-confidence bounding boxes to generate the weight-optimized target detection model comprises: counting the number of bounding boxes output by the classification detection head, the regression detection head and the confidence detection head and exceeding the preset confidence threshold according to the confidence levels of the first detection result; calculating weight proportions of the classification detection head, the regression detection head and the confidence detection head based on the counted number of the bounding boxes output by the classification detection head, the regression detection head and the confidence detection head and exceeding the preset confidence threshold, and normalizing the weight proportions into weight coefficients; performing weighted fusion of the weight coefficients and output features of corresponding detection heads respectively to generate the weight-optimized target detection model; the step of calculating the weight proportions of the classification detection head, the regression detection head and the confidence detection head based on the counted number of the bounding boxes output by the classification detection head, the regression detection head and the confidence detection head and exceeding the preset confidence threshold, and normalizing the weight proportions into weight coefficients comprises: calculating initial weight proportions of each detection head through the following formula: In the formula, r i represents the initial weight proportion of the i-th detection head, i=1, 2, 3 respectively corresponding to the classification, regression, and confidence detection head; 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; normalizing the initial weight proportions through a Softmax function to generate normalized weight coefficients, wherein the Softmax function satisfies: In the formula, w i represents the normalized weight coefficient of the ith detection head; j is the detection head index, and the value range is consistent with i.
2. The YOLO architecture based object detection method of claim 1, wherein, the process of adjusting the detection head weight coefficients further comprises: obtaining weight coefficients of the classification detection head, the regression detection head and the confidence detection head of the initial YOLO model in a historical training stage; performing sliding weighted average calculation on each detection head weight coefficient calculated in a current training stage and a corresponding historical weight coefficient to generate a smoothed weight coefficient, wherein the sliding weighted average calculation satisfies: In the formula, denotes the smoothing weight coefficient of the tth training stage; denotes the current weight coefficient calculated in the tth training stage; denotes the historical weight coefficient of the (t-1)th training stage; and α is a dynamic attenuation factor, which is linearly increased from a preset initial value to a preset upper limit with the iteration number of the training stage. replacing the weight coefficient of the current training stage with the smoothed weight coefficient to perform the weighted fusion step.
3. The YOLO architecture based object detection method of claim 1, wherein, the determination process of the preset confidence threshold comprises: extracting detection results of the initial YOLO model on a validation set, the validation set being randomly divided from the labeled training images, and the detection results including confidence levels of all detection boxes; calculating a sum of a mean value and a standard deviation of the confidence levels to generate an initial confidence threshold; during the training process, dynamically adjusting the initial confidence threshold according to a pseudo-label score distribution of the unlabeled training images in a current training stage to generate an updated confidence threshold, and a specific formula is as follows: T new = μ + βσ In the formula, T new is an updated confidence threshold; μ is a mean value of the current pseudo-label score; σ is a standard deviation of the current pseudo-label score; and β is a preset coefficient.
4. The YOLO architecture based object detection method of claim 2, wherein, the storage and calling process of the historical weight coefficients includes: constructing a ring buffer to store weight coefficients of each detection head in the last N training stages, wherein N is a preset initial value, and a preset increment is added every preset number of training stages until a preset maximum value is reached; when the sliding weighted average calculation is performed, M historical weight coefficients adjacent to the current training stage are extracted from the ring buffer, wherein M is dynamically adjusted according to a preset proportion of the total number of model training stages, and satisfies: M = λ × T wherein, T is the current total training stage number; λ is a preset proportion factor; and · represents a down rounding operator.
5. An electronic device, comprising: comprise: 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 of any one of claims 1 to 4.
6. A computer readable storage medium characterized by, The computer program is stored on the computer readable storage medium and is executed by the processing device to implement the method of any one of claims 1 to 4.
7. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processing device to implement the method of any one of claims 1 to 4.
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