Lightweight image detection method and system fusing SPD-HSFPN-RVB
By introducing the lightweight detection method of SPD-HSFPN-RVB into the YOLO framework, the limitations of the remote sensing image detection system in terms of accuracy and real-time performance are solved, efficient feature extraction and fusion is achieved, and detection accuracy and computing efficiency are improved. Suitable for detection needs of remote sensing images.
Patent Information
- Application Number
- CN202410670135.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2024-09-10
AI Technical Summary
Existing remote sensing image detection systems have limitations in terms of accuracy and real-time performance, are easily affected by external environmental factors, and are sensitive to noise and interference. Especially when the target is mixed with the background or the target shape changes significantly, the detection accuracy decreases, and the model Complexity leads to low computational efficiency.
A lightweight image detection method that integrates SPD-HSFPN-RVB is adopted. By introducing the SPDconv module and RVB module in the YOLO framework, combined with the HSFPN module, the capabilities of feature extraction and downsampling are enhanced, the amount of model parameters is reduced, and through the attention mechanism and Atrous convolution improves feature fusion and improves the model's ability to handle targets of different sizes.
It achieves lightweight and highly computationally efficient image detection, improves detection accuracy and generalization capabilities, significantly reduces the amount of model parameters and calculations, and is suitable for the detection and recognition of remote sensing images. It can handle targets of different sizes more effectively and meet the needs of Actual remote sensing detection needs.
Smart Images

Figure CN118628907A
Abstract
Description
Technical Field
[0001] The present invention relates to the application field of deep learning in the field of computer vision, and specifically to a lightweight image detection method and system integrating SPD-HSFPN-RVB. Background Art
[0002] Remote sensing images are images of the earth's surface information obtained by long-distance sensors such as satellites and aircraft. These images are usually used in map making, environmental monitoring, urban planning, agricultural management and other fields. Remote sensing image detection has a wide range of application scenarios, especially with the continuous advancement of technology and the improvement of data acquisition capabilities, its application prospects are becoming more and more abundant, such as: monitoring natural disasters such as wildfires and floods, monitoring changes in air pollution and water quality, providing information on urban construction, land cover, agriculture, forestry and forestry management, etc.
[0003] Traditional remote sensing image detection systems often rely on rule-based algorithms such as feature extraction, classifiers, and post-processing. However, these systems have certain limitations in terms of accuracy and real-time performance. They are easily affected by external environmental factors such as model parameters, filters, sensors, etc., resulting in errors. There are also many restrictions on usage conditions, such as the need for a large amount of manual participation, poor generalization ability, and sensitivity to noise and interference. If the target is mixed with the background or the target shape changes greatly, it may lead to many problems such as decreased detection accuracy.
[0004] With the rapid development of deep learning technology, especially the breakthrough in the field of target detection, remote sensing image detection methods based on deep learning have become an innovative way to improve the detection level. The target detection algorithm based on deep learning has become a powerful tool for solving remote sensing image detection problems with its efficient real-time and accurate target positioning capabilities. By introducing deep learning technology into the remote sensing image monitoring system and analyzing the pictures of remote sensing images, the deep learning model can identify the corresponding features, such as houses, airports, ships, airplanes, etc. However, in existing machine learning, due to the complexity of the model structure, the number of model parameters and the amount of calculation are extremely large, the calculation efficiency is low, and it is not easy to use. Summary of the invention
[0005] Purpose of the invention: The purpose of the present invention is to provide a lightweight, computationally efficient, SPD-HSFPN-RVB-fused lightweight image detection method and system.
[0006] Technical solution: The lightweight image detection method integrating SPD-HSFPN-RVB described in the present invention includes: acquiring and preprocessing images; establishing a network model based on the YOLO framework, after the preprocessed image is input into the network model, it is processed by the backbone network and the head network in sequence, and output after being inspected by the detection head module; the backbone network includes multiple RVB-EMA modules and SPDconv convolutional layers, and the head network includes multiple HSFPN modules.
[0007] Furthermore, after the image is input into the SPDconv convolution layer, it is output after undergoing space-to-depth transformation, feature map splicing, and convolution processing in sequence.
[0008] Furthermore, the SPDconv convolutional layer transforms the input image X(S, S, C1) by the scale factor in the dimension, splices it in the channel direction, and outputs it after convolution.
[0009] Furthermore, the RVB-EMA module includes an EMA module and an RVB module, the RVB module includes deep convolution, squeeze and excitation layer, dilated convolution and projection layer, and the residual connection jumps over the dilated convolution and projection layer; after the EMA module groups the input tensors, it performs height and width pooling through the spatial attention mechanism, and then enhances the features through multiple convolutions, and calculates the adaptive weights and splices the output.
[0010] Furthermore, the deep convolution is implemented by a RepVGGDW layer, which includes initialization, forward propagation, fused convolution and batch normalization operations, and the forward propagation includes depthwise separable convolution and point convolution.
[0011] Furthermore, the backbone network includes multiple C2f modules, the RVB-EMA module is combined with the C2f module to form a C2f-RVB-EMA module; the RVB module is combined with the C2f module to form a C2f-RVB module.
[0012] Furthermore, the HSFPN module performs feature selection through the attention mechanism and dimension matching to obtain multiple high-level features and low-level features with different expansion rates, unifies the dimensions of the high-level features and the low-level features, and then fuses them through dilated convolution.
[0013] Furthermore, in the HSFPN module, the attention mechanism is implemented by a CA module, which uses global average pooling and global maximum pooling to calculate the average value and maximum value of each channel respectively; the dimension matching is implemented by a DM module, which unifies the number of feature map channels of each scale to the same number.
[0014] Furthermore, the dilated convolution is implemented by an SFF module, which strategically fuses low-level features by using high-level features as weights to filter basic semantic information embedded in low-level features. The SFF module is performed using the following formula:
[0015] f att =BL(T-Conv(f high ))
[0016] f out =f low *CA(f att )+f att
[0017] In the formula, f att represents the attention feature map; BL represents bilinear interpolation, which is used to adjust the spatial size of the feature map; T-Conv represents transposed convolution, which is used to extract the high-level feature f from the high Expand the size of the feature map; f low represents low-level features; f out represents the fused output feature map; CA represents channel attention, which is applied to the attention feature map to focus on relevant features.
[0018] The lightweight image detection system integrating SPD-HSFPN-RVB of the present invention comprises:
[0019] An image acquisition module, used to acquire and pre-process images;
[0020] The image processing module is used to establish a network model based on the YOLO framework. After the preprocessed image is input into the network model, it is processed by the backbone network and the head network in sequence, and is output after being inspected by the detection head module. The backbone network includes multiple RVB-EMA modules and SPDconv convolutional layers, and the head network includes multiple HSFPN modules.
[0021] Beneficial effects: The present invention has the following significant effects: 1. The present invention achieves lightweight: The present invention proposes a lightweight image detection method and system integrating SPD-HSFPN-RVB, which is deeply customized and optimized on the basis of YOLOv8. The SPDconv module and RVB module are introduced to enhance the feature extraction and downsampling capabilities, and reduce the interference of blurred background on remote sensing image detection. In the Head network, the HSFPN module is also added to further improve the performance of the model in processing target detection tasks. The network can more effectively process targets of different sizes and greatly reduce the number of model parameters. The image target feature extraction technology is used for prediction to identify the image, so that the model The overall accuracy, stability and generalization ability of type detection are improved to a certain extent, and the number of parameters and model size are significantly reduced, thereby realizing the demand for lightweight. 2. High computational efficiency: The present invention combines a variety of algorithms to improve on the YOLO framework, while taking into account the particularity of the image processing process, and adaptively improves each module. It is verified through experiments that while the detection accuracy remains unchanged, the number of parameters and the amount of computation of the model can be significantly reduced, thereby greatly improving the computational efficiency. In addition, it is better at detecting and identifying remote sensing images, has more advantages in detection accuracy and detection rate, has obvious detection effects, meets the needs of actual remote sensing detection, more effectively processes targets of different sizes, and greatly reduces the number of model parameters. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 This is a flow chart of the lightweight image detection method of SPD-HSFPN-RVB;
[0023] Figure 2 This is the overall structure diagram of the network model fused with SPD-RVB-HSFPN;
[0024] Figure 3 This is the workflow diagram of the SPDconv convolutional layer;
[0025] Figure 4 This is the schematic diagram of the image processing process of the SPDconv convolution layer;
[0026] Figure 5 This is a structural comparison diagram of the RVB module before and after improvement;
[0027] Figure 6 It is a schematic diagram of the C2f-RVB-EMA module structure;
[0028] Figure 7 This is the workflow diagram of the HSFPN module;
[0029] Figure 8 This is the schematic diagram of the image processing process of the HSFPN module;
[0030] Fig. 9 A curve diagram of the network model training process proposed by the present invention;
[0031] Fig.10 Schematic diagram of the effect of network model detection. DETAILED DESCRIPTION
[0032] The present invention is further explained below in conjunction with the accompanying drawings and specific implementation methods.
[0033] See also Figure 1 and Figure 2 As shown, the lightweight image detection method integrating SPD-HSFPN-RVB described in the present invention includes: acquiring and preprocessing images; establishing a network model based on the YOLO framework, after the preprocessed image is input into the network model, it is processed by the backbone network and the head network in sequence, and is output after being inspected by the detection head module; the backbone network includes multiple RVB-EMA modules and SPDconv convolutional layers, and the head network includes multiple HSFPN modules.
[0034] The lightweight image detection system integrating SPD-HSFPN-RVB described in the present invention includes: an image acquisition module, used for acquiring and preprocessing images; an image processing module, used for establishing a network model based on a YOLO framework, after the preprocessed image is input into the network model, it is processed by a backbone network and a head network in sequence, and is output after being inspected by a detection head module; the backbone network includes a plurality of RVB-EMA modules and an SPDconv convolutional layer, and the head network includes a plurality of HSFPN modules.
[0035] The lightweight image detection method and system proposed by the present invention are described in detail below.
[0036] After the image is input into the SPDconv convolutional layer, it is sequentially output after space-to-depth transformation, feature map splicing, and convolution processing. The SPDconv convolutional layer of the present invention is used to replace the Conv module in the YOLO framework backbone network. The Conv module contains a large number of multiplication operations, especially when using large convolution kernels and high channel numbers, they require significant computing resources and are not suitable for devices with limited resources. In addition, the receptive field of the Conv layer is fixed by the size of the convolution kernel, and is not suitable for all pattern scales in the input data, especially when there are features with large-scale size changes. The Conv layer will also face the problem of large number of parameters. If the technology such as deep separable convolution is not adopted, the standard convolutional layer will have many parameters, thereby increasing the storage demand and the risk of overfitting. Therefore, in order to achieve model lightweight, on this basis, the SPDConv convolutional layer of the present invention adaptively applies the most suitable convolution parameters to different areas in the image by introducing a dynamic adjustment mechanism. Compared with traditional convolutional layers, it not only focuses on feature extraction at the spatial level, but also introduces attention mechanisms in three dimensions: convolution kernel size, input channel, and output channel, making the convolution operation more sensitive to specific features, thereby improving the ability to capture image details and increasing the receptive field. Especially when the model processes background or small object detection in high-resolution images, the improved SPDConv helps to significantly improve model performance and reduce the amount of computation and model size.
[0037] See also Figure 3 to Figure 4 The SPDconv convolutional layer is described in detail below. The SPDconv convolutional layer splits the input image X(S,S,C1) in the dimension by the scale factor, concatenates it in the channel direction, and outputs it after convolution. When the input image X(S,S,C1) with spatial size s×s and number of channels c1 is processed by the SPDconv convolution layer, the detailed process is as follows:
[0038] First, a spatial-to-depth transformation is performed. Each 2×2 pixel block of the input image X is rearranged to the channel dimension, so the result is a combination of four pieces of data, each with the original number of channels c1, but the spatial size is reduced to These four parts are concatenated in the channel dimension to form a new feature map whose number of channels is increased to 4c1 and whose spatial size is reduced to half of the original one.
[0039] After that, feature map concatenation is performed. The four downsampled images are concatenated into a new feature map by channel. This step does not involve any weights or training parameters and is a pure data rearrangement technique.
[0040] Next, convolution is performed and the concatenated feature map is input into a standard convolution layer. In this embodiment, a 3×3 convolution kernel is used and the step size is kept as 1. The convolution layer uses the learned weights and biases to extract the spatial features of the feature map. Through this convolution operation, another transformed form of the feature map is obtained. Then, X′ is output, which has c2 channels and a spatial size of This feature map can be used for the next step of the network or as input to the detector.
[0041] Through the above process, for the SPDConv convolution layer given any (original) feature Figure X , subgraph f x,y It consists of all entries of X(i,j) where i+x and j+y are divisible by scale. Therefore, each subgraph downsamples X by the scale factor. Figure 4 An example with scale = 21 is given. According to the example, the module obtains four subgraphs f 0,0 ,f 1,0 ,f 0,1 ,f 1,1 , each subgraph is of shape And downsample X by a factor of 2.
[0042] The SPDConv convolutional layer connects these sub-feature maps along the channel dimension to obtain the feature Figure X ′, its spatial dimension is reduced by scale times, and the channel dimension is increased by scale 2 SPDConv transforms the features Figure X (S, S, C1) is converted to an intermediate feature map Figure 4 The module processing flow when scale=2 is described.
[0043] After the SPDConv feature conversion layer, the module adds a filter with C2 (where C2 <scale 2 C1) non-strided (i.e. stride = 1) convolutional layer, and further transform The reason for using non-strided convolution is to preserve all discriminative feature information. Prevent the following situation: for example, using a 3×3 filter with stride=3, the feature map will be reduced, but each pixel will be sampled only once; if stride=2, asymmetric sampling will occur, where even and odd rows / columns are sampled at different times. In general, a stride greater than 1 will result in a non-discriminatory loss of information, although on the surface it seems to also transform the feature map (But no features Figure X ′).
[0044] The RVB-EMA module includes an EMA module and an RVB module. The RVB module includes deep convolution, squeeze and excitation layer, dilated convolution and projection layer, and the residual connection jumps over the dilated convolution and projection layer. After the EMA module groups the input tensors, it performs height and width pooling through the spatial attention mechanism, and then performs feature enhancement through multiple convolutions, calculates adaptive weights and splices the output. Among them, the deep convolution is implemented by the RepVGGDW layer, and the RepVGGDW layer includes initialization, forward propagation, fused convolution and batch normalization operations, and the forward propagation includes deep separable convolution and point convolution.
[0045] For details, please refer to Figure 5 The RVB module proposed in this paper is improved on the basis of the MobileNetV3 block. The MobileNetV3 block is a module designed to improve the efficiency and performance of neural networks on mobile devices. Its design idea is derived from elements borrowed from the Vision Transformer (ViT) architecture through structural reparameterization technology and integrated into the traditional convolutional neural network (CNN). The specific structure of the MobileNetV3 block is as follows Figure 5 As shown in (a), the improved RVB module is as follows Figure 5 (b) Figure 5 (c) represents the operation flow chart of the RVB module. Among them, the MobileNetV3 block uses 1×1 dilated convolution and 1×1 projection layer to realize the interaction between channels (i.e., channel mixer), and is equipped with 3×3 depth (DW) convolution after the 1×1 dilated convolution for the fusion of spatial information (i.e., Token mixing). However, when the Token mixer and the channel mixer are coupled together, the flexibility of the network will be reduced, the complexity of model optimization and updating will be increased, more parameters and more complex calculation processes will be encountered, which is not conducive to the lightweight of the model. In order to separate them, the RVB module proposed in the present invention first moves the DW convolution upward, and the optional squeeze and excitation (SE) layer depends on the spatial information interaction, so it is moved up to after the DW. Therefore, the Token mixer and channel mixer in the MobileNetV3 module can be successfully separated. Further, the widely used structural reparameterization technology is adopted in the DW layer to enhance model learning during training. Thanks to the structural reparameterization technology, the computational and memory costs associated with skip connections during inference can be eliminated, which is particularly beneficial for mobile devices. After Figure 5 (a) to Figure 5 The improvement of (b) will enhance the flexibility and performance of the model, and its advantages in efficiency and scalability will also be greater.
[0046] The backbone network includes multiple C2f modules, and the RVB-EMA module is combined with the C2f module to form a C2f-RVB-EMA module; the RVB module is combined with the C2f module to form a C2f-RVB module. The C2f module of the backbone network in the original yolo model introduces multi-step operations (such as segmentation, transformation and fusion), which increases the complexity of the network. Although the C2f module increases the receptive field through cross-layer connections and helps feature fusion, its fusion method may not have the global perception ability like Transformer, and sometimes may limit the model's ability to capture long-range dependencies. Secondly, the C2f module may increase the forward and backward propagation time by repeatedly processing the feature map, especially when the module is reused. Therefore, the present invention combines the C2f module of the original model with the RVB module and adds the EMA mechanism. RVB combines the advantages of convolutional neural network and Transformer architecture, surpassing traditional CNN in feature representation and long-distance dependency capture, and the combination of deep separable convolution and residual connection is expected to improve the model's ability to learn complex spatial patterns. The RVB structure in the present invention plays the role of a bridge connecting the convolutional neural network and the Transformer in the model. By combining deep separable convolution with residual connection, RVB can improve the feature representation ability of the model while maintaining computational efficiency. This design enables it to deeply capture the spatial relationship in the image and strengthen the focus on the key areas of the image through the self-attention mechanism in the Transformer. This remote sensing image detection network replaces the C2f module in the Backbone backbone network in the YOLOv8 network with the C2f-RVB module. The replaced module has higher FLOPS than grouped convolution and DW convolution, and lower FLOPs than standard convolution. It only applies conventional Conv to some input channels for spatial feature extraction, while the remaining channels remain unchanged. Secondly, in order to improve the accuracy of the model, this model also adds the EMA attention mechanism to further enhance the feature extraction capability, and the improved module is called C2f-RVB-EMA. Each RVB module consists of 1 PConv and two subsequent 1×1 conv. These three form an inverted residual architecture, with more channels in the middle layer and self.identity placed to decide whether to use residual links. A new efficient multi-scale attention (EMA) module is added after 1×1conv, with the goal of retaining information on each channel and reducing computational overhead. Some channels are reshaped into batch dimensions, and the channel dimensions are grouped into multiple sub-features so that spatial semantic features are evenly distributed in each feature group. The EMA attention mechanism is a method of calculating attention weights through exponential moving averages. It can adaptively learn the importance of different feature maps and weight them during feature fusion.The EMA attention mechanism is introduced into the original backbone network to suppress redundant and interfering information, improve the accuracy of the model's detection and classification of remote sensing images, increase the model's attention to important features, and reduce the complexity of the model.
[0047] See also Figure 6 , combining the RVB module with the c2f module in the original network of yolov8 and adding the EMA attention mechanism forms the C2f-RVB-EMA module. The following is a detailed introduction to the module. The C2f-RVB-EMA module is an extended version of the C2f module that comes with yolov8, which includes the RVB-EMA module. The C2f-RVB-EMA module mainly consists of initialization and forward propagation. The following is a detailed workflow:
[0048] In the initialization part: The initialization part is divided into C2f initialization and RVB-EMA initialization. C2f-RVB-EMA inherits the C2f module and modifies it. C2f initialization specifically includes: c1 is the number of input channels, c2 is the number of output channels, n is the number of Bottleneck layers, and the initial value of n is 1. shortcut is a Boolean value that determines whether to use shortcut connections; g is the number of groups, and the initial value is 1; e is the expansion factor, which is used to calculate the number of intermediate channels, and the initial value is 0.5; self.c is the number of intermediate channels, which is calculated by c2*e; self.cv1 is a 1x1 convolutional layer used to convert the number of input channels to 2*self.c. self.cv2 is a 1x1 convolutional layer used to convert (2+n)*self.c to the number of output channels c2. self.m is a module list containing n Bottleneck layers. RVB-EMA initialization includes: inp is the number of input channels; oup is the number of output channels; use_se is a Boolean value that determines whether to use the Squeeze and Excite module; during initialization, the initialization method of the parent class RepViTBlock is called, and the Squeeze and Excite module is replaced by the EMA module.
[0049] The forward propagation process includes the following: 1. Input data (batch_size, c1, height, width): Process the shape of the first four-dimensional tensor, which is used to describe the shape of the input image or feature map in the deep learning model; 2. The first layer of convolution (cv1): Use 1x1 convolution to convert the input data from c1 channels to 2*self.c channels, and divide the convolution result into two equal parts in the channel dimension, and store them in the list y. 3. After RVB-EMA processing: The last tensor in the list y is processed by n RVB-EMA modules in turn, and each processed result is added to y; The processing of each RVB-EMA module includes: passing through the RepVGGDW layer; passing through the EMA module (if use_se is true); channel mixing processing through Conv2d_BN and GELU. The difference between the C2f-RVB-EMA module and the C2f-RVB module is that the C2f-RVB-EMA module replaces the SqueezeExcite (SE) layer with the EMA module based on RVB, while the C2f-RVB module does not need to be replaced and directly passes through the SE layer to proceed to the next step; 4. Concatenate the processing results: concatenate all tensors in the list y in the channel dimension and pass them to self.cv2; 5. The second convolution layer (cv2): use 1x1 convolution to convert the concatenated result from (2+n)*self.c channels to the output channel number c2; 6. Return the final result: the shape of the processed four-dimensional tensor: (batch_size, c2, height, width). Among them, the epVGGDW layer, EMA module, Conv2d_BN and GELU mentioned above perform channel mixing processing, and the following are their specific explanations.
[0050] The detailed operation process of the RepVGGDW layer is as follows. Through these steps, the forward propagation and fusion process of the RepVGGDW layer will be more efficient and maintain good accuracy. This design helps to improve computational efficiency in the inference phase while maintaining good performance in the training phase.
[0051] First, initialize. In the initialization method, RepVGGDW defines the following components: self.conv, a 3x3 depth convolution layer, defined using Conv2d_BN; the number of input and output channels is ed, and the number of groups is ed, which means that each input channel has its own independent convolution kernel; self.conv, a 1x1 convolution layer, the number of input and output channels is ed, and the number of groups is ed; self.bn: a batch normalization layer; self.dim, the number of channels is ed.
[0052] Secondly, forward propagation is performed. The specific steps of the forward propagation method forward are as follows: 1. 3x3 depth convolution (self.conv): The input data x is subjected to 3x3 depth convolution through self.conv. This convolution layer is defined using Conv2d_BN, which combines convolution operations and batch normalization operations. 2. 1x1 convolution (self.conv1): The input data x is subjected to 1x1 convolution through self.conv1. This convolution layer does not have a batch normalization operation, only convolution. 3. Element addition: Add the result of the 3x3 convolution and the result of the 1x1 convolution, and then add the original input x to achieve residual connection. 4. Batch normalization (self.bn): Pass the above addition result through the batch normalization layer to obtain the final output. 5. Return result: Return the result after batch normalization.
[0053] Then, fused convolution and batch normalization (fuse_self) are performed. The fuse_self method is used to fuse the convolution layer and batch normalization layer into one convolution layer to improve the computational efficiency of the inference stage. The specific steps are as follows: 1. Get the convolution layer and batch normalization layer: extract self.conv and self.conv1. 2. Extract the convolution kernel weights and bias: extract the convolution kernel weights and bias from conv and conv1. 3. Pad the 1x1 convolution kernel: pad conv1_w to make it have the same size as the 3x3 convolution kernel. 4. Generate identity convolution kernel: generate the identity convolution kernel, which represents the identity mapping. 5. Calculate the fused convolution kernel weights and bias: add conv_w, conv1_w and identity to get the final convolution kernel weight, and add conv_b and conv1_b to get the final bias. 6. Update the convolution kernel weights and bias: update the weights and bias of conv. 7. Fusion batch normalization layer parameters: Calculate the convolution kernel weights and biases after fusion batch normalization layer, and update them. 8. Return the fused convolution layer. The depth convolution formula and point convolution formula used are as follows:
[0054] The depth convolution formula is as follows:
[0055]
[0056] The point convolution formula is as follows:
[0057]
[0058] Where I is the input image, K and K′ are convolution kernels, and D k is the result of the depthwise convolution, P k is the result of point convolution, x, y are spatial coordinates, and c is the channel index.
[0059] EMA (Efficient Multihead Attention) is an efficient multi-head attention mechanism. In simple terms: The EMA module implements an efficient multi-head attention mechanism through the following steps: 1. Group the input tensors and perform height and width pooling on each group. 2. Calculate the weighted feature map through 1x1 convolution and sigmoid activation. 3. Further process the feature map through group normalization and 3x3 convolution. 4. Calculate the weight of the feature map and get the final weighted result through matrix multiplication. 5. Reshape the weighted feature map to the original shape and output it. This design can efficiently capture the spatial relationship of the feature map and enhance the representation ability of the model. The following is an explanation of the detailed operation flow of the EMA module, each step and the operations involved.
[0060] First, initialize. In the initialization method, EMA defines the following components: self.groups: the number of groups, the default is 8. self.softmax: a Softmax layer for subsequent weight calculations. self.agp: an adaptive average pooling layer that pools the input feature map to a size of 1x1. self.pool_h: an adaptive average pooling layer that pools the input feature map to a height of 1. self.pool_w: an adaptive average pooling layer that pools the input feature map to a width of 1. self.gn: a group normalization layer, the number of channels in each group is channels / / self.groups. self.conv1x1: a 1x1 convolution layer, the number of input and output channels are both channels / / self.groups. self.conv3x3: a 3x3 convolution layer, the number of input and output channels are both channels / / self.groups.
[0061] After that, forward propagation is performed. The specific steps of the forward propagation method forward are as follows: 1. Get the shape of the input tensor: The shape of the input tensor x is (batch_size, channels, height, width), and get its batch size b, number of channels c, height h and width w. 2. Reshape the tensor: Reshape the input tensor x into group_x with a shape of (b*self.groups, c / / self.groups, h, w). Here self.groups is the number of groups, and c / / self.groups is the number of channels in each group. 3. Perform pooling operation: Perform pooling operation on group_x, and perform adaptive average pooling in the height and width directions respectively. 4. Concatenate the pooling results and perform 1x1 convolution: Concatenate the results of height and width pooling in the height dimension and pass through a 1x1 convolution layer. 5. Split the convolution result: Split the convolution result hw into x_h and x_w in the height dimension. 6. Calculate the weighted feature map x1: weight group_x using the sigmoid activation values of x_h and x_w, and pass it through the group normalization layer. 7. Perform a 3x3 convolution: pass group_x through a 3x3 convolution layer to get x2. 8. Calculate weights x11 and x12: perform adaptive average pooling on x1 and activate it through softmax, calculate weight x11. 9. Reshape x2 and calculate weight x21: reshape x2 to shape (b*self.groups,c / / self.groups,h*w), perform adaptive average pooling on it, activate it through softmax, and calculate weight x21. 10. Reshape x1 and calculate weight x22: reshape x1 to shape (b*self.groups,c / / self.groups,h*w). 11. Calculate the final weights: calculate the final weights through matrix multiplication and reshape them to shape (b*self.groups,1,h,w). 12. Weighted feature map and reshape: Weight group_x using the weights after sigmoid activation and reshape it to the original shape (b,c,h,w).
[0062] In the forward propagation method of RepViTBlock, the input x is first processed by token_mixer, then mixed by channel_mixer, and finally output. The Conv2d_BN and GELU channel mixing layers are used in RepViTBlock to adjust the number of channels of the feature map and introduce nonlinearity, thereby enhancing the expressiveness of the model. The specific steps include 1x1 convolution, batch normalization, and GELU activation function. Through these steps, the number of channels and nonlinear characteristics of the input feature map are adjusted and enhanced. The following is a detailed explanation of the specific operating steps of the Conv2d_BN and GELU channel mixing layers.
[0063] First, in the RVB module, the channel_mixer module (channel mixing) is a nn.Sequential module wrapped by Residual. The channel_mixer module contains two Conv2d_BN layers and a GELU activation function for channel mixing processing. The detailed operation process is as follows: 1. Input tensor, assuming that the shape of the input tensor x is (batch_size, inp, height, width). 2. The first Conv2d_BN layer is used to perform 1x1 convolution and batch normalization. The specific steps are as follows: 1. Convolution operation: Use 1x1 convolution to change the number of input channels from inp to hidden_dim(2*inp). The shape of the output tensor is (batch_size, hidden_dim, height, width). 2. Batch normalization: Batch normalize the output after convolution. Batch normalization helps to speed up training and stabilize the model. The output shape after normalization remains unchanged, which is (batch_size, hidden_dim, height, width). 3. GELU activation function. The function of this layer is to perform a nonlinear transformation on the output of the previous layer. The specific activation operation is: Use the GELU activation function to perform a nonlinear transformation on the input. (GELU (Gaussian Error Linear Unit) is an activation function based on the Gaussian error linear unit. It can introduce nonlinearity, thereby improving the expressiveness of the model.) The output shape after activation remains unchanged, which is (batch_size, hidden_dim, height, width). 4. The second Conv2d_BN layer. The function of this layer is to perform 1x1 convolution and batch normalization again. The specific convolution operation is as follows: Use 1x1 convolution to change the number of channels from hidden_dim to oup. The shape of the output tensor is (batch_size, oup, height, width). Batch Normalization: Batch normalize the output after convolution. In this layer, the weight of the batch normalization layer is initialized to 0 (bn_weight_init=0), which means that at the beginning of training, the scaling parameter of the batch normalization layer is 0. The normalized output shape remains unchanged, which is (batch_size, oup, height, width). 5. Forward propagation process, the forward propagation process of the entire channel_mixer module (channel mixing) is as follows: 1. The shape of the input tensor x is (batch_size, inp, height, width). 2. Through the first Conv2d_BN layer, the number of channels is changed from inp to hidden_dim, and the output shape is (batch_size, hidden_dim, height, width).3. Through the GELU activation function, the output is nonlinearly transformed, and the shape remains (batch_size, hidden_dim, height, width). 4. Through the second Conv2d_BN layer, the number of channels is changed from hidden_dim to oup, and the output shape is (batch_size, oup, height, width).
[0064] In the Head network and Detect detection head, there are one Conv convolution layer module, one Detect detection head module, two ConvTranspose2d modules, two C2f-RVB modules, three nn.Conv2d modules, and five ChannelAttention_HSFPN modules. When fusion and upsampling are performed, the ChannelAttention_HSFPN module (HSFPN module) is applied to perform channel attention processing to highlight important channel features. After that, the convolution operation is performed through the standard nn.Conv2d to adjust the number of channels. nn.ConvTranspose2d is used for transposed convolution (i.e. upsampling) to restore the spatial resolution of the feature map. More feature processing: The ChannelAttention_HSFPN module is used again to perform attention processing on feature maps of other layers and continue upsampling. Multiply and Add operations are used at specific layers for feature fusion. Multiply is used for element-level multiplication, while Add is used for element-level addition. These operations help to merge features from different layers. The C2fRVB module is applied to the fused feature map to further extract and fuse features. Finally, the feature maps from different scales (P3, P4, P5) are combined to perform object detection through the Detect module. This module is responsible for generating the final detection output, including bounding boxes, classification probabilities, etc.
[0065] In the Head network and detection head module, the original model uses multiple upsampling and C2f modules to increase the computational burden. Each upsampling and splicing operation increases processing time and memory consumption, especially when processing high-resolution inputs. Multiple splicing of feature maps and the application of C2f modules require that the model must be precisely adjusted to avoid information loss and optimize performance. Improper hierarchical design or parameter setting may lead to inefficiency and insufficient performance. In addition, in feature splicing and complex convolution operations, the model may learn noise specific to the training data rather than generalized features, especially in the case of insufficient data or imbalanced categories, and will also design fusion efficiency issues. Although the Concat operation can combine features of different scales, simple splicing may not be able to optimize the use of these features. The lack of effective feature selection or weighting mechanism may cause the fused features to be insufficient to express key information. In the present invention, the original Head network structure is replaced with a multi-scale receptive network, and ChannelAttention_HSFPN constructs a multi-scale receptive field enhancement module by fusing hole convolutions with different expansion rates, which effectively expands the receptive field of the model. By combining ordinary convolution with dilated convolution with different expansion rates (1, 2, 3), each convolution branch can independently capture feature information of different scales. After integrating these branches together, ChannelAttention_HSFPN can integrate information from multiple dimensions, thereby achieving accurate positioning and recognition of objects of different sizes in detection tasks. This structure is particularly suitable for scenarios that require fine receptive field adjustment and can also significantly reduce.
[0066] See also Figure 7 As shown in the figure, the HSFPN module performs feature selection through the attention mechanism and dimensionality matching to obtain multiple high-level features and low-level features with different expansion rates. The high-level features and low-level features are unified in dimension and then fused after dilated convolution. Specifically, the attention mechanism is implemented by the CA module, which uses global average pooling and global maximum pooling to calculate the average and maximum values of each channel respectively; dimensionality matching is implemented by the DM module, which unifies the number of feature map channels of each scale to the same number. Dilated convolution is implemented by the SFF module, which strategically fuses low-level features by using high-level features as weights to filter the basic semantic information embedded in the low-level features. The SFF module uses the following formula:
[0067] f att =BL(T-Conv(f high ))
[0068] f out =f low *CA(f att )+f att
[0069] In the formula, f att represents the attention feature map; BL represents bilinear interpolation, which is used to adjust the spatial size of the feature map; T-Conv represents transposed convolution, which is used to extract the high-level feature f from the high Expand the size of the feature map; f low represents low-level features; f out represents the fused output feature map; CA represents channel attention, which is applied to the attention feature map to focus on relevant features.
[0070] Specifically, the principle of HSFPN is as follows Figure 8 As shown. HSFPN consists of two main components: a feature selection module and a feature fusion module. Initially, feature maps of different scales undergo a screening process in the feature selection module. Subsequently, the high-level and low-level information in these feature maps are synergistically integrated through the selective feature fusion (SFF) mechanism. This fusion produces features with rich semantic content, which helps to detect subtle features in remote sensing images, thereby enhancing the detection ability of the model. In the feature selection module: the channel attention mechanism (CA) module and the dimension matching (DM) module play an important role in this process. The CA module first processes the input feature map f in ∈R C×H×W , where C represents the number of channels, H represents the height of the feature map, and W represents the width of the feature map. The feature map passes through two pooling layers (global average pooling and global maximum pooling), and then the resulting features are combined. Subsequently, the Sigmoid activation function is used to determine the weight value of each channel, and finally the weight f of each channel is obtained. CA ∈R C×1×1 . The CA module uses global average pooling and global maximum pooling to calculate the average and maximum value of each channel, respectively. The main purpose of maximum pooling is to extract the most relevant data from each channel, while the purpose of average pooling is to uniformly obtain all data from the feature map and minimize excessive loss. Therefore, the combination of these pooling methods in the CA module helps to extract the most representative information from each channel while minimizing information loss. The filtered feature map is then generated by multiplying the weight information with the feature map of the corresponding scale. Before feature fusion, it is crucial to match the dimensions of feature maps of different scales because they have different numbers of channels. To achieve this, the DM module applies 1×1 convolution to reduce the number of channels of each scale feature map to 256.
[0071] In the feature fusion module: The multi-scale feature maps generated by the backbone network present high-level features with rich semantic information, but the target localization is relatively coarse. In contrast, low-level features provide precise target locations but contain limited semantic information. A common solution to this problem involves direct pixel summation of upsampled high-level features and low-level features, enriching each layer with semantic information. However, this technique does not perform feature selection, but simply adds the pixel values of multiple feature layers. To address this limitation, in this model, we developed the SFF module. This module strategically fuses features by using high-level features as weights to filter out essential semantic information embedded in low-level features. Figure 8 As shown, given the input high-level feature f high ∈R C×H×W And input low-level features The high-level features are initially expanded using a transposed convolution with a stride size of 2 and a kernel size of 3×3, resulting in a feature size of Then, to unify the dimensions of high-level features and low-level features, we use bilinear interpolation to upsample or downsample the high-level features to obtain Then, the CA module is used to convert high-level features into corresponding attention weights to filter low-level features and obtain features with consistent dimensions. Finally, the filtered low-level features are fused with high-level features to enhance the feature representation of the model and obtain
[0072] Based on the above process, the image processing process of the present invention is described in detail. In this embodiment, YOLOv8n is used as the YOLO framework as the basic framework for building the network model. YOLOv8 includes a feature extraction network and a feature fusion network; the original input image is obtained from the video. The YOLO framework itself includes a backbone network, a head network, and a detection head module. The present invention integrates the SPD-HSFPN-RVB algorithm on the YOLO framework to establish a network model.
[0073] The video stream signal is received through the camera, the video stream signal is intercepted into an image, the image is preprocessed, and the size of the input image is scaled to 640×640 pixels. The image uses an image in the remote sensing field. Specifically, a remote sensing dataset is obtained, the image is preprocessed, and the input image size is scaled to 640×640 pixels. The data storage folder is Datasets, which includes two subfolders, namely Images and Labels. Images stores training images, and Labels stores xml files corresponding to training images. The ratio of training set to test set is 8:2. The training set image path is saved in train.txt, and the test set image path is saved in test.txt, which stores the relative path of training images and labels.
[0074] Build an airport aircraft remote sensing image detection network based on YOLOv8 and SPD-HSFPN-RVB fusion, as shown in the following example. Figure 2 As shown in the figure, it includes Backbone network, Head network block and Detect target detection head module. The Backbone network module introduces lightweight network structure C2f-RVB-EMA and C2f-RVB modules and SPDconv convolution layer. The combination of these modules greatly reduces the computational complexity of the model, improves the information fusion capability, and enhances the feature extraction capability. The target detection head Detect module is used to detect the target object. The ChannelAttention-HSFPN module is added to the Head network to make the model more compact.
[0075] The Backbone network includes a Conv convolutional layer module, a SPFF fast spatial pyramid pooling module, two C2f-RVB modules, two C2f-RVB-EMA modules, and four SPDconv modules. The backbone network extracts the feature information of remote sensing images through various modules. After the image input enters the model, the image processing is initialized. The image is first processed through a standard convolutional layer (64 3x3 convolution kernels with a stride of 2) to generate a P1 / 2 feature map. Secondly, the layer-by-layer feature extraction operation is performed: the feature map is processed using SPDConv to increase the number of channels of the feature map and increase the perception mechanism. The C2f-RVB module is applied to the generated feature map, and this series of operations is repeated 3 times. C2f-RVB integrates channel attention and RepViTBlock (RVB) structure, which enhances the feature extraction and representation capabilities of the model. Repeat the above steps, gradually increase the number of channels of the feature map through SPDConv, and continue to extract features through C2f-RVB or C2f-RVB-EMA. C2f-RVB-EMA adds EMA on the basis of C2f-RVB to further smooth parameters and improve model stability. Finally, spatial pyramid pooling is performed through the SPPF module to enhance the capture of multi-scale features.
[0076] After the model is established, the training set image data in the remote sensing data set is input into the network model for training, and the images marked in the training set and the validation set are used for training. During the training process, the images divided in the test set are tested to obtain the effect of each stage of training; after the training, the model will generate a corresponding weight file, import the trained weights and the images to be tested and the corresponding labels, run the program to obtain the data and images after the test, and compare whether the recognition effect and detection accuracy meet the expected requirements. Save the model parameters with the highest accuracy on the validation set after the training process, and name the file best.pt.
[0077] Also, see Fig. 9 and Fig.10 , the present invention runs the network model on the test set and records and analyzes the performance indicators in detail. According to the test results, Fig. 9 The figure shows the curve of the changes of various indicators during 200 rounds of model training. After the model training is completed, the Precision of the verified aircraft graphics reaches 96% and the mAP reaches 92.4% after the validation set test. Compared with the original YOLOv8n, the algorithm in this paper improves the Precision by 2.0% and the mAP by 1.2%; the number of parameters is reduced by 35% and the amount of calculation (GFLOPs) is reduced by 20%. Among them, Precision represents the accuracy of the model. The larger the index, the better the model recognition effect; mAP represents the quality of the model in all categories. The larger the index, the better the model network performance. The algorithm index comparison table is shown in Table 1, which proves the feasibility of the algorithm of the present invention. It can be seen that the use of the lightweight SPD-HSFPN-RVB feature fusion network to strengthen the multi-scale feature fusion process can improve the feature expression ability and significantly reduce the model size and parameter amount.
[0078] Table 1 Comparison of experimental results of different models
[0079] Model Class Precision(P) Recall(R) mAP(%) GLOPs(M) YOLOv8n Plane 0.94 0.94 0.912 8.2 Ours Plane 0.96 0.95 0.924 6.6
Claims
1. A lightweight image detection method integrating SPD-HSFPN-RVB, characterized in that: The method comprises: Acquire and preprocess images; A network model is established based on the YOLO framework. After the preprocessed image is input into the network model, it is processed by the backbone network and the head network in sequence, and is output after being inspected by the detection head module. The backbone network includes multiple RVB-EMA modules and SPDconv convolutional layers, and the head network includes multiple HSFPN modules.
2. The lightweight image detection method integrating SPD-HSFPN-RVB according to claim 1, characterized in that: After the image is input into the SPDconv convolution layer, it is output after space-to-depth transformation, feature map splicing, and convolution processing.
3. The lightweight image detection method integrating SPD-HSFPN-RVB according to claim 2, characterized in that: The SPDconv convolutional layer transforms the input image X(S, S, C1) by the scale factor in the dimension, concatenates it in the channel direction, and outputs it after convolution.
4. The lightweight image detection method integrating SPD-HSFPN-RVB according to claim 1, characterized in that: The RVB-EMA module includes an EMA module and an RVB module. The RVB module includes deep convolution, a squeeze and excitation layer, an extended convolution and a projection layer, and the residual connection jumps over the extended convolution and projection layers. After the EMA module groups the input tensors, it performs height and width pooling through a spatial attention mechanism, and then performs feature enhancement through multiple convolutions, and splices the output after calculating the adaptive weights.
5. The lightweight image detection method integrating SPD-HSFPN-RVB according to claim 4, characterized in that: The deep convolution is implemented by the RepVGGDW layer, which includes initialization, forward propagation, fused convolution and batch normalization operations, and the forward propagation includes depthwise separable convolution and point convolution.
6. The lightweight image detection method integrating SPD-HSFPN-RVB according to claim 4, characterized in that: The backbone network includes multiple C2f modules, the RVB-EMA module is combined with the C2f module to form a C2f-RVB-EMA module; the RVB module is combined with the C2f module to form a C2f-RVB module.
7. The lightweight image detection method integrating SPD-HSFPN-RVB according to claim 1, characterized in that: The HSFPN module performs feature selection through attention mechanism and dimension matching to obtain multiple high-level features and low-level features with different expansion rates, unifies the dimensions of the high-level features and the low-level features, and then fuses them through dilated convolution.
8. The lightweight image detection method integrating SPD-HSFPN-RVB according to claim 7, characterized in that: In the HSFPN module, the attention mechanism is implemented by a CA module, which uses global average pooling and global maximum pooling to calculate the average value and maximum value of each channel respectively; the dimension matching is implemented by a DM module, which unifies the number of feature map channels of each scale to the same number.
9. The lightweight image detection method integrating SPD-HSFPN-RVB according to claim 7, characterized in that: The dilated convolution is implemented by the SFF module, which strategically fuses low-level features by using high-level features as weights to filter basic semantic information embedded in low-level features. The SFF module is performed using the following formula: f att =BL(T-Conv(f high )) f out =f low *CA(f att )+f att In the formula, f att represents the attention feature map; BL represents bilinear interpolation, which is used to adjust the spatial size of the feature map; T-Conv represents transposed convolution, which is used to extract the high-level feature f from the high Expand the size of the feature map; f low Represents low-level features; f out represents the fused output feature map; CA represents channel attention, which is applied to the attention feature map to focus on relevant features.
10. A lightweight image detection system integrating SPD-HSFPN-RVB, characterized in that: include: An image acquisition module, used to acquire and pre-process images; The image processing module is used to establish a network model based on the YOLO framework. After the preprocessed image is input into the network model, it is processed by the backbone network and the head network in sequence, and is output after being inspected by the detection head module. The backbone network includes multiple RVB-EMA modules and SPDconv convolutional layers, and the head network includes multiple HSFPN modules.
Citation Information
Patent Citations
Leukocyte detection method based on multi-scale fusion and deformable self-attention
CN116580394A
Remote sensing deep learning-based electric power tower identification method and storage medium
CN116912707A
Visual garbage identification method for unmanned garbage sweeper based on improved YOLOv8
CN117423040A
Cited By
Dispelling notification method, device and equipment for wind power plant and storage medium
CN119251726A
Light unmanned aerial vehicle aerial image small target detection method and system based on TFA-YOLO11
CN119810409A
Parasite egg detection method based on improved YOLOv8s
CN119942533A
Ecological environment protection supervision method, system, equipment and medium
CN120387580A
