A target detection method and system based on dynamic neural network
By introducing a multivariate convolutional fusion module and a bidirectional feature pyramid into the YOLOv7 model, and combining it with an intelligent router, a dynamic object detection model is constructed, which solves the problem of balancing accuracy and speed in existing technologies and improves detection performance in complex scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NANJING UNIV OF INFORMATION SCI & TECH
- Filing Date
- 2024-12-02
- Publication Date
- 2026-07-31
AI Technical Summary
Existing object detection methods fall short in balancing accuracy and speed, especially in complex scenarios, and existing dynamic networks have limitations in multi-scale feature processing, making them difficult to adapt to different task requirements.
The efficient layer aggregation module of the YOLOv7 backbone network is replaced by a multi-convolutional fusion module. A bidirectional feature pyramid and a smart router are introduced to build a dynamic object detection model. The detection strategy is dynamically adjusted according to the image difficulty. The improved YOLOv7 model is used to process simple or complex images.
It significantly improves the flexibility and adaptability of target detection, enhances detection accuracy and efficiency, and can dynamically adjust processing strategies to achieve optimal performance, especially in complex scenarios.
Smart Images

Figure CN119723239B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and deep neural network technology, and specifically to a target detection method and system based on dynamic neural networks. Background Technology
[0002] Object detection is a core task in computer vision, aiming to identify and locate specific objects in images or videos. It is widely used in fields such as autonomous driving, intelligent surveillance, and multi-object tracking. Its main performance metrics are accuracy and inference speed. In recent years, the rapid development of deep learning has greatly promoted the advancement of object detection technology, especially achieving remarkable results in complex scenes.
[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 offers high accuracy but incurs significant computational overhead and slow inference speed. Single-stage detectors, such as the YOLO series and SSD, complete object detection in a single forward pass, using a fixed grid or anchor boxes to simultaneously predict the object's class and location. They offer high inference speed and are suitable for real-time applications. However, these methods often compromise on accuracy, especially in complex environments.
[0004] While both types of detectors have their advantages and disadvantages, they generally suffer from a trade-off between accuracy and speed, and exhibit poor adaptability to task requirements. As application demands change, existing detection networks often need to be redesigned and retrained, reducing flexibility. To address these issues, dynamic neural networks have emerged as an emerging technology. Unlike traditional fixed-structure networks, dynamic neural networks can flexibly adjust their structure and computational processes based on input data, environment, or task requirements, thereby improving model adaptability and computational efficiency.
[0005] Dynamic neural networks exhibit greater flexibility in deep learning, capable of dynamically adjusting their network structure based on image complexity. While current dynamic networks often employ 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 identifying multiple objects of different categories and scales but also extracting multi-scale features for precise localization, making full-scale feature processing essential. The limitations of existing dynamic networks in this regard restrict their application in object detection tasks.
[0006] Furthermore, existing object detectors still perform unsatisfactorily in complex scenes, especially with multi-scale objects and occlusion. Therefore, designing a new, more stable, and adaptable object detector, particularly a dynamic object detection network model capable of handling multi-scale features and complex scenes, is 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 dynamic neural networks, which addresses the shortcomings of the existing technology.
[0008] The method includes the following steps:
[0009] Step 1: Obtain a publicly available object detection dataset and perform preprocessing;
[0010] Step 2: Improve the YOLOv7 model;
[0011] Step 3: Construct a dynamic object detection model based on the improved YOLOv7;
[0012] Step 4: Train and validate the dynamic object detection model using the preprocessed dataset;
[0013] Step 5: Use the image to be detected as input and perform object detection using the trained dynamic object detection model.
[0014] In step 1, the object detection dataset is the PASCAL VOC 2012 dataset. The annotation file of the object detection dataset is in XML format, containing object categories and bounding box information. The annotation file is converted to YOLO format. During the conversion, the XML format annotation file is read first, and the corresponding category index is found in the pre-defined category file according to the category name. For each object, the bounding box coordinates of the object in the XML format annotation file are obtained, the center coordinates and width and height are calculated and normalized, thereby converting the bounding box coordinates to YOLO format. Finally, the category index and the converted bounding box coordinate information are saved in YOLO format to a txt file with the same name as the image.
[0015] Step 2 includes the following steps:
[0016] Step 2.1: Convolution, partial convolution, depthwise 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, which includes three independent branches: the first branch, the second branch, and the third branch. Each branch undertakes a different feature processing task.
[0017] Both the first and second branches employ partial convolution to perform local convolution on the input feature maps. Partial convolution is applied to 1 / 4 of the input channels to reduce computation and improve feature extraction efficiency. The floating-point number of partial convolution operations is... Memory access volume is Where h represents the height of the feature map, and w represents the width of the feature map. Indicates the kernel size. This indicates the number of output channels. It has 1 / 4 the number of input channels, 1 / 16 the number of floating-point operations, and 1 / 4 the memory access of a normal convolution.
[0018] The third branch first uses convolution to extract features from the input feature map, then uses depthwise separable convolution to reduce computation and the number of parameters while preserving the spatial structure of the features. Next, the third branch introduces a layer normalization to normalize the features, thereby improving the stability of the model and training efficiency.
[0019] In the feature processing, Gaussian error linear unit activation and global response normalization operations are also used to increase the nonlinearity of the network. The calculation formula for Gaussian error linear unit activation is as follows:
[0020] ,
[0021] in, Let Gaussian error be the activation function of the linear unit. The input feature map is used. 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 an aggregated vector. Then, in feature normalization, the aggregated vector is normalized using the standard division normalization function. Finally, in feature calibration, the normalized vector is used to calibrate the original feature map.
[0022] Finally, the outputs of the first, second, and third branches are merged through a concatenation operation to form the final output of the multivariate convolutional fusion module;
[0023] Step 2.2: Replace the efficient layer aggregation module in the YOLOv7 backbone network with a multivariate convolutional fusion module to improve the efficiency of feature extraction and the performance of the network.
[0024] Step 2.3 introduces a bidirectional feature pyramid into the neck network of YOLOv7, replacing the original connection operation with a weighted feature fusion operation. At each fusion node, the contribution of different features is dynamically adjusted according to their importance. The formula for the weighted feature fusion operation is as follows:
[0025] ,
[0026] in, To output the feature map, The number of feature maps that need to be fused. It is the first One input feature map, yes The corresponding weight coefficients represent the input feature maps. The degree of contribution.
[0027] Then, nodes with only one input edge are removed to simplify the network. Finally, an additional edge is added between the original input and the output node to fuse more feature information.
[0028] Step 3 includes:
[0029] Step 3.1, Build a smart router;
[0030] Step 3.2: Construct a dynamic object detection model using the improved YOLOv7 model and a smart router.
[0031] Step 3.1 includes:
[0032] Step 3.1.1: The smart router uses a pooling layer as the first input layer, and then obtains a difficulty score through two fully connected layers. The difficulty score is used to determine whether the image is a complex image.
[0033] Multi-scale features extracted from the backbone network First, it undergoes pooling operations, multi-scale features. include Features at different scales are represented as follows: ,in Representing multi-scale features Including the Each feature These are features extracted from images at different scales. The value ranges from 1 to L, and each feature All features undergo pooling operations to extract important information across all scales. Concatenated into a single feature vector , is represented as:
[0034] ,
[0035] in, Represents the concatenation operation of features. It is the first The result of pooling stage features; through this processing method, the router can effectively fuse features at different scales and capture a variety of information.
[0036] Step 3.1.2, the concatenated feature vector It will be mapped through two learnable fully connected layers to obtain a difficulty score. Feature vector The process involves mapping through a first fully connected layer, followed by ReLU activation, then mapping through a second fully connected layer, and normalizing using Sigmoid activation. The final difficulty score is obtained using the following formula:
[0037] ,
[0038] in These are learnable parameters. It is the ReLU activation function. The activation function is Sigmoid. Difficulty score. The closer the value is to 1, the more difficult the image processing is; conversely, the closer it is to 1, the easier it is.
[0039] Step 3.2 includes:
[0040] Step 3.2.1: Prepare two improved YOLOv7 backbone networks. ,in Used for processing simple images. Used for processing complex images. Additionally, a standard YOLOv7 header is prepared. It is used to perform routine object detection tasks, providing object classification and localization information; it also prepares an improved YOLOv7 header. This is achieved by fusing features from complex images using a bidirectional feature pyramid. Finally, a smart router is also required. This is used to select the appropriate network based on the difficulty score of the image;
[0041] Step 3.2.2, will and Combined into a network, used to process images judged to be simple, and They are combined into another network to process images that are deemed complex. Multiscale features extracted It will first be input into the smart router In China, smart routers The image difficulty is determined based on its input features, and a network is selected based on the predicted difficulty score. Dense composite connections are then used to... Extracted multi-scale features Embedded into This improves the detection capability of subsequent complex images;
[0042] Step 3.2.3: During the detection process, input the image. It will be sent to the first backbone network first. Feature extraction:
[0043] ,
[0044] in Indicates the input image Through the backbone network Processing. Then, the smart router. Input features To predict the difficulty score of an image :
[0045] ,
[0046] in , Representing input features via smart router If the smart router The input image is classified into simple images, and then the head... Output detection results :
[0047] ,
[0048] If smart router To classify the input image as a complex image, the multi-scale features will require a second backbone for further enhancement. This is achieved by first using a composite connection module composed of dense composite connections. Multiscale features Embedded into middle:
[0049] ,
[0050] Then, the input image Re-feeding into the second backbone network and combining composite features By combining the features at each scale, a summation operation is performed to obtain new multi-scale features. :
[0051] ,
[0052] Through the head Output detection 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 pre-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 ( , The second network processes simple images. , Processing complex images;
[0058] Step 4.1.2, Freeze the smart router The parameters remain fixed and are not used in training;
[0059] Step 4.1.3, during training, the input image will simultaneously pass through the first network ( , ) and the second network ( , ) to process, the first network ( , ) and the second network ( , It will calculate its respective loss function based on the input image and the corresponding labeled data. and ,in, This is the actual annotation. and These are the first network ( , The learnable parameters of the second network and the second network ( , Learnable parameters of ) and They represent the first network ( , The loss of the second network () , The loss is calculated by using the backpropagation algorithm to pass the loss value to each layer of the network during training, thereby gradually optimizing the weights and biases of the network.
[0060] Step 4.1.4, based on the total loss Perform backpropagation to optimize the parameters of both networks, and the total loss... The expression is:
[0061] ,
[0062] During training, iterative training is performed, and the dynamic object detection model is validated on a validation set to evaluate the model's accuracy and recall. The training process continues until the preset number of iterations is reached or the validation set performance no longer improves, at which point the network model training is complete.
[0063] Step 4.2 includes:
[0064] Step 4.2.1 involves inputting the constructed PASCAL VOC 2012 dataset into the dynamically configured object detection model for training. At this stage, the router's role is to determine the difficulty of the input image based on its multi-scale features and decide which network to use for object detection. During training, the input image is processed through the complete network architecture, including the intelligent router's decisions. To train the router, data is first input into the backbone network. In this process, a difficulty score is calculated for each image via a router. This score is used to determine which network the image will pass through for further processing.
[0065] Step 4.2.2, freeze the first network ( , ) and the second network ( , This involves keeping the parameters constant, meaning maintaining the weights and biases of both networks fixed and not allowing them to participate in gradient updates. The purpose of this is to ensure the intelligent router remains stable during training. It can independently learn how to assess image complexity and make correct decisions. Freezing the parameters of the YOLOv7 model helps to focus on optimizing the intelligent router and avoids unnecessary interference during model training.
[0066] Step 4.2.3: The input image passes through the entire dynamic object detection model, including the intelligent router. According to smart routers loss Backpropagation to optimize smart routers The parameters, loss The expression is:
[0067] ,
[0068] in For the first network ( , ) and the second network ( , The difference in training loss, These are used to reward the first network ( , ) and punish the second network ( , The loss function reflects the accuracy of the router's decisions. In this stage, the router's parameters are updated based on the loss value through backpropagation, thereby optimizing its decision-making process and ensuring that it can efficiently select the appropriate detection network based on 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 building module is used to build a complete dataset from the preprocessed PASCAL VOC 2012 dataset images;
[0071] The YOLOv7 model improvement module is used to replace the efficient layer aggregation module in the backbone network with a multivariate convolutional fusion module and introduce a bidirectional feature pyramid into the neck network of YOLOv7 to build an improved YOLOv7 model.
[0072] The dynamic object detection model building module constructs an intelligent router by introducing the improved YOLOv7 model to build a dynamic object detection model.
[0073] The model training module is used to input the PASCAL VOC 2012 dataset into the dynamic object detection model for training. It trains the improved YOLOv7 model separately, and then optimizes the parameters of the smart router to obtain a dynamic object detection model suitable for object detection.
[0074] This invention improves YOLOv7 by introducing a multi-convolutional fusion module and a bidirectional feature pyramid, thereby enhancing the model's feature fusion capability, effectively solving the problem of small target loss, and significantly improving detection efficiency. Simultaneously, this 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. This invention not only achieves significant breakthroughs in improving the accuracy and efficiency of target detection but also brings new development directions to the field of target detection, especially providing a more flexible and efficient solution in dynamic task environments.
[0075] The beneficial effects of this invention are as follows: This invention proposes a dynamic object detection model. Based on YOLOv7, a multi-convolutional fusion module replaces the original high-efficiency layer aggregation module. By optimizing the network structure and reducing redundant parameters, the computational complexity and runtime of the model are effectively reduced, enabling the dynamic object detection model to adapt to more resource-constrained application scenarios while maintaining high performance. Furthermore, a bidirectional feature pyramid is used instead of the original structure at the network neck, resulting in higher efficiency in feature fusion, especially when processing multi-scale features. This allows for more effective integration of information from different levels, enhancing the network's ability to capture details and thus improving overall detection performance, particularly in complex scenes. Further, this invention uses the improved YOLOv7 and a smart router to form a dynamic detector, achieving dynamic detection of images with varying complexities. For complex images, the system selects to perform more processing steps to achieve higher detection accuracy; while for simple images, it reduces processing steps to accelerate detection. This dynamic adjustment strategy not only improves detection efficiency but also ensures optimal detection performance in different scenarios. Attached Figure Description
[0076] Figure 1 This is a diagram of the multi-convolutional fusion module of the present invention.
[0077] Figure 2 This is a diagram of the bidirectional feature pyramid structure in this invention.
[0078] Figure 3 This is a diagram of the improved YOLOv7 model in this invention.
[0079] Figure 4 This is a diagram of the dynamic target detection model in this invention.
[0080] Figure 5 This is the validation result of the present invention on the PASCAL VOC 2012 dataset. Detailed Implementation
[0081] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments, and other advantages of the present invention will become clearer.
[0082] Figure 1 Taking the multi-convolutional 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 structure diagram of a dynamic target detection model as an example, the implementation process and details of a target detection method based on a dynamic neural network proposed in this embodiment of the invention will be described in detail.
[0083] Figure 1 The detailed structure of the multi-convolutional fusion module is shown. Figure 2 The bidirectional feature pyramid feature map fusion module is constructed, and then based on the YOLOv7 network architecture, it uses... Figure 1 The multi-convolutional fusion module constructed in [the original text] replaces the efficient layer aggregation module in the YOLOv7 backbone network, using [the original text] Figure 2 The bidirectional feature pyramid in the model is used as the structure of the feature fusion layer to obtain, as shown below. Figure 3 The improved YOLOv7 architecture is shown. Subsequently, a smart router is built using the improved YOLOv7 architecture. Figure 4 The dynamic object detection model shown is first trained on an improved YOLOv7, then on a smart router, ultimately resulting in a dynamic object detection model that can adaptively adjust based on image complexity.
[0084] This invention provides a target detection method based on a dynamic neural network, comprising the following steps:
[0085] Step 1: Construct as follows Figure 1 The multi-convolutional fusion module shown employs a three-branch structure, combining convolution, partial convolution, depthwise separable convolution, layer normalization, Gaussian error linear unit activation, and global response normalization. The first and second branches use local convolution, operating only on 1 / 4 of the input channels to reduce computation and improve efficiency, and capture different levels of features through varying parameter settings. The third branch first extracts features using Conv, then reduces computation and parameter count through depthwise separable convolution while preserving feature structure. It then normalizes the features through layer normalization and uses Gaussian error linear unit activation to enhance the non-linearity of the global response normalization. The outputs of the three branches are concatenated and merged to generate the final result.
[0086] Step 2: Based on the YOLOv7 network architecture, replace the high-efficiency layer aggregation module in the backbone network with the multivariate convolutional fusion module from Step 1.
[0087] Step 3: Introduce, for example, into the feature fusion layer Figure 2 The bidirectional feature pyramid feature fusion structure is shown. Unlike traditional structures, the bidirectional feature pyramid removes nodes with only one input edge and adds an extra edge between the original input and output nodes. The improved final network architecture is as follows. Figure 3 As shown, the original join operation is replaced by weighted feature fusion. At each fusion node, the contribution of different features is dynamically adjusted based on their importance. The formula for the weighted fusion operation is: ,in, To output the feature map, The number of feature maps that need to be fused. It is the first One input feature map, yes The corresponding weight coefficients represent the input feature maps. The degree of contribution.
[0088] Step 4: Construct as follows Figure 4 The dynamic target detection model shown consists of two improved YOLOv7 backbone networks. A standard YOLOv7 header An improved YOLOv7 header and a smart router composition. and They are combined into a network to process images judged as "simple"; and They are combined into another network to process images that are judged to be "complex". Multiscale features extracted It will first be input into the smart router In the middle, the router is based on its predicted difficulty score. To select a network, dense compound connections are used to enhance the features of complex images. Extracted multi-scale features Embedded into This improves the detection capability of subsequent complex images.
[0089] During the detection process, the input image is... It will be sent to the first backbone network first. Extracting multi-scale features ,in Indicates the input image Through the backbone network Process. Then, the router. These features will be input To predict the difficulty score of the image ,in Based on the router's prediction, if the router classifies the input image as a "simple" image, then the features... Transmitted to the head Perform standard target detection and output the detection results. If the router classifies the input image as a "complex" image, then the multi-scale features will require further enhancement via a second backbone, initially using a composite connection module composed of dense composite connections. Multiscale features Embedded into middle Then, the input image Re-feeding into the second backbone network and combining composite features By combining the features at each scale, a summation operation is performed to obtain new multi-scale features. Finally, through the head Output detection results .
[0090] Step 5: Train the dynamic object detection model on a standard dataset, including 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. This model consists of two main parts: the first network ( , The first network is responsible for processing simple images, and the second network ( , The intelligent router is responsible for processing complex images. During training, the intelligent router... The parameters are kept frozen, meaning their weights and biases are fixed and they do not participate in gradient updates. The input image is processed by two networks simultaneously, and the loss function of each network is calculated separately. and ,in, It is the input image. This is the actual annotation. and These are the learnable parameters of the network. and These represent the losses of the two networks, used to evaluate the difference between the network output and the actual annotations. During training, the loss values are propagated to each layer of the network using the backpropagation algorithm, progressively optimizing the network weights and biases. Total loss. The sum of the losses of the two networks is shown below:
[0092] ,
[0093] In each training iteration, backpropagation is performed using the total loss to compute the gradient of each network, and the parameters of the YOLOv7 model are updated based on these gradients. Furthermore, the model is periodically evaluated using a validation set, calculating metrics such as precision and recall to ensure the effectiveness of the training process. Training continues until the preset maximum number of iterations is reached, or the performance on the validation set no longer shows significant improvement.
[0094] Step 5.2: Train the intelligent router. Again, use the PASCAL VOC 2012 dataset as input to train the entire dynamic object detection model (including the intelligent router). This optimizes the router's parameters. The intelligent router's task is to determine the difficulty of the input image based on its multi-scale features and decide which network to use for object detection. Specifically, the input image first passes through the backbone network... The intelligent router calculates a difficulty score based on image features. This score determines which network the image will be processed by next. During router training, the parameters of the two YOLOv7 networks are frozen to ensure their weights and biases do not participate in gradient updates. Router loss. The calculation formula is as follows:
[0095] ,
[0096] in This represents the difference in training loss between the first and second networks. These are used to reward the first network and punish the second network, respectively.
[0097] Compared with existing technologies, this invention significantly improves the object detection capability and efficiency of the YOLOv7 model by introducing a multi-convolutional fusion module and a bidirectional feature pyramid feature fusion structure. Furthermore, this invention constructs a dynamic object detection model using an improved YOLOv7 and a smart router, adaptively processing images based on their complexity, ensuring detection speed while maintaining accuracy. Moreover, only one hyperparameter needs to be adjusted to adapt the model to different speed and accuracy requirements. The performance of this invention was tested on the PASCAL VOC 2012 object detection standard dataset, which contains 20 categories, with 13,500 images used for training and 3,595 images used for validation and testing. Experiments were conducted on an Nvidia RTX 4090 GPU, and the dynamic object detection model performed as follows on the PASCAL VOC 2012 dataset: Figure 5 As shown, at 83 FPS, mAP@0.5:0.95 can reach 61.2%, while at 169 FPS, mAP@0.5:0.95 can still reach 60.3%.
[0098] This invention provides a target detection method and system based on a dynamic neural network. Many methods and approaches exist for implementing this technical solution; the above description is merely a preferred embodiment of the invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of this invention, and these improvements and modifications should also be considered within the scope of protection of this invention. All components not explicitly stated in this embodiment can be implemented using existing technologies.
Claims
1. A target detection method based on a dynamic neural network, characterized in that, Includes the following steps: Step 1: Obtain a publicly available object detection dataset and perform preprocessing; Step 2, improve the YOLOv7 model; Step 2 includes the following steps: Step 2.1: Convolution, partial convolution, depthwise 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. Both the first and second branches employ partial convolution to perform local convolution on the input feature maps. Partial convolution is applied to 1 / 4 of the input channels, and the floating-point number of partial convolution operations is... Memory access volume is ;in, Indicates the height of the feature map. Indicates the width of the feature map. Indicates the kernel size. This indicates the number of output channels. It has 1 / 4 the number of input channels, 1 / 16 the number of floating-point operations, and 1 / 4 the memory access of ordinary convolution; The third branch first uses convolution to extract features from the input feature map, then uses depthwise separable convolution to reduce computation and the number of parameters while preserving the spatial structure of the features. Next, the third branch introduces a layer normalization to normalize the features. In the feature processing, Gaussian error linear unit activation and global response normalization operations are also used to increase the nonlinearity of the network. The calculation formula for Gaussian error linear unit activation is as follows: , in, Let Gaussian error be the activation function of the linear unit. The input feature map is used; 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, second, and third branches are merged through a concatenation operation to form the final output of the multivariate convolutional fusion module; Step 2.2: Replace the high-efficiency layer aggregation module in the YOLOv7 backbone network with a multivariate convolutional fusion module; Step 2.3 introduces a bidirectional feature pyramid into the neck network of YOLOv7, replacing the original connection operation with a weighted feature fusion operation. At each fusion node, the contribution of different features is dynamically adjusted according to their importance. The formula for the weighted feature fusion operation is as follows: , in, To output the feature map, The number of feature maps that need to be fused. It is the first One input feature map, yes The corresponding weight coefficients represent the input feature maps. The degree of contribution; Then, nodes with only one input edge are removed to simplify the network, and finally an extra edge is added between the original input and the output node. Step 3: Construct a dynamic object detection model based on the improved YOLOv7; Step 4: Train and validate the dynamic object detection model using the preprocessed dataset; Step 5: Use the image to be detected as input and perform object detection using the trained dynamic object detection model.
2. The method according to claim 1, characterized in that, In step 1, the annotation file of the object detection dataset is in XML format, containing object categories and bounding box information. The annotation file is converted to YOLO format. During the conversion, the XML format annotation file is read first, and the corresponding category index is found in the pre-defined category file according to the category name. For each object, the bounding box coordinates of the object in the XML format annotation file are obtained, the center coordinates and width and height are calculated and normalized, thereby converting the bounding box coordinates to YOLO format. Finally, the category index and the converted bounding box coordinate information are saved in YOLO format to a txt file with the same name as the image.
3. The method according to claim 2, characterized in that, Step 3 includes: Step 3.1, Build a smart router; Step 3.2: Construct a dynamic object detection model using the improved YOLOv7 model and a smart router.
4. The method according to claim 3, characterized in that, Step 3.1 includes: Step 3.1.1: The smart router uses a pooling layer as the first input layer, and then obtains a difficulty score through two fully connected layers. The difficulty score is used to determine whether the image is a complex image. Multi-scale features extracted from the backbone network First, it undergoes pooling operations, multi-scale features. include Features at different scales are represented as follows: ,in Representing multi-scale features Including the Each feature These are features extracted from images at different scales. The value ranges from 1 to L, and each feature All features undergo pooling operations to extract important information across all scales. Concatenated into a single feature vector , is represented as: , in, Represents the concatenation operation of features. It is the first The result of pooling the stage features; Step 3.1.2, the concatenated feature vector It will be mapped through two learnable fully connected layers to obtain a difficulty score; feature vector The process involves mapping through a first fully connected layer, followed by ReLU activation, then mapping through a second fully connected layer, and normalizing using Sigmoid activation. The final difficulty score is obtained using the following formula: , in These are learnable parameters. It is the ReLU activation function. This is the Sigmoid activation function.
5. The method according to claim 4, characterized in that, Step 3.2 includes: Step 3.2.1: Prepare two improved YOLOv7 backbone networks. ,in Used for processing simple images. Used for processing complex images; prepares a standard YOLOv7 header. It is used to perform routine object detection tasks, providing object classification and localization information; it also prepares an improved YOLOv7 header. This involves fusing features from complex images using a bidirectional feature pyramid; finally, a smart router is also required. This is used to select a network based on the difficulty score of the image; Step 3.2.2, will and Combined into a network, used to process images judged to be simple, and They are combined into another network to process images that are deemed complex; Multiscale features extracted It will first be input into the smart router In China, smart routers The image difficulty is determined based on its input features, and a network is selected based on the predicted difficulty score. Dense composite connections are then used to... Extracted multi-scale features Embedded into middle; Step 3.2.3: During the detection process, input the image. It will be sent to the first backbone network first. Feature extraction: , in Indicates the input image Through the backbone network Processing; then, the smart router Input features To predict the difficulty score of an image : , in , Representing input features via smart router If the smart router The input image is classified into simple images, and then the head... Output detection results : , If smart router To classify the input image as a complex image, the multi-scale features will require a second backbone for further enhancement. This is achieved by first using a composite connection module composed of dense composite connections. Multiscale features Embedded into middle: , Then, the input image Re-feeding into the second backbone network and combining composite features By combining the features at each scale, a summation operation is performed to obtain new multi-scale features. : , Through the head Output detection results .
6. The method according to claim 5, characterized in that, Step 4 includes: Step 4.1: Train two improved YOLOv7 models; Step 4.2, train the smart router.
7. The method according to claim 6, characterized in that, Step 4.1 includes: Step 4.1.1: Use the prepared dataset to train two improved YOLOv7 models. The two improved YOLOv7 models are the first network ( , ) and the second network ( , ), the first network ( , The second network processes simple images. , Processing complex images; Step 4.1.2, Freeze the smart router The parameters remain fixed and are not used in training; Step 4.1.3, during training, the input image will simultaneously pass through the first network ( , ) and the second network ( , ) to process, the first network ( , ) and the second network ( , It will calculate its respective loss function based on the input image and the corresponding labeled data. and ,in, This is the actual annotation. and These are the first network ( , The learnable parameters of the second network and the second network ( , Learnable parameters of ) and They represent the first network ( , The loss of the second network () , The loss is calculated by using the backpropagation algorithm to pass the loss value to each layer of the network during training, thereby gradually optimizing the weights and biases of the network. Step 4.1.4, based on the total loss Perform backpropagation to optimize the parameters of both networks, and the total loss... The expression is: , During training, iterative training is performed, and the dynamic object detection model is validated on a validation set to evaluate the model's accuracy and recall. The training process continues until the preset number of iterations is reached or the validation set performance no longer improves, at which point the network model training is complete.
8. The method according to claim 7, characterized in that, Step 4.2 includes: Step 4.2.1: Input the constructed dataset into the dynamic object detection model with the hyperparameters set for training; Step 4.2.2, freeze the first network ( , ) and the second network ( , Keep the parameters constant; Step 4.2.3: The input image passes through the entire dynamic object detection model, including the intelligent router. According to smart routers loss Backpropagation to optimize smart routers The parameters, loss The expression is: , in For the first network ( , ) and the second network ( , The difference in training loss, These are used to reward the first network ( , ) and punish the second network ( , ).
9. The target detection system based on a dynamic neural network implemented according to any one of claims 1 to 8, characterized in that, include: The dataset building module is used to build a complete dataset from the preprocessed PASCAL VOC 2012 dataset images; The YOLOv7 model improvement module is used to replace the efficient layer aggregation module in the backbone network with a multivariate convolutional fusion module and introduce a bidirectional feature pyramid into the neck network of YOLOv7 to build an improved YOLOv7 model. The dynamic object detection model building module constructs an intelligent router by introducing the improved YOLOv7 model to build a dynamic object detection model. The model training module is used to input the PASCAL VOC 2012 dataset into the dynamic object detection model for training. It trains the improved YOLOv7 model separately, and then optimizes the parameters of the smart router to obtain a dynamic object detection model suitable for object detection.