A remote sensing image detection method, device and storage medium based on yolov5
By introducing the CBAM attention mechanism and feature fusion module into the yolov5 model, the problem of insufficient accuracy caused by feature loss in remote sensing image detection is solved, the detection performance of small targets and occluded objects is improved, and the feature information is balanced to improve Detection accuracy and speed.
Patent Information
- Application Number
- CN202210541629.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-17
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-05-17
AI Technical Summary
The existing yolov5 network model has insufficient target detection accuracy due to feature loss in the feature extraction process in remote sensing image detection, especially when dealing with occluded objects or small objects.
By introducing the CBAM attention mechanism and feature fusion module into the yolov5 model, the feature extraction and fusion capabilities are enhanced, including adding spatial and channel attention sub-modules after BottleNeckCSP, and replacing PANet with the feature fusion module to achieve better feature fusion. .
It improves the target detection accuracy, especially the detection performance when dealing with small targets and occluded objects, balances the feature information of different scales, and improves the detection speed.
Smart Images

Figure CN114998756B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to a remote sensing image detection method, device and storage medium based on yolov5. Background Art
[0002] Remote sensing image target detection and recognition has always been a hot topic in the field of remote sensing image processing. In recent years, with the rapid development of earth observation technology, remote sensing has entered an unprecedented new stage. The available satellite remote sensing image data has grown exponentially. How to quickly and accurately automatically extract and identify targets from massive remote sensing data has become a difficult problem that urgently needs to be solved. With the improvement of computer computing power, target detection methods based on deep learning have achieved great success in remote sensing image detection.
[0003] Object detection plays a core role in computer vision. With the development of convolutional neural networks, object detection algorithms have made great progress. RCNN proposed by Ross Girshick pioneered the two-stage algorithm, and based on this algorithm, he continuously improved it and proposed fast-RCNN and faster-RCNN. At the same time, the one-stage series of algorithms have also made rapid progress in recent years, with representative algorithms such as the yolo series and retinanet.
[0004] At present, target detection can adopt a variety of neural network detection methods, such as the currently popular yolo series network models, but the detection and positioning accuracy of the yolo network model for most occluded objects or objects that are relatively small in size is still poor. Especially in the field of remote sensing detection technology, remote sensing images usually have too much background information and a large number of small targets that are very close to each other. The existing yolo network model will cause feature loss during the feature extraction process, resulting in insufficient target detection accuracy. The existing methods to improve the detection accuracy of the model will cause the model itself to be too large, which will have a relatively large impact on the detection speed.
[0005] Therefore, how to improve target detection accuracy is a technical problem that needs to be solved urgently in the field of remote sensing image target detection. Summary of the invention
[0006] Aiming at the technical problem that the existing lightweight yolov5 network model has feature loss in the process of feature extraction, resulting in insufficient target detection accuracy, the present invention provides a remote sensing image detection method, device and storage medium based on yolov5. The present invention realizes efficient feature fusion by adding a feature fusion module and introducing a CBAM attention mechanism, thereby obtaining a better detection effect.
[0007] The technical means adopted by the present invention are as follows:
[0008] A remote sensing image detection method based on yolov5 includes the following steps:
[0009] S1. Obtain remote sensing images of uniform size to form a remote sensing image data set, obtain a detection target annotation result image of each remote sensing image, and thereby obtain a remote sensing image sample set, wherein the samples in the remote sensing image sample set include remote sensing images and detection target annotation result images matching the remote sensing images; and randomly divide the samples in the remote sensing image sample set into a training set and a test set according to a preset ratio;
[0010] S2. Performing model training on the improved yolov5 model based on the sample data in the training set and the test set, wherein the improved yolov5 model includes a feature extraction module, a CBAM module, a feature fusion module and a classification output module;
[0011] S3. Perform target detection on remote sensing images based on the trained improved yolov5 model.
[0012] Furthermore, the detection method further comprises:
[0013] S4. Classify the target detection results and output the classification results and the target detection results simultaneously.
[0014] Furthermore, the remote sensing images of uniform size obtained in S1 constitute a remote sensing image dataset, including:
[0015] The acquired remote sensing image is subjected to enhancement operations based on size transformation, flipping, and random cropping sampling, and the obtained enhanced image is added to the remote sensing image data set.
[0016] Furthermore, the improved yolov5 model is set as:
[0017] An attention module is added after BottleNeckCSP of the yolov5 model backbone network. The attention module includes a spatial attention submodule and a channel attention submodule. The spatial attention submodule is used to implement attention guidance in the spatial dimension, and the channel attention submodule is used to implement attention guidance in the channel dimension.
[0018] Furthermore, the improved yolov5 model is set as:
[0019] The PANet module in the yolov5 model is replaced with a feature fusion module, which is used to perform feature fusion by first performing downward convolution and pooling operations, and then further realize feature fusion by performing convolution kernel upsampling operations from bottom to top on the obtained features.
[0020] The present invention also discloses a remote sensing image detection device based on yolov5, comprising:
[0021] A data extraction unit, which obtains remote sensing images of uniform size to form a remote sensing image data set, obtains a detection target annotation result image of each remote sensing image, and thereby obtains a remote sensing image sample set, wherein the samples in the remote sensing image sample set include remote sensing images and detection target annotation result images matching the remote sensing images; and randomly divides the samples in the remote sensing image sample set into a training set and a test set according to a preset ratio;
[0022] A model training unit, which is used to perform model training on an improved yolov5 model based on sample data in a training set and a test set, wherein the improved yolov5 model includes a feature extraction module, a CBAM module, a feature fusion module, and a classification output module;
[0023] The detection module is used to perform target detection on remote sensing images based on the trained improved yolov5 model.
[0024] The present invention also discloses a storage medium, which includes a stored program, wherein when the program is run, the above method is executed.
[0025] Compared with the prior art, the present invention has the following advantages:
[0026] 1. The present invention introduces the CBAM attention mechanism based on the yolov5 model to better extract features in the two dimensions of channel and space and improve detection accuracy.
[0027] 2. The present invention replaces the original PANet of the yolov5 model with a dedicated feature fusion module to better perform feature fusion and balance feature information of different scales. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0029] Figure 1 This is a flow chart of the remote sensing image detection method based on yolov5 in the present invention.
[0030] Figure 2 This is the framework diagram of the existing yolov5 model.
[0031] Figure 3 This is the framework diagram of the improved yolov5 model in the present invention.
[0032] Figure 4 The results of target detection based on the detection method of the present invention in the embodiment are shown in FIG. Figure 1 .
[0033] Figure 5 The results of target detection based on the detection method of the present invention in the embodiment are shown in FIG. Figure 2 . DETAILED DESCRIPTION
[0034] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0035] like Figure 1 As shown, the present invention provides a remote sensing image detection method based on yolov5, comprising the following steps:
[0036] S1. Obtain remote sensing images of uniform size to form a remote sensing image data set, obtain the detection target annotation result image of each remote sensing image, and thus obtain a remote sensing image sample set, wherein the samples in the remote sensing image sample set include remote sensing images and detection target annotation result images matching the remote sensing images; and randomly divide the samples in the remote sensing image sample set into a training set and a test set according to a preset ratio.
[0037] Specifically, the present invention first obtains a data set of remote sensing images, then uses a target detection and annotation tool to annotate them, converts the images into a uniform size, and then obtains remote sensing image information.
[0038] Then, the collected image data is divided into independent training sets and test sets according to a certain ratio by random sampling. Preferably, in the embodiment of the present invention, the training set accounts for 80% of the sample quantity, and the test set accounts for 20% of the sample quantity.
[0039] In addition, S1 also includes performing enhancement operations based on size transformation, flipping, and random cropping sampling on the acquired remote sensing image, and adding the obtained enhanced image to the remote sensing image data set.
[0040] S2. Perform model training on the improved yolov5 model based on the sample data in the training set and the test set. The improved yolov5 model includes a feature extraction module, a CBAM module, a feature fusion module and a classification output module.
[0041] In the present invention, an improved yolov5 model is used as a deep learning detector. The construction process mainly includes installing the yolov5 model, using a data enhancement strategy, constructing a data input part, performing size transformation, flipping, random cropping and sampling operations on the original remote sensing image, and obtaining the input data of the detector.
[0042] Specifically, it includes:
[0043] a. Add an attention module after BottleNeckCSP of the yolov5 model backbone network. The attention module includes a spatial attention submodule and a channel attention submodule. The spatial attention submodule is used to implement attention guidance in the spatial dimension, and the channel attention submodule is used to implement attention guidance in the channel dimension. Specifically, after the backbone network, the CBAM (Convolutional Block Attention Module) attention mechanism is introduced. CBAM can be divided into two modules, channel attention and spatial attention, which perform attention in the channel and spatial dimensions respectively. The features cover more parts of the object to be identified, and the probability of finally identifying the object is also higher.
[0044] b. Replace the PANet module in the yolov5 model with a feature fusion module, which is used to perform feature fusion by first performing downward convolution and pooling operations, and then performing a convolution kernel upsampling operation on the obtained features from bottom to top to further achieve feature fusion. Specifically, in order to achieve a more efficient multi-scale fusion method, the present invention designs a new feature fusion module to replace the PANet in the yolov5 model, which performs feature fusion by first performing downward convolution and pooling operations, and then performing a convolution kernel upsampling operation on the obtained features from bottom to top to further achieve feature fusion, thereby better balancing feature information of different scales.
[0045] S3. Perform target detection on remote sensing images based on the trained improved yolov5 model.
[0046] Furthermore, the detection method further comprises:
[0047] S4. Classify the target detection results and output the classification results and the target detection results simultaneously.
[0048] The scheme and effect of the present invention are further illustrated below through a specific application example.
[0049] The remote sensing image target detection method provided in this embodiment has a flow chart as follows: Figure 1 As shown, specifically including:
[0050] 1. Obtain a remote sensing image to be detected containing the target to be detected. The present invention adopts a random sampling method to divide the collected remote sensing image data into independent training sets and test sets according to a certain ratio, wherein the training set accounts for 80% and the test set accounts for 20%.
[0051] 2. Input the image into the trained detection network for feature extraction to obtain feature maps of different scales. Specifically, the remote sensing image to be detected is input into the backbone network for feature extraction to obtain feature maps of multiple feature layers of different scales from shallow to deep; these feature maps of feature layers of different scales form a bottom-up pyramid structure. The remote sensing image target detection network includes a backbone network, a feature fusion network, and a classification network connected in series.
[0052] 3. Perform feature fusion on the feature map and output the prediction results of remote sensing images at different scales. Figure 3 , Figure 3 This is the architecture diagram of the target detection network used in the present invention. It is based on the yolov5 network, introduces the CBAM attention mechanism, replaces the original PANet of yolov5 with a new feature fusion network designed by the present invention, and adds a group of smaller anchor boxes to form a network model. The original yolov5 model architecture is as follows Figure 2 shown.
[0053] First, the CBAM attention mechanism module is introduced. It is an attention mechanism module that combines space and channels. The channel attention mechanism compresses the feature map in the spatial dimension and obtains a one-dimensional vector before operating. When compressing in the spatial dimension, not only average pooling but also maximum pooling is considered. Average pooling and maximum pooling can be used to aggregate the spatial information of the feature map, send it to a shared network, compress the spatial dimension of the input feature map, and sum and merge element by element to generate a channel attention map. The spatial attention mechanism compresses the channel, and performs average pooling and maximum pooling in the channel dimension respectively. The operation of MaxPool is to extract the maximum value in the channel, and the number of extractions is height multiplied by width; the operation of AvgPool is to extract the average value in the channel, and the number of extractions is also height multiplied by width; then the previously extracted feature maps (the number of channels is 1) are merged to obtain a 2-channel feature map. The CBAM module will infer the attention map along these two independent dimensions in turn, and then multiply the attention map with the input feature map for adaptive feature optimization.
[0054] The present invention introduces a CBAM attention mechanism module between the backbone network and the feature fusion module in the yolov5 model, optimizes the features output after the two BottleNeckCSP layers of the backbone network of yolov5 through CBAM, and inputs the output result of the CBAM module into the feature fusion module.
[0055] The detailed architecture of the feature fusion module proposed in this invention is as follows: Figure 3 As shown in the figure, it is a bidirectional feature pyramid network that allows simple and fast multi-scale feature fusion, achieving a more efficient multi-scale fusion method. The idea is actually based on the idea of path-enhanced FPN (PANet). After the top-down feature fusion, it is immediately fused again from the bottom to the top, so as to achieve a better feature fusion effect. The feature map of each prediction layer has different scales, and the feature map of each prediction layer is the prediction result of the remote sensing image at each scale. Therefore, this experiment replaces the original PANet of the yolov5 model with this module. The features are convolved and pooled from top to bottom, and the multi-scale features are connected to achieve feature fusion. Then the features are convolved and upsampled again from the bottom to the top, and the multi-scale features are connected to further achieve feature fusion.
[0056] First, perform 3x3 convolution on the features output by the CBAM mechanism of the first layer, then perform pooling operation, and connect them with the features output by the CBAM mechanism of the second layer, and perform 3x3 convolution and pooling operation again, and connect the result with the features output by the third layer. Then perform 3x3 convolution and upsampling on the connected result, connect it with the convolution result of the second layer, perform convolution and upsampling operation again, and finally connect it with the convolution result of the first layer.
[0057] 4. Classify the prediction results of the remote sensing images of each scale, and output the category to which the target to be detected belongs and the position of the target to be detected in the remote sensing image to be detected.
[0058] The preliminary classification result is input into the non-maximum suppression module for deduplication operation, and the category of the target to be detected and the position of the target to be detected in the remote sensing image to be detected are output. The non-maximum suppression module is used to perform non-maximum suppression processing. It is used to exclude detection frames with relatively small confidence in multiple detection frames that repeatedly select the same target.
[0059] The dataset is augmented using mosaic data augmentation. The Adam optimization method is selected, the initial learning rate is set to 0.001, and 400 epochs are trained. The learning rate gradually decays during the training process. The confidence score threshold is 0.3, and the threshold of non-maximum suppression is set to 0.4.
[0060] As attached Figure 4 ,5It can be seen that the improved yolov5 model of the present invention has achieved better detection effect, especially for small targets, it can also show excellent detection performance.
[0061] In this embodiment, the experimental effects of introducing the CBAM attention mechanism, introducing a new feature fusion module and adding a set of smaller anchor boxes to the yolov5 model are compared with those of the original yolov5 model. The results are shown in Table 1.
[0062] Table 1: Detection performance comparison between the remote sensing image target detection network of the present invention and the yolov5 network
[0063] method mAP AP50 YOLOv5 0.408 0.627 YOLOv5+CBAM 0.425 0.658 YOLOv5+CBAM+feature fusion 0.436 0.680
[0064] It can be seen from the above table that after the modification of the yolov5 model, the mAP is 0.408 on the original basis, and the improved mAP is 0.436, which is an increase of 0.028; on the original basis, the AP50 is 0.627, and the improved AP50 is 0.680, which is an increase of 0.053. The experimental data proves the effectiveness of the improvement.
[0065] The remote sensing image target detection method of the embodiment of the present invention is based on the yolov5 network model, and introduces the CBAM attention mechanism behind the backbone network, so that the features cover more parts of the object to be identified, and the probability of finally distinguishing the object is also higher. In addition, the present invention designs a new feature fusion module to replace the PANet in the yolov5 model. The module performs feature fusion by first performing downward convolution and pooling operations, and then performs convolution and upsampling operations on the obtained features from bottom to top to further realize feature fusion, thereby better balancing feature information of different scales.
[0066] The present invention also discloses a remote sensing image detection device based on yolov5, comprising:
[0067] A data extraction unit, which obtains remote sensing images of uniform size to form a remote sensing image data set, obtains a detection target annotation result image of each remote sensing image, and thereby obtains a remote sensing image sample set, wherein the samples in the remote sensing image sample set include remote sensing images and detection target annotation result images matching the remote sensing images; and randomly divides the samples in the remote sensing image sample set into a training set and a test set according to a preset ratio;
[0068] A model training unit, which is used to perform model training on an improved yolov5 model based on sample data in a training set and a test set, wherein the improved yolov5 model includes a feature extraction module, a CBAM module, a feature fusion module, and a classification output module;
[0069] The detection module is used to perform target detection on remote sensing images based on the trained improved yolov5 model.
[0070] As for the embodiments of the present invention, since they correspond to the embodiments above, the description is relatively simple. For the relevant similarities, please refer to the description of the above embodiments, which will not be described in detail here.
[0071] The present invention also discloses a storage medium, which includes a stored program, wherein when the program is run, the above method is executed.
[0072] As for the embodiments of the present invention, since they correspond to the embodiments above, the description is relatively simple. For the relevant similarities, please refer to the description of the above embodiments, which will not be described in detail here.
[0073] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A remote sensing image detection method based on yolov5, It is characterized in that The following steps are involved: S1. Obtain remote sensing images of uniform size to form a remote sensing image data set, obtain a detection target annotation result image of each remote sensing image, and thus obtain a remote sensing image sample set, wherein the samples in the remote sensing image sample set include remote sensing images and detection target annotation result images matching the remote sensing images; The samples in the remote sensing image sample set are randomly divided into a training set and a test set according to a preset ratio; S2. Perform model training on the improved yolov5 model based on the sample data in the training set and the test set. The improved yolov5 model includes a feature extraction module, a CBAM module, a feature fusion module and a classification output module. The improved yolov5 model is set as follows: An attention module is added after BottleNeckCSP of the yolov5 model backbone network. The attention module includes a spatial attention submodule and a channel attention submodule. The spatial attention submodule is used to implement attention guidance in the spatial dimension, and the channel attention submodule is used to implement attention guidance in the channel dimension. The PANet module in the yolov5 model is replaced with a feature fusion module, which is used to perform feature fusion by first performing downward convolution and pooling operations, and then further perform convolution kernel upsampling operations on the obtained features from bottom to top to achieve feature fusion; S3. Perform target detection on remote sensing images based on the trained improved yolov5 model.
2. A remote sensing image detection method based on yolov5 according to claim 1, It is characterized in that The detection method further comprises: S4. Classify the target detection results and output the classification results and the target detection results simultaneously.
3. A remote sensing image detection method based on yolov5 according to claim 1, It is characterized in that The remote sensing images of uniform size obtained in S1 constitute the remote sensing image dataset, including: The acquired remote sensing image is subjected to enhancement operations based on size transformation, flipping, and random cropping sampling, and the obtained enhanced image is added to the remote sensing image data set.
4. A remote sensing image detection device based on yolov5, It is characterized in that include: A data extraction unit, which obtains remote sensing images of uniform size to form a remote sensing image data set, obtains a detection target annotation result image of each remote sensing image, and thereby obtains a remote sensing image sample set, wherein the samples in the remote sensing image sample set include remote sensing images and detection target annotation result images matching the remote sensing images; The samples in the remote sensing image sample set are randomly divided into a training set and a test set according to a preset ratio; The model training unit is used to perform model training on the improved yolov5 model based on the sample data in the training set and the test set. The improved yolov5 model includes a feature extraction module, a CBAM module, a feature fusion module and a classification output module. The improved yolov5 model is set as follows: An attention module is added after BottleNeckCSP of the yolov5 model backbone network. The attention module includes a spatial attention submodule and a channel attention submodule. The spatial attention submodule is used to implement attention guidance in the spatial dimension, and the channel attention submodule is used to implement attention guidance in the channel dimension. The PANet module in the yolov5 model is replaced with a feature fusion module, which is used to perform feature fusion by first performing downward convolution and pooling operations, and then further perform convolution kernel upsampling operations on the obtained features from bottom to top to achieve feature fusion; The detection module is used to perform target detection on remote sensing images based on the trained improved yolov5 model.
5. A storage medium, It is characterized in that The storage medium includes a stored program, wherein when the program is run, the method according to any one of claims 1 to 3 is executed.
Citation Information
Cited By
Improved remote sensing image target detection method
CN119992347A
