Target detection method and system based on dynamic neural network
By improving the YOLOv7 model, introducing a multivariate convolutional fusion module and a bidirectional feature pyramid, and combining with the intelligent router to dynamically adjust the detection network, the problem of difficult balance between accuracy and speed of the existing object detection methods is solved, and efficient object detection in complex scenarios is achieved.
Patent Information
- Application Number
- CN202411752104.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-12-02
AI Technical Summary
The existing object detection methods are difficult to balance between accuracy and speed, and have limited processing capabilities for complex scenarios and multi-scale features, resulting in low detection accuracy in complex environments.
Using a dynamic neural network-based object detection method, by improving the YOLOv7 model, a multivariate convolutional fusion module and a bidirectional feature pyramid are introduced to build a dynamic object detection model, and dynamically adjust the detection network according to the image difficulty is combined with an intelligent router.
It significantly improves the accuracy and efficiency of object detection, enhances the adaptability and computing efficiency of the model, especially in complex scenarios, excellent detection accuracy and speed performance.
Smart Images

Figure CN119723239A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision and deep neural network technology, and in particular to a target detection method and system based on a dynamic neural network. Background Art
[0002] Object detection is a core task in computer vision, which aims to identify and locate specific objects in images or videos. It is widely used in fields such as autonomous driving, intelligent monitoring, and multi-target tracking. Its main performance indicators are accuracy and inference speed. In recent years, the rapid development of deep learning has greatly promoted the advancement of object detection technology, especially in complex scenarios.
[0003] Traditional object detection methods are generally divided into two categories: two-stage detectors and single-stage detectors. Two-stage detectors, such as Faster R-CNN and Mask R-CNN, divide object detection into two steps: first generating candidate regions, and then classifying and locating these regions. This method has high accuracy, but high computational overhead and slow inference speed. Single-stage detectors, such as the YOLO series and SSD, complete object detection through a single forward pass, use a fixed grid or anchor box to simultaneously predict the category and location of the object, have high inference speed, and are suitable for real-time applications. However, these methods often compromise on accuracy, especially in complex environments.
[0004] Although both types of detectors have their own advantages and disadvantages, they generally have the problem of balancing accuracy and speed, and have poor adaptability to task requirements. As application requirements change, existing detection networks often need to be redesigned and trained, reducing flexibility. In order to solve these problems, dynamic neural networks have emerged as an emerging technology. Unlike traditional fixed-structure networks, dynamic neural networks can flexibly adjust their structure and calculation process according to input data, environment or task requirements, thereby improving the adaptability and computational efficiency of the model.
[0005] Dynamic neural networks show higher flexibility in deep learning and can dynamically adjust the network structure according to the complexity of the image. Although current dynamic networks mostly adopt multi-stage prediction strategies and have achieved good results in image classification tasks, they still face challenges in object detection. Object detection not only requires the identification of multiple objects of different categories and scales, but also requires the extraction of multi-scale features for precise positioning, which makes the processing of full-scale features necessary. The limitations of existing dynamic networks in this regard have limited their application in object detection tasks.
[0006] In addition, the performance of existing object detectors in complex scenes is still unsatisfactory, especially in the case of multi-scale objects and occlusion. Therefore, designing a new, more stable and adaptable object detector, especially a dynamic object detection network model that can handle multi-scale features and complex scenes, is the key to improving detection accuracy and efficiency. Summary of the invention
[0007] Purpose of the invention: The technical problem to be solved by the present invention is to provide a target detection method and system based on a dynamic neural network in view of the shortcomings of the prior art.
[0008] The method comprises the following steps:
[0009] Step 1: Obtain a public target detection dataset and perform preprocessing;
[0010] Step 2, improve the YOLOv7 model;
[0011] Step 3, build a dynamic target detection model based on improved YOLOv7;
[0012] Step 4: Use the preprocessed data set to train and verify the dynamic target detection model;
[0013] Step 5: Take the image to be detected as input and perform target detection using the trained dynamic target detection model.
[0014] In step 1, the target detection dataset is the PASCAL VOC 2012 dataset. The annotation file of the target detection dataset is in XML format, containing target categories and bounding box information. The annotation file is converted to YOLO format. During the conversion, the XML format annotation file is first read, and the corresponding category index is found in the pre-set category file according to the category name. For each target, the bounding box coordinates of the target in the XML format annotation file are obtained, the center coordinates and width and height are calculated and normalized, so as to convert the bounding box coordinates to YOLO format; finally, the category index and the converted bounding box coordinate information are saved in YOLO format in a txt file with the same name as the image.
[0015] Step 2 contains the following steps:
[0016] In step 2.1, convolution, partial convolution, depth-wise separable convolution, layer normalization, Gaussian error linear unit activation, and global response normalization are used to construct a multivariate convolution fusion module. The multivariate convolution fusion module adopts a parallel structure and includes three independent branches, namely the first branch, the second branch, and the third branch. Each branch undertakes different feature processing tasks.
[0017] The first branch and the second branch both use partial convolution to perform local convolution on the input feature map. 1 / 4 of the input channels are selected to apply partial convolution operations to reduce the amount of calculation and improve the efficiency of feature extraction. The floating-point operation number of partial convolution is , the memory access amount is . Among them, h represents the height of the feature map, w represents the width of the feature map, represents the convolution kernel size, Indicates the number of output channels. It is 1 / 4 of the number of input channels, the number of floating-point operations is 1 / 16 of that of ordinary convolution, and the memory access amount is 1 / 4 of that of ordinary convolution.
[0018] The third branch first uses convolution to extract features from the input feature map, and then uses depthwise separable convolution to reduce the amount of computation and the number of parameters and maintain the spatial structure of the features. Then, the third branch introduces a layer normalization to normalize the features to improve the stability of the model and the training efficiency.
[0019] In the feature processing process, Gaussian error linear unit activation and global response normalization operations are also used to increase the nonlinear characteristics of the network. The calculation formula of Gaussian error linear unit activation is:
[0020] ,
[0021] in, is the Gaussian error linear unit activation function, is the input feature map. Global response normalization includes global feature aggregation, feature normalization and feature calibration. First, in global feature aggregation, the feature map on each channel is aggregated using the L2 norm to obtain the aggregated vector. Then, in feature normalization, the standard division normalization function is used to normalize the aggregated vector. Finally, in feature calibration, the normalized vector is used to calibrate the original feature map.
[0022] Finally, the outputs of the first branch, the second branch, and the third branch are merged through a concatenation operation to form the final output of the multivariate convolutional fusion module;
[0023] Step 2.2, use the multivariate convolutional fusion module to replace the efficient layer aggregation module in the YOLOv7 backbone network, thereby improving the efficiency of feature extraction and network performance;
[0024] Step 2.3, introduce a bidirectional feature pyramid into the neck network of YOLOv7, replace the original connection operation with a weighted feature fusion operation, and dynamically adjust the contribution of different features at each fusion node according to the importance of the feature. The formula for the weighted feature fusion operation is:
[0025] ,
[0026] in, is the output feature map, is the number of feature maps that need to be fused, It is Input feature maps, yes The corresponding weight coefficient represents the input feature map contribution.
[0027] Then, nodes with only one input edge are deleted to simplify the network, and finally an extra edge is added between the original input and output nodes to incorporate more feature information.
[0028] Step 3 includes:
[0029] Step 3.1, build a smart router;
[0030] In step 3.2, a dynamic target detection model is constructed using the improved YOLOv7 model and the smart router.
[0031] Step 3.1 includes:
[0032] Step 3.1.1, the smart router uses the pooling layer as the first layer of input, and then passes it through two fully connected layers to obtain the difficulty score, which will be used to determine whether the image is a complex image;
[0033] Multi-scale features extracted in the backbone network First, it will go through the pooling operation, multi-scale features include Features of different scales are represented as ,in Representing multi-scale features Included Features, each are features of different scales extracted from the image, The value ranges from 1 to L, and each feature All are pooled to extract important information at all scales. The features after pooling are concatenated into a feature vector , expressed as:
[0034] ,
[0035] in, represents the concatenation operation of features, It is for The result after pooling the stage features; through this processing method, the router can effectively fuse features of different scales and capture a variety of information.
[0036] Step 3.1.2, concatenated feature vector It will be mapped through two learnable fully connected layers to obtain a difficulty score. It will be mapped through the first fully connected layer, activated by ReLU, then mapped through the second fully connected layer, and normalized by Sigmoid activation to finally get a difficulty score, the formula is:
[0037] ,
[0038] in is a learnable parameter, is the ReLU activation function, is the Sigmoid activation function. Difficulty score The closer the value is to 1, the more difficult it is to process the image, and vice versa.
[0039] Step 3.2 includes:
[0040] Step 3.2.1, prepare two improved YOLOv7 backbone networks ,in For processing simple images, Used to process complex images. In addition, prepare a standard YOLOv7 head , used to perform conventional target detection tasks, provide target classification and positioning information; at the same time, an improved YOLOv7 head is also prepared , by using a bidirectional feature pyramid to fuse the features of complex images. Finally, an intelligent router is also needed , used to select the appropriate network based on the difficulty score of the image;
[0041] Step 3.2.2, and Combined into a network to process images judged to be simple and Combined into another network for processing images judged to be complex. Multi-scale features extracted from Will first be entered into the smart router In, smart router The difficulty of the image is determined based on the input features, the network is selected based on the predicted difficulty score, and dense composite connections are used to connect Extracted multi-scale features Embed in In order to improve the detection ability of subsequent complex images;
[0042] Step 3.2.3, during the detection process, input image Will first be sent to the first backbone network Extract features:
[0043] ,
[0044] in Represents the input image Backbone network Then, the smart router Input features To predict the difficulty score of an image :
[0045] ,
[0046] in , Represents input features Through smart router Processing, if the smart router Classify the input image into simple images, the following head The test results will be output :
[0047] ,
[0048] If the smart router If the input image is classified as a complex image, the multi-scale features will need to be further enhanced by a second backbone, first using a composite connection module composed of dense composite connections Multi-scale features Embed in middle:
[0049] ,
[0050] Then, the input image Re-send it to the second backbone network and combine it with the composite features Combine and sum the features of each scale to obtain new multi-scale features :
[0051] ,
[0052] Through the head Output test results .
[0053] Step 4 includes:
[0054] Step 4.1, train two improved YOLOv7 models;
[0055] Step 4.2, train the smart router.
[0056] Step 4.1 includes:
[0057] Step 4.1.1, use the built PASCAL VOC 2012 dataset to train two improved YOLOv7 models. The two improved YOLOv7 models are the first network ( , ) and the second network ( , ), the first network ( , ) processes simple images, and the second network ( , ) Processing complex images;
[0058] Step 4.1.2, Freeze the Smart Router , keep the parameters fixed and do not participate in training;
[0059] Step 4.1.3, during the training process, the input image will pass through the first network ( , ) and the second network ( , ) is processed, the first network ( , ) and the second network ( , ) will calculate their respective loss functions based on the input image and the corresponding annotation data and ,in, is the actual annotation, and They are the first network ( , ) and the learnable parameters of the second network ( , ), and Represent the first network ( , ) and the second network ( , ) loss; during the training process, the loss value is passed to each layer of the network through the back propagation algorithm, and the weights and biases of the network are gradually optimized;
[0060] Step 4.1.4, based on the total loss Perform back propagation to optimize the parameters of the two networks and the total loss The expression is:
[0061] ,
[0062] During the training process, iterative training is performed, the dynamic target detection model is verified on the validation set, and the accuracy and recall of the model are evaluated. The training process is completed until the preset number of iterations is reached or the performance of the validation set is no longer improved.
[0063] Step 4.2 includes:
[0064] Step 4.2.1, input the constructed PASCAL VOC 2012 dataset into the dynamic target detection model with set hyperparameters for training; at this time, the role of the router is to judge the difficulty of the image based on the multi-scale features of the input image and decide which network to use for target detection. During the training process, the input image will be processed through the complete network architecture, including the judgment of the intelligent router. In order to train the router, first input the data into the backbone network In the process, the difficulty score of each image is calculated by the router, and this score is used to determine which network the image will pass through for subsequent processing;
[0065] Step 4.2.2, freeze the first network ( , ) and the second network ( , ), keep the parameters fixed, that is, keep the weights and biases of the two networks fixed and do not participate in gradient updates. The purpose of this is to ensure that the smart router It can independently learn how to evaluate the complexity of images and make correct decisions. Freezing the parameters of the YOLOv7 model helps to focus on the optimization of the smart router and avoid unnecessary interference during model training.
[0066] Step 4.2.3, the input image goes through the entire dynamic target detection model, including the intelligent router , according to the smart router Loss Back propagation, optimizing smart routers Parameters, loss The expression is:
[0067] ,
[0068] in For the first network ( , ) and the second network ( , ), Respectively used to reward the first network ( , ) and penalize the second network ( , ). The loss function reflects whether the router’s decision is accurate. At this stage, through the back-propagation algorithm, the router’s parameters are updated according to the loss value, thereby optimizing its decision-making process and ensuring that it can efficiently select the appropriate detection network according to the image difficulty in practical applications.
[0069] The present invention also provides a target detection system based on a dynamic neural network, comprising:
[0070] The dataset construction module is used to construct the preprocessed PASCAL VOC 2012 dataset images into a complete dataset;
[0071] YOLOv7 model improvement module, which is used to replace the efficient layer aggregation module in the backbone network with the multi-convolution fusion module, introduce the bidirectional feature pyramid into the neck network of YOLOv7, and build an improved YOLOv7 model;
[0072] Dynamic target detection model construction module, build intelligent router, introduce improved YOLOv7 model, and build dynamic target detection model;
[0073] The model training module is used to input the PASCAL VOC 2012 dataset into the dynamic target detection model for training, and train the improved YOLOv7 model respectively. After obtaining the optimized YOLOv7 model, the parameters of the smart router are optimized, and finally a dynamic target detection model suitable for target detection is obtained.
[0074] The method of the present invention improves YOLOv7 by introducing a multivariate convolution fusion module and a bidirectional feature pyramid, thereby enhancing the feature fusion capability of the model, effectively solving the problem of small target loss, and significantly improving the detection efficiency. At the same time, the present invention combines the improved YOLOv7 with an intelligent router to construct a dynamic target detection model, significantly improving the flexibility and adaptability of target detection. The present invention has not only made significant breakthroughs in improving target detection accuracy and efficiency, but also brought new development directions to the field of target detection, especially in dynamic task environments, providing a more flexible and efficient solution.
[0075] The beneficial effect of the present invention is that the present invention proposes a dynamic target detection model. On the basis of YOLOv7, a multivariate convolution fusion module is used to replace the original efficient layer aggregation module. By optimizing the network structure and reducing redundant parameters, the computational complexity and running time of the model are effectively reduced, so that the dynamic target detection model can adapt to more resource-constrained application scenarios while maintaining high performance. In addition, at the neck of the network, a bidirectional feature pyramid is used to replace the original structure, so that the network shows higher efficiency in feature fusion, especially when processing multi-scale features, it can more effectively integrate information at different levels, enhance the ability of the network to capture details, thereby improving the overall detection performance, especially the detection accuracy in complex scenes. Further, the present invention uses the improved YOLOv7 and the intelligent router to form a dynamic detector, and realizes dynamic detection of images of different complexity. For complex images, the system chooses to execute more processing steps to obtain higher detection accuracy; while for simple images, the detection speed is accelerated by reducing the processing steps. This dynamic adjustment strategy not only improves the detection efficiency, but also ensures that the optimal detection performance can be obtained in different scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] Figure 1 This is a diagram of the multivariate convolution fusion module of the present invention.
[0077] Figure 2 This is a bidirectional feature pyramid structure diagram in the present invention.
[0078] Figure 3 This is the improved YOLOv7 model diagram in the present invention.
[0079] Figure 4 This is a dynamic target detection model diagram in the present invention.
[0080] Figure 5 This is the verification result of the present invention on the PASCAL VOC 2012 dataset. DETAILED DESCRIPTION
[0081] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments, and other advantages of the present invention will become more clear.
[0082] Figure 1 Taking the multivariate convolution fusion module as an example, Figure 2 Taking the bidirectional feature pyramid structure diagram as an example, Figure 3 Taking the improved YOLOv7 architecture diagram as an example, Figure 4 Taking the dynamic target detection model structure diagram as an example, the implementation process and details of a target detection method based on a dynamic neural network proposed in an embodiment of the present invention will be introduced in detail.
[0083] Figure 1 The detailed structure of the multi-convolution fusion module is shown. Figure 2 It is the construction of the bidirectional feature pyramid feature map fusion module, and then based on the YOLOv7 network architecture, use Figure 1 The multivariate convolutional fusion module constructed in replaces the efficient layer aggregation module in the YOLOv7 backbone network, using Figure 2 The bidirectional feature pyramid in is used as the structure of the feature fusion layer, and the following is obtained: Figure 3 The improved YOLOv7 architecture is shown in Figure 2. Subsequently, the improved YOLOv7 and smart router are used to build Figure 4 The dynamic target detection model shown in the figure. First, the improved YOLOv7 is trained, and then the intelligent router is trained, and finally a dynamic target detection model that can be adaptively adjusted according to the complexity of the image is obtained.
[0084] An embodiment of the present invention provides a target detection method based on a dynamic neural network, comprising the following steps:
[0085] Step 1: Build Figure 1 The multivariate convolution fusion module shown in the figure adopts a three-parallel branch structure, which combines convolution, partial convolution, depth-separable convolution, layer normalization, Gaussian error linear unit activation and global response normalization. The first and second branches use local convolution, which only acts on 1 / 4 of the input channels, reducing the amount of calculation and improving efficiency, and capturing different levels of features through different parameter settings. The third branch first extracts features with Conv, then reduces the amount of calculation and parameters through depth-separable convolution, while retaining the feature structure, and then normalizes it through layer normalization, and uses Gaussian error linear unit activation to enhance the activation function and global response normalization nonlinear characteristics. The outputs of the three branches are connected and merged to generate the final result.
[0086] Step 2: Based on the YOLOv7 network architecture, use the multi-convolutional fusion module in step 1 to replace the efficient layer aggregation module in the backbone network.
[0087] Step 3: Introduce the following into the feature fusion layer: Figure 2 The bidirectional feature pyramid feature fusion structure shown in Figure 1 is different from the traditional structure. The bidirectional feature pyramid deletes nodes with only one input edge and adds an extra edge between the original input and output nodes. The improved final network architecture is shown in Figure 1. Figure 3 The original connection operation is replaced by weighted feature fusion, which is performed at each fusion node to dynamically adjust the contribution of different features based on the importance of the features. The formula for the weighted fusion operation is: ,in, is the output feature map, is the number of feature maps that need to be fused, It is Input feature maps, yes The corresponding weight coefficient represents the input feature map contribution.
[0088] Step 4: Build Figure 4 The dynamic target detection model shown in the figure consists of two improved YOLOv7 backbone networks. , a standard YOLOv7 header , an improved YOLOv7 head And a smart router composition. and Combined into a network to process images judged to be "simple"; and Combined into another network to process images judged to be "complex". Multi-scale features extracted from Will first be entered into the smart router In the example, the routers use their predicted difficulty scores To select the network, in order to enhance the features of complex images, dense composite connections are used to Extracted multi-scale features Embed in In this way, the detection capability of subsequent complex images is improved.
[0089] During the detection process, the input image Will first be sent to the first backbone network Extract multi-scale features ,in Represents the input image Backbone network Then, the router These features will be entered To predict the difficulty score of the image ,in According to the prediction result of the router, if the router classifies the input image as a "simple" image, the feature Pass to head Perform standard target detection and output the detection results If the router classifies the input image as "complex", the multi-scale features will need to be further enhanced by a second backbone, first using a composite connection module composed of dense composite connections. Multi-scale features Embed in middle Then, the input image Re-send it to the second backbone network and combine it with the composite features Combine and sum the features of each scale to obtain new multi-scale features Finally, through the head The test results will be output .
[0090] Step 5: Train the dynamic object detection model on the standard dataset, which includes the following steps:
[0091] Step 5.1, train two improved YOLOv7 models using the PASCAL VOC 2012 dataset. Set appropriate hyperparameters and input them into the dynamic object detection model. The model consists of two main parts: the first network ( , ) is responsible for processing simple images, and the second network ( , ) is responsible for processing complex images. During the training process, the smart router The parameters of are kept frozen, that is, their weights and biases are fixed and do not participate in gradient updates. The input image is processed by both networks at the same time, and the loss function of each network is calculated separately. and ,in, is the input image, is the actual annotation, and are the learnable parameters of the network, and Represents the loss of the two networks, which is used to evaluate the gap between the network output and the actual annotation. During the training process, the loss value is passed to each layer of the network through the back propagation algorithm to gradually optimize the weights and biases of the network. is the sum of the two network losses, as shown below:
[0092] ,
[0093] In each training iteration, the total loss is used for back propagation, the gradients of each network are calculated, and the parameters of the YOLOv7 model are updated based on these gradients. In addition, the model is regularly evaluated using the validation set to calculate indicators such as precision and recall to ensure the effectiveness of the training process. Training will continue until the preset maximum number of iterations is reached, or the performance of the validation set is no longer significantly improved.
[0094] Step 5.2, train the smart router, again using the PASCAL VOC 2012 dataset as input, and train the entire dynamic object detection model (including the smart router ) to optimize the parameters of the router. The task of the intelligent router is to judge the difficulty of the image based on the multi-scale features of the input image and decide which network to use for target detection. Specifically, the input image first passes through the backbone network , the smart router calculates the difficulty score based on the image features , this score determines which network the image will pass through for subsequent processing. During the training of the router, the parameters of the two YOLOv7 networks are frozen to ensure that their weights and biases do not participate in the gradient update. Router loss The calculation formula is as follows:
[0095] ,
[0096] in represents the difference in training loss between the first and second networks, They are used to reward the first network and punish the second network respectively.
[0097] Compared with the prior art, the present invention greatly improves the target detection capability and detection efficiency of the YOLOv7 model by introducing a multi-convolution fusion module and a bidirectional feature pyramid feature fusion structure. In addition, the present invention constructs a dynamic target detection model by using an improved YOLOv7 and an intelligent router, and adaptively processes images according to the complexity of the images, thereby ensuring the detection speed while maintaining the detection accuracy. And only one hyperparameter needs to be adjusted to adapt the model to different speed and accuracy requirements. The present invention tested the performance on the PASCAL VOC 2012 target detection standard dataset, which contains 20 categories, of which 13,500 images are used for training and 3,595 images are used for verification and testing. The present invention conducted experiments on an Nvidia RTX 4090 GPU, and the effect of the dynamic target detection model on the PASCAL VOC 2012 dataset is as follows. Figure 5 As shown in Figure 2, mAP@0.5:0.95 can reach 61.2% at 83 FPS, and 60.3% at 169 FPS.
[0098] The present invention provides a target detection method and system based on a dynamic neural network. There are many methods and ways to implement the technical solution. The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the protection scope of the present invention. All components not specified in this embodiment can be implemented by existing technologies.
Claims
1. A target detection method based on dynamic neural network, characterized in that: The following steps are involved: Step 1: Obtain a public target detection dataset and perform preprocessing; Step 2, improve the YOLOv7 model; Step 3, build a dynamic target detection model based on improved YOLOv7; Step 4: Use the preprocessed data set to train and verify the dynamic target detection model; Step 5: Take the image to be detected as input and perform target detection using the trained dynamic target detection model.
2. The method according to claim 1, characterized in that In step 1, the annotation file of the target detection dataset is in XML format, containing target categories and bounding box information. The annotation file is converted to YOLO format. During the conversion, the XML format annotation file is first read, and the corresponding category index is found in the pre-set category file according to the category name. For each target, the bounding box coordinates of the target in the XML format annotation file are obtained, the center coordinates and width and height are calculated and normalized, so as to convert the bounding box coordinates to YOLO format; finally, the category index and the converted bounding box coordinate information are saved in YOLO format in a txt file with the same name as the image.
3. The method according to claim 2, characterized in that Step 2 contains the following steps: Step 2.1, use convolution, partial convolution, depth-separable convolution, layer normalization, Gaussian error linear unit activation and global response normalization to construct a multivariate convolution fusion module. The multivariate convolution fusion module adopts a parallel structure and includes three independent branches, namely the first branch, the second branch and the third branch. The first branch and the second branch both use partial convolution to perform local convolution on the input feature map. 1 / 4 of the input channels are selected to apply the partial convolution operation. The floating-point operation number of the partial convolution is , the memory access amount is ;in, represents the height of the feature map, represents the feature map width, represents the convolution kernel size, Indicates the number of output channels. The number of input channels is 1 / 4, the number of floating-point operations is 1 / 16 of that of ordinary convolution, and the memory access volume is 1 / 4 of that of ordinary convolution; The third branch first uses convolution to extract features from the input feature map, and then uses depthwise separable convolution to reduce the amount of calculation and the number of parameters, while maintaining the spatial structure of the features. Then, the third branch introduces a layer normalization to normalize the features. In the feature processing process, Gaussian error linear unit activation and global response normalization operations are also used to increase the nonlinear characteristics of the network. The calculation formula of Gaussian error linear unit activation is: , in, is the Gaussian error linear unit activation function, is the input feature map; global response normalization includes global feature aggregation, feature normalization and feature calibration. First, in global feature aggregation, the feature map on each channel is aggregated using the L2 norm to obtain the aggregated vector. Then, in feature normalization, the standard division normalization function is used to normalize the aggregated vector. Finally, in feature calibration, the normalized vector is used to calibrate the original feature map. Finally, the outputs of the first branch, the second branch, and the third branch are merged through a concatenation operation to form the final output of the multivariate convolutional fusion module; Step 2.2, use the multi-convolution fusion module to replace the efficient layer aggregation module in the YOLOv7 backbone network; Step 2.3, introduce a bidirectional feature pyramid into the neck network of YOLOv7, replace the original connection operation with a weighted feature fusion operation, and dynamically adjust the contribution of different features at each fusion node according to the importance of the feature. The formula for the weighted feature fusion operation is: , in, is the output feature map, is the number of feature maps that need to be fused, It is Input feature maps, yes The corresponding weight coefficient represents the input feature map Contribution of Then, the network is simplified by removing nodes that have only one input edge, and finally an extra edge is added from the original input to the output node.
4. The method according to claim 3, characterized in that Step 3 includes: Step 3.1, build a smart router; In step 3.2, a dynamic target detection model is constructed using the improved YOLOv7 model and the smart router.
5. The method according to claim 4, characterized in that Step 3.1 includes: Step 3.1.1, the smart router uses the pooling layer as the first layer of input, and then passes it through two fully connected layers to obtain the difficulty score, which will be used to determine whether the image is a complex image; Multi-scale features extracted in the backbone network First, it will go through the pooling operation, multi-scale features include Features of different scales are represented as ,in Representing multi-scale features Included Features, each are features of different scales extracted from the image, The value ranges from 1 to L, and each feature All are pooled to extract important information at all scales. The features after pooling are concatenated into a feature vector , expressed as: , in, represents the concatenation operation of features, It is for The result after pooling the stage features; Step 3.1.2, concatenated feature vector It will be mapped through two learnable fully connected layers to obtain a difficulty score; the feature vector It will be mapped through the first fully connected layer, activated by ReLU, then mapped through the second fully connected layer, and normalized by Sigmoid activation to finally get a difficulty score, the formula is: , in is a learnable parameter, is the ReLU activation function, is the Sigmoid activation function.
6. The method according to claim 5, characterized in that Step 3.2 includes: Step 3.2.1, prepare two improved YOLOv7 backbone networks ,in For processing simple images, Used to process complex images; prepare a standard YOLOv7 head , used to perform conventional target detection tasks, provide target classification and positioning information; at the same time, an improved YOLOv7 head is also prepared , by using a bidirectional feature pyramid to fuse the features of complex images; finally, an intelligent router is also needed , used to select a network based on the difficulty score of the image; Step 3.2.2, and Combined into a network to process images judged to be simple and Combined into another network for processing images judged to be complex; Multi-scale features extracted from Will first be entered into the smart router In, smart router The difficulty of the image is determined based on the input features, the network is selected based on the predicted difficulty score, and dense composite connections are used to connect Extracted multi-scale features Embed in middle; Step 3.2.3, during the detection process, input image Will first be sent to the first backbone network Extract features: , in Represents the input image Backbone network Processing; then, the smart router The input features To predict the difficulty score of an image : , in , Represents input features Through smart router Processing, if the smart router Classify the input image into simple images, the following head The test results will be output : , If the smart router If the input image is classified as a complex image, the multi-scale features will need to be further enhanced by a second backbone, first using a composite connection module composed of dense composite connections Multi-scale features Embed in middle: , Then, the input image Re-send it to the second backbone network and combine it with the composite features Combine and sum the features of each scale to obtain new multi-scale features : , Through the head Output test results .
7. The method according to claim 6, characterized in that Step 4 includes: Step 4.1, train two improved YOLOv7 models; Step 4.2, train the smart router.
8. The method according to claim 7, characterized in that Step 4.1 includes: Step 4.1.1, use the constructed data set to train two improved YOLOv7 models. The two improved YOLOv7 models are the first network ( , ) and the second network ( , ), the first network ( , ) processes simple images, and the second network ( , ) Processing complex images; Step 4.1.2, Freeze the Smart Router , keep the parameters fixed and do not participate in training; Step 4.1.3, during the training process, the input image will pass through the first network ( , ) and the second network ( , ) is processed, the first network ( , ) and the second network ( , ) will calculate their respective loss functions based on the input image and the corresponding annotation data and ,in, is the actual annotation, and They are the first network ( , ) and the learnable parameters of the second network ( , ), and Represent the first network ( , ) and the second network ( , ) loss; during the training process, the loss value is passed to each layer of the network through the back propagation algorithm, and the weights and biases of the network are gradually optimized; Step 4.1.4, based on the total loss Perform back propagation to optimize the parameters of the two networks and the total loss The expression is: , During the training process, iterative training is performed, the dynamic target detection model is verified on the validation set, and the accuracy and recall of the model are evaluated. The training process is completed until the preset number of iterations is reached or the performance of the validation set is no longer improved.
9. The method according to claim 8, characterized in that Step 4.2 includes: Step 4.2.1, input the constructed data set into the dynamic target detection model with set hyperparameters for training; Step 4.2.2, freeze the first network ( , ) and the second network ( , ), keeping the parameters fixed; Step 4.2.3, the input image goes through the entire dynamic target detection model, including the intelligent router , according to the smart router Loss Back propagation, optimizing smart routers Parameters, loss The expression is: , in For the first network ( , ) and the second network ( , ), Respectively used to reward the first network ( , ) and penalize the second network ( , ).
10. A target detection system based on a dynamic neural network implemented by the method according to any one of claims 1 to 9, characterized in that: include: The dataset construction module is used to construct the preprocessed PASCAL VOC 2012 dataset images into a complete dataset; YOLOv7 model improvement module, which is used to replace the efficient layer aggregation module in the backbone network with the multi-convolution fusion module, introduce the bidirectional feature pyramid into the neck network of YOLOv7, and build an improved YOLOv7 model; Dynamic target detection model construction module, build intelligent router, introduce improved YOLOv7 model, and build dynamic target detection model; The model training module is used to input the PASCAL VOC 2012 dataset into the dynamic target detection model for training, and train the improved YOLOv7 model respectively. After obtaining the optimized YOLOv7 model, the parameters of the smart router are optimized, and finally a dynamic target detection model suitable for target detection is obtained.
Citation Information
Patent Citations
Fire detection early warning method based on attention mechanism and multi-scale characteristics
CN116343077A
Automatic driving multi-target detection method based on instance adaptive dynamic neural network
CN117237893A
Dense pedestrian detection method based on YOLO
CN117456452A
YOLOv7-tiny-based efficient real-time target detection method
CN118015253A
Flying bird dynamic target detection method and system based on flapping wing conversion frequency
CN118465767A
Cited By
Product quality detection method of adaptive adjustment feature fusion layer
CN121414669A
Small mechanical part defect visual detection system based on YOLO lightweight
CN121921281A