Dynamic reasoning method of multi-branch neural network for target detection
Through the dynamic reasoning method of multi-branch neural network, combined with the transfer distillation training strategy and the width factor set, the problems of low versatility and unstable reasoning time of the target detection dynamic reasoning method in the existing technology are solved, and time certainty and stability are achieved. Accuracy adjustment improves the overall efficiency and detection accuracy of the model.
Patent Information
- Application Number
- CN202410827436.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-10-01
AI Technical Summary
In the existing technology, the dynamic inference method for target detection has low versatility in network architecture, is incompatible with multi-scale feature fusion, has unstable inference time, and is difficult to adjust the balance between accuracy and computational overhead.
Using the dynamic reasoning method of multi-branch neural network, by setting the reasoning path of the multi-branch neural network, a multi-branch neural network based on the convolutional neural network is established, and the transfer distillation training strategy is adopted, and the width factor set and the composite connection function are used to achieve information aggregation , dynamically select inference paths to meet real-time and accuracy requirements.
It achieves time-deterministic reasoning path decision-making, flexibly adjusts computing overhead and accuracy to meet real-time requirements, and integrates multiple reasoning branches in a single super network, improving the overall efficiency and detection accuracy of the model.
Smart Images

Figure CN118736196A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision, and in particular to a dynamic reasoning method of a multi-branch neural network for target detection. Background Art
[0002] Object detection is one of the most important tasks in the field of computer vision. In the prior art, invention CN115861374A designed a dynamic reasoning method based on an early exit mechanism to achieve reasoning acceleration, but its network architecture has low versatility and is not compatible with the multi-scale feature fusion mechanism. At the same time, the confidence is used as the exit condition, and the reasoning time is unstable. Invention CN108734265A takes into account the limitations of hardware resources when deploying neural networks, and balances model accuracy and computational overhead through model pruning or model quantization, but it is difficult to adjust.
[0003] Therefore, it is necessary to develop a dynamic reasoning method with easy-to-adjust accuracy and stable reasoning time. Summary of the invention
[0004] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a dynamic reasoning method of a multi-branch neural network for target detection.
[0005] The purpose of the present invention can be achieved by the following technical solutions:
[0006] A dynamic reasoning method of a multi-branch neural network for target detection comprises the following steps:
[0007] S1: Set the inference path of the multi-branch neural network;
[0008] S2: Building a multi-branch neural network based on convolutional neural network
[0009] S3: Set the transfer distillation training strategy for multi-branch neural networks;
[0010] S4: Input the image into a multi-branch neural network, train it according to the transfer distillation training strategy, obtain decision information, select the reasoning path according to the decision information, and obtain the target detection result.
[0011] Furthermore, the multi-branch neural network includes a first backbone network, a first prediction head, a second backbone network, and a second prediction head. The first backbone network and the second backbone network are stacked in a cascade structure of multi-exit branch networks, and the second backbone network reuses the characteristics of the first backbone network.
[0012] Furthermore, the expression of the feature of the second backbone network multiplexing the first backbone network is:
[0013]
[0014] In the formula, x represents the feature map vector, subscripts 1 and 2 represent the corresponding backbone network numbers, superscript l represents the corresponding stage number in the propagation process, and g(·) represents the network module containing the upsampling operation. Represents a composite connection function.
[0015] Furthermore, the multi-branch neural network also includes a width factor set, the multi-branch neural network includes a first reasoning path from the first backbone network to the first prediction head, and a second reasoning path from the first backbone network to the second backbone network and then to the second prediction head, and the number of channels of the convolution operation of the first reasoning path and the second reasoning path is multiplied by the width factor to obtain the actual number of channels.
[0016] Furthermore, the transfer distillation training strategy is: when the training width factor is ρ i When the composite backbone subnetwork is constructed, the width factor is ρ i+1 The output of the long trunk branch is used as a soft label for distillation training, so that the generalization ability of the hypernetwork is transmitted step by step along the direction of reducing the network width.
[0017] Further, the reasoning path includes the following steps:
[0018] 1) Set the frame rate and judge the rationality of the frame rate based on the inference time of the shortest inference path;
[0019] 2) Establish a time window, detect resource configuration, and initialize decision dependency information;
[0020] 3) Read input data and calculate relaxation time;
[0021] 4) Perform feasibility analysis on all executable reasoning paths based on the relaxation time;
[0022] 5) Dynamically assign priorities to feasible reasoning paths and select the reasoning path with the highest priority to process input data;
[0023] 6) Record the reasoning of the current input and update the decision dependency information. If the response environment is interrupted or the end of the time window is reached, return to 2), otherwise return to 3) to process the next input sample.
[0024] Furthermore, the convolutional neural network is a YOLOv7 network.
[0025] Furthermore, the multi-branch neural network achieves information aggregation by element-by-element addition.
[0026] Furthermore, the reasoning path is controlled by a dynamic priority algorithm.
[0027] Furthermore, the image is a video frame image.
[0028] Compared with the prior art, the present invention has the following beneficial effects:
[0029] 1) The present invention generates a multi-branch neural network through backbone network parallel connection and multi-level channel simplification. The control module uses a heuristic reasoning branch decision algorithm, taking into account sample complexity and process resource allocation. By calculating the relaxation time, the reasoning path decision of the present invention has time certainty, and selects a reasoning path that meets the real-time requirements for the image frame.
[0030] 2) The present invention integrates multiple reasoning branches in a single hypernetwork, which can flexibly meet the balance between computational overhead and computational accuracy and is easy to adjust. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 It is a schematic diagram of the process of the present invention.
[0032] Figure 2 This is a schematic diagram of the improved network structure of the present invention.
[0033] Figure 3 It is a schematic diagram of the reasoning path flow of the present invention.
[0034] Figure 4 This is a visualization comparison chart of the algorithm accuracy of the present invention. DETAILED DESCRIPTION
[0035] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0036] Example 1
[0037] like Figure 1 As shown, the present invention is a dynamic reasoning method of a multi-branch neural network for target detection, comprising the following steps:
[0038] S1: Set the inference path of the multi-branch neural network;
[0039] S2: Building a multi-branch neural network based on convolutional neural network
[0040] S3: Set the transfer distillation training strategy for multi-branch neural networks;
[0041] S4: Input the image into a multi-branch neural network, train it according to the transfer distillation training strategy, obtain decision information, select the reasoning path according to the decision information, and obtain the target detection result.
[0042] S1: Traditional dynamic neural networks use internal network modules or gate functions to control specific reasoning paths. The reasoning path and time are directly related to the characteristics of the input samples and are difficult to control manually. This patent proposes a heuristic dynamic branch decision algorithm to formalize the dynamic selection process of the reasoning path, which is convenient for controlling the overall efficiency of model reasoning. The algorithm process is:
[0043] 1) Set the frame rate and judge the rationality of the frame rate based on the inference time of the shortest inference path
[0044] 2) Create a new time window, check resource configuration, and initialize decision dependency information
[0045] 3) Read input data and calculate relaxation time
[0046] 4) Perform feasibility analysis on all executable reasoning paths based on relaxation time
[0047] 5) Dynamically assign priorities to feasible reasoning paths and select the reasoning path with the highest priority to process input data
[0048] 6) Record the reasoning of the current input and update the decision dependency information. If the response environment is interrupted or the end of the time window is reached, return to step 2), otherwise return to step 3) to process the next input sample.
[0049] S2: The present invention proposes a transformation method from a static convolutional neural network to a multi-branch neural network. The specific approach is to introduce multiple exits in the depth and width of the static network. The backbone network of the original static network is represented by B1, and the prediction head is represented by H1. First, B1 is copied to generate a second backbone network B2, and the corresponding prediction head is represented by H2. The cascade structure of the multi-exit branch network is used to stack B1 and B2. At this time, for an input image, there are two reasoning paths with different depths: B1→H1 and in represents the second backbone network reusing the features of the first backbone network. Let L represent the number of backbone network stages. The process of backbone B2 reusing the features of B1 can be expressed as:
[0050]
[0051] In the formula, x represents the feature map vector, subscripts 1 and 2 represent the corresponding backbone network numbers, superscript l represents the corresponding stage number in the propagation process, and g(·) represents the network module containing the upsampling operation. Represents a composite connection function.
[0052] Where g(·) consists of a 1×1 convolution, a batch normalization layer, and an upsampling operation, so that the output features of the lth stage in B1 can be adjusted to the same dimension as the features of the l-1th stage in B2, and element-by-element addition operations can be performed to achieve information aggregation. Set the width factor set [ρ1, ρ2, ..., ρ i ],ρ i ∈(0,1], given a width factor ρ i After that, B1→H1 and The actual number of channels of the convolution operation in the two inference paths will become the original ρ i times, thus setting multiple outlets in width. These two designs are orthogonal, forming a multi-branch network structure such as Figure 2 shown.
[0053] S3: This paper proposes a transfer distillation training strategy for a dual-degree-of-freedom multi-branch network. i When the composite backbone subnetwork is constructed, the width factor is ρ i+1 The output of the long trunk branch is used as a soft label for distillation training, so that the generalization ability of the hypernetwork is transmitted step by step along the direction of reducing the network width.
[0054] S4: The above process of dynamically selecting the inference path based on the input sample to complete the model inference is as follows: Figure 3 shown.
[0055] This embodiment applies this method to an actual algorithm. Object detection is one of the most important tasks in the field of computer vision, and YOLOv7 is an advanced real-time 2D object detection algorithm. First, the model structure of the YOLOv7 algorithm is analyzed, the backbone network cascade and the width factor set are defined, the multi-branch neural network transformation is completed, and each reasoning path is trained simultaneously using the self-distillation method. The accuracy and reasoning time of each reasoning path are counted, the parameters of the reasoning path decision algorithm are configured, and the path decision is embedded in the reasoning process of the YOLOv7 algorithm. For the read video frame or single image, the decision algorithm selects a specific reasoning path to process the input data to improve the reasoning performance of the model.
[0056] Experiment: YOLOv7 Dynamic Branching Target Detection
[0057] Experimental purpose: To verify the effectiveness of the multi-branch transformation strategy on the YOLOv7 model and explore the impact of the inference path dynamic decision algorithm on the overall inference performance of the model.
[0058] Experimental environment:
[0059] (1) Experimental platform: Intel Xeon E5-2683v4, 128GB memory, RTX-3090×4
[0060] (2) Operating system: Ubuntu 20.04
[0061] Experimental protocol:
[0062] This experiment verifies the effectiveness of the dynamic reasoning method by modifying the YOLOv7 model and performing dynamic path reasoning. The experimental steps are as follows.
[0063] 1. Static model analysis and multi-branch transformation. Analyze the YOLOv7 model structure, complete the backbone network cascade, determine the appropriate width factor set according to the task frame rate requirements, and complete the creation of a multi-branch network.
[0064] 2. Model training: Using the self-distillation method, a sub-network with a larger width factor is used to guide the training of a sub-network with a smaller width, thereby alleviating the decrease in accuracy caused by the reduction in model capacity.
[0065] 3. Model verification. Test the accuracy-speed performance of each inference path of the multi-branch network and compare it with the original static model to verify the effect of the multi-branch transformation.
[0066] 4. Use the inference path decision algorithm to complete dynamic branch target detection. The decision algorithm is embedded in the inference process of the multi-branch YOLOv7 model to perceive the changes in real-time frame complexity and process resource configuration, select the most appropriate inference path for each video frame under specific real-time requirements, and observe the inference performance.
[0067] Experimental results:
[0068] The YOLOv7 model was transformed into a multi-branch backbone network with dual-backbone composite and 4 widths integrated. It was trained and tested on the COCO2017 dataset. The input image size was (640,640). The FPS value was measured on a 2080Ti GPU. The prefix DD-XY is used to indicate which path is used, X∈{1,2} indicates whether it is the output of the short backbone or the long composite backbone, and Y∈{1,2,3,4} indicates which width ratio is used.
[0069] The multi-branch model has 8 inference branches, achieving various speed and accuracy balances in a single model. Specifically, DD-1-4-YOLOv7 and the baseline model have the same forward propagation path. Due to the existence of weight slicing operations, the inference speed is slightly reduced, but the detection accuracy only decreases by 0.1%. On this basis, as the network width decreases, the inference speed of the short backbone branch increases and the detection accuracy decreases. For the long backbone inference branch, the composite backbone brings obvious accuracy gains. Even the composite long backbone branch with a width of 50% (DD-2-1-YOLOv7) has a 1.6% accuracy improvement in exchange for an increase of 3 milliseconds in inference time relative to the 100% width short backbone inference branch (DD-1-4-YOLOv7). As the network width continues to increase, the inference time of the long backbone branch increases and the detection accuracy increases. The performance of the multi-branch YOLOv7 model is summarized with the most advanced real-time object detection models such as YOLOv5, YOLOX, and YOLOv6 as shown below. Figure 4 shown.
[0070] Verify the impact of dynamic branch reasoning on model accuracy. Select 55, 45, and 40 FPS values as frame rate requirements, and use the following two strategies to measure detection accuracy:
[0071] (1) Static reasoning is performed using the three inference branches DD-1-3-YOLOv7, DD-2-1-YOLOv7 and DD-2-2-YOLOv7 that meet the real-time requirements.
[0072] (2) Use heuristic dynamic branch decision for adaptive reasoning.
[0073] The above conditions are measured on the COCO2017 validation set, and the results are shown in Table 1.
[0074] Table 1 Comparison of model accuracy of different inference methods
[0075]
[0076] Under three different frame rate requirements, dynamic branch decision reasoning shows an increase in detection accuracy compared to static reasoning, especially when FPS=55. Since DD-2-1-YOLOv7 introduces a composite backbone to significantly improve accuracy, and it does not belong to an outlier branch, a long backbone branch can be selected for dynamic decision reasoning. Compared with static reasoning using the short backbone branch DD-1-3-YOLOv7, a significant increase in AP indicators (0.9 and 1.1) is obtained.
[0077] Verify the proportion of dynamic branch reasoning real-time constraint satisfaction. Sample 50,000 frames of camera data, set the time window of the heuristic branch decision method to 1000 milliseconds, and explore the real-time satisfaction of the heuristic branch decision algorithm in 1000 cycle decisions when the FPS requirements are 55, 45, and 35, respectively, according to the FPS value range in Table 1, and record the activation ratio of each reasoning path. The results are shown in Table 2:
[0078] Table 2 Real-time verification results of decision-making algorithm
[0079]
[0080] In 1000 cycle decisions, the heuristic branch decision algorithm achieved at least 99.9% achievement rate in response to different real-time constraints, and the probability of default can be reduced by reducing the virtual deadline.
[0081] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. A dynamic reasoning method for multi-branch neural networks for target detection, characterized in that: The following steps are involved: S1: Set the inference path of the multi-branch neural network; S2: Establish a multi-branch neural network based on convolutional neural network; S3: Set up the transfer distillation training strategy for the multi-branch neural network; S4: Input the image into a multi-branch neural network, train it according to the transfer distillation training strategy, obtain decision information, select the inference path based on the decision information, and obtain the target detection result.
2. The dynamic inference method of a multi-branch neural network for target detection according to claim 1, characterized in that: The multi-branch neural network includes a first backbone network, a first prediction head, a second backbone network, and a second prediction head. The first backbone network and the second backbone network are stacked in a cascade structure of multi-exit branch networks, and the second backbone network reuses the characteristics of the first backbone network.
3. The dynamic inference method of a multi-branch neural network for target detection according to claim 2, characterized in that: The expression for the characteristics of the second backbone network reusing the first backbone network is: Where x represents the feature map vector, subscripts 1 and 2 represent the corresponding backbone network numbers, superscript l represents the corresponding stage number in the propagation process, and g(·) represents the network module containing the upsampling operation. Represents a composite connection function.
4. The dynamic reasoning method of a multi-branch neural network for target detection according to claim 2, characterized in that: The multi-branch neural network also includes a width factor set, and the multi-branch neural network includes a first reasoning path from the first backbone network to the first prediction head, and a second reasoning path from the first backbone network to the second backbone network and then to the second prediction head. The number of channels of the convolution operation of the first reasoning path and the second reasoning path is multiplied by the width factor to obtain the actual number of channels.
5. The dynamic inference method of a multi-branch neural network for target detection according to claim 4, characterized in that: The transfer distillation training strategy is: when the training width factor is ρ i When the composite backbone subnetwork is constructed, the width factor is ρ i+1 The output of the long trunk branch is used as a soft label for distillation training, so that the generalization ability of the hypernetwork is transmitted step by step along the direction of decreasing network width.
6. The dynamic reasoning method of a multi-branch neural network for target detection according to claim 4, characterized in that: The reasoning path includes the following steps: 1) Set the frame rate and judge its rationality based on the inference time of the shortest inference path; 2) Establish a time window, detect resource configuration, and initialize decision dependency information; 3) Read input data and calculate relaxation time; 4) Perform feasibility analysis on all executable reasoning paths based on slack time; 5) Dynamically assign priorities to feasible reasoning paths and select the reasoning path with the highest priority to process input data; 6) Record the reasoning status of the current input and update the decision dependency information. If the response environment is interrupted or the time window ends, return to 2), otherwise return to 3) to process the next input sample.
7. The dynamic reasoning method of a multi-branch neural network for target detection according to claim 1, characterized in that: The convolutional neural network is a YOLOv7 network.
8. The dynamic inference method of a multi-branch neural network for target detection according to claim 1, characterized in that: The multi-branch neural network achieves information aggregation by element-by-element addition.
9. The dynamic inference method of a multi-branch neural network for target detection according to claim 1, characterized in that: The inference path is controlled by a dynamic priority algorithm.
10. The dynamic reasoning method of a multi-branch neural network for target detection according to claim 1, characterized in that: The image is a video frame image.
Citation Information
Patent Citations
Compression method and device for deep neural network model, terminal and storage medium
CN108734265A
Dynamic reasoning path target tracking method based on conditional early leaving mechanism
CN115861374A
Cited By
X-ray security inspection machine picture object detection method
CN119600389A
