A Real-Time Detection Method for Crested Ibis in the Wild Based on YOLOv5-CBAM

By optimizing the YOLOv5-CBAM network model, the problem of low detection accuracy of crested ibises was solved, and efficient real-time detection was achieved in complex environments.

CN116416490BActive Publication Date: 2025-10-28SHAANXI SCI TECH UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202310163118.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-24
Publication Date
2025-10-28
Estimated Expiration
2043-02-24

AI Technical Summary

Technical Problem

Existing methods for detecting crested ibises have low accuracy and efficiency in complex environments, and cannot meet the needs of real-time monitoring.

Method used

A detection method based on YOLOv5-CBAM is adopted, and the network model is optimized through data augmentation, clustering and attention modules to improve detection accuracy and speed.

Benefits of technology

It significantly improved the average accuracy of crested ibis detection in complex environments, maintained the advantage of detection speed, and improved the accuracy and effectiveness of detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116416490B_ABST
    Figure CN116416490B_ABST
Patent Text Reader

Abstract

This invention discloses a real-time detection method for crested ibises in the wild based on YOLOv5-CBAM, belonging to the field of crested ibis detection technology. This invention constructs a YOLOv5-CBAM network model for real-time detection of crested ibises in the wild. The YOLOv5-CBAM network model incorporates a Stem module and a CBAM attention module, resulting in a stable YOLOv5-CBAM network model after training. The detection method of this invention not only retains the advantage of the YOLO algorithm's fast detection speed but also significantly improves both detection accuracy and performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a real-time detection method for crested ibises in the wild based on YOLOv5-CBAM. Background Technology

[0002] The crested ibis is one of the world's most endangered bird species. Understanding its distribution is crucial for its conservation. Currently, locating wild crested ibises relies on scientific investigations by professionals to pinpoint potential habitats. However, due to the crested ibis's large range and complex environment, existing methods are time-consuming, labor-intensive, and inefficient. With the rapid advancements in computer vision, using fixed cameras or drones and computer vision technology can replace manual labor for long-term monitoring of crested ibis habitats, automatically obtaining detailed information on their presence in specific areas. Therefore, using computer vision-based methods to replace manual patrols is of significant importance.

[0003] In recent years, many remarkable deep learning-based object detection algorithms have emerged in computer vision. These algorithms effectively improve upon the problems of low detection accuracy, poor anti-interference ability, and inability to adapt to complex environments inherent in traditional machine learning algorithms. They can be broadly categorized into two types: one is "two-stage detection" algorithms, which require two steps: first, obtaining candidate regions, and then classifying objects within those regions. Notable algorithms include R-CNN, Fast-R-CNN, and Faster-R-CNN. The other type is one-stage detection algorithms, which directly predict the object's category and location information through an object detection network. Regression-based object detection algorithms include the YOLO series (YouOnlyLookOnce) and SSD (Singleshot Multibox Detector). These algorithms offer faster detection speeds and better real-time performance, but their accuracy is slightly lower than two-stage detection algorithms. However, all the aforementioned classic networks suffer from insufficient detection accuracy. Summary of the Invention

[0004] To address the shortcomings of existing technologies, this invention provides a real-time detection method for crested ibises in the wild based on YOLOv5-CBAM. This method can effectively improve the mean accuracy (mAP) of crested ibis detection in complex environments. Compared with the existing YOLO algorithm, this invention not only retains the advantage of fast detection speed of the YOLO algorithm, but also significantly improves the accuracy and detection effect.

[0005] This invention is achieved using the following technical solution:

[0006] A real-time detection method for crested ibises in the wild based on YOLOv5-CBAM is characterized by the following steps:

[0007] (1) Collect image data of crested ibises in the wild, and perform image annotation and data augmentation to obtain a crested ibis image database;

[0008] (2) Divide the images in the crested ibis image database into a training set and a test set in an 8:2 ratio;

[0009] (3) Construct a YOLOv5-CBAM network model using the CBAM attention module and the Stem module;

[0010] (4) Use the K-means clustering algorithm to cluster the crested ibis anchor frame size in the wild crested ibis dataset;

[0011] (5) Reduce the image size in the training set to a multiple of 32 in the range of 320-640K, while keeping the input image size consistent in length and width;

[0012] (6) Perform Mosaic data augmentation on the training set images processed in step (5);

[0013] (7) Use the training set images processed in step (6) to train the YOLOv5-CBAM network model described in step (3) to obtain the trained YOLOv5-CBAM network model.

[0014] (8) Input the real-time images of wild crested ibises to be detected into the trained YOLOv5-CBAM network model for detection.

[0015] Firstly, step (1) involves collecting image data of crested ibises from the Hanzhong Crested Ibis National Nature Reserve, labeling the crested ibises in the images using LabelImg, and performing data enhancement processes such as rotation, tangent, random cropping, and color space transformation on the images to obtain a crested ibis image database.

[0016] Preferably, step (3) involves removing the first layer of YOLOv5m, namely the Focus layer, and adding the Stem module; adding the CBAM attention module to the backbone network of YOLOv5m, and adding the CBAM attention module to the feature fusion module of YOLOv5m, thereby obtaining a lightweight object detection network model.

[0017] Preferably, the CBAM attention module in step (3) includes a channel attention module (CAM) and a spatial attention module (SAM);

[0018] The channel attention module first processes the input feature map through global max pooling and global average pooling to obtain two 1*1*C feature maps. Then, it feeds them into a shared fully connected layer containing two neural networks. The shared fully connected layer uses the ReLU activation function. Then, the two feature vectors output by the shared fully connected layer are element-wise summed and activated by Sigmoid. The generated feature vector is the attention weight of the channel dimension of the original input feature map.

[0019] The spatial attention module takes the output feature map of the channel attention module as the input feature map. First, it performs global max pooling and global average pooling on the input feature map to obtain two H*W*1 feature maps. These feature maps are then concatenated along the channel dimension and convolution is used for feature extraction. The convolution operation uses a 7*7 kernel with a stride of 1 and a sigmoid activation function to reduce the dimensionality to 1. The spatial attention weights are then generated by the sigmoid function and element-wise multiplied with the input feature map of the module to regenerate the feature map.

[0020] Preferably, step (3) uses the Stem module to replace the focus layer in YOLOv5s. The Stem module extracts features through two branch networks. The specific steps are as follows:

[0021] The input image first passes through a regular convolution with a kernel size of 3*3 and a stride of 2, using the ReLU6 activation function. Then, it passes through two branches: one branch uses a 2*2 pooling kernel, and the other branch uses a regular convolution with a kernel size of 1*1 and a stride of 1, using the Silu activation function, and then another regular convolution with a kernel size of 3*3 and a stride of 1, also using the Silu activation function. The two branches are then concatenated in the channel direction, and finally passed through a regular convolution with a kernel size of 3*3 and a stride of 1, using the ReLU6 activation function.

[0022] Preferably, the Mosaic data augmentation in step (6) involves setting bounding boxes for all four photos in the image, then stitching them together to obtain a new image. The new image is then fed into a neural network for learning. Data augmentation operations are performed on each of the four photos in the stitched new image, including left and right flipping, proportional scaling, color gamut changes, and proportional scaling of the bounding boxes in the image according to the image size.

[0023] Preferably, when training in step (7), it is necessary to set the initial parameters for network training. The initial parameters include the image input size, momentum parameter, weight decay regularization term parameter, image angle change parameter, saturation and exposure change parameter, hue change parameter, initial learning rate, and number of training iterations. Adjust the momentum parameter, weight decay regularization term parameter, initial learning rate, and number of training iterations. After training, the training results are stabilized, and mAP is used to evaluate the network performance to obtain the trained YOLOv5-CBAM network model.

[0024] Preferably, in step (8), the image to be detected is input into the network model, and detection boxes of three scales are output. Then, the detection boxes are processed as follows:

[0025] Detection boxes with confidence scores below the threshold are filtered out, and then non-maximum suppression algorithm is used to filter the remaining detection boxes to obtain the best crested ibis detection box.

[0026] The nonmaximum prediction algorithm is as follows: First, find the detection box with the highest confidence among all detection boxes. Then, calculate the I0U between each detection box and the remaining detection boxes. The I0U is the intersection of two detection boxes divided by the union of two detection boxes. If the value is greater than a set threshold, the detection box is removed. The remaining detection boxes are the best ones.

[0027] Compared with the prior art, the present invention has the following beneficial effects:

[0028] This invention provides a real-time detection method for crested ibises in the wild based on YOLOv5-CBAM, which can effectively improve the mean accuracy (mAP) of crested ibis detection in complex environments. Compared with the existing YOLO algorithm, this invention not only retains the advantage of fast detection speed of the YOLO algorithm, but also significantly improves the accuracy and detection effect. Attached Figure Description

[0029] Figure 1 This is a schematic diagram of the Stem module structure of the present invention;

[0030] Figure 2 This is a schematic diagram of the CBAM attention module structure of the present invention. Detailed Implementation

[0031] To make the objectives, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention are described in detail below. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided so that the disclosure of the present invention will be thorough and complete.

[0032] Example 1

[0033] The real-time detection method for crested ibises in the wild based on YOLOv5-CBAM consists of the following steps:

[0034] (1) Collect image data of crested ibises in the wild, and perform image annotation and data augmentation to obtain a crested ibis image database;

[0035] (2) Divide the images in the crested ibis image database into a training set and a test set in an 8:2 ratio;

[0036] (3) Construct a YOLOv5-CBAM network model using the CBAM attention module and the Stem module;

[0037] (4) Use the K-means clustering algorithm to cluster the crested ibis anchor frame size in the wild crested ibis dataset;

[0038] (5) Reduce the image size in the training set to a multiple of 32 in the range of 320-640K, while keeping the input image size consistent in length and width;

[0039] (6) Perform Mosaic data augmentation on the training set images processed in step (5);

[0040] (7) Use the training set images processed in step (6) to train the YOLOv5-CBAM network model described in step (3) to obtain the trained YOLOv5-CBAM network model.

[0041] (8) Input the real-time images of wild crested ibises to be detected into the trained YOLOv5-CBAM network model for detection.

[0042] In this invention, step (1) involves collecting image data of crested ibises from the Hanzhong Crested Ibis National Nature Reserve, labeling the crested ibises in the images using LabelImg, and performing data enhancement processing such as rotation, tangent, random cropping, and color space transformation on the images to obtain a crested ibis image database.

[0043] Step (3) of this invention involves removing the first layer, the Focus layer, of YOLOv5m and adding the Stem module; adding the CBAM attention module to the backbone network of YOLOv5m and the feature fusion module of YOLOv5m, thereby obtaining a lightweight object detection network model.

[0044] The CBAM attention module mentioned in step (3) includes a channel attention module (CAM) and a spatial attention module (SAM);

[0045] The channel attention module first processes the input feature map through global max pooling and global average pooling to obtain two 1*1*C feature maps. Then, it feeds them into a shared fully connected layer containing two neural networks. The shared fully connected layer uses the ReLU activation function. Then, the two feature vectors output by the shared fully connected layer are element-wise summed and activated by Sigmoid. The generated feature vector is the attention weight of the channel dimension of the original input feature map.

[0046] The spatial attention module takes the output feature map of the channel attention module as the input feature map. First, it performs global max pooling and global average pooling on the input feature map to obtain two H*W*1 feature maps. These feature maps are then concatenated along the channel dimension and convolution is used for feature extraction. The convolution operation uses a 7*7 kernel with a stride of 1 and a sigmoid activation function to reduce the dimensionality to 1. The spatial attention weights are then generated by the sigmoid function and element-wise multiplied with the input feature map of the module to regenerate the feature map.

[0047] In step (3) of this invention, the Stem module is used to replace the focus layer in YOLOv5s. The Stem module performs feature extraction through two branch networks. The specific steps are as follows:

[0048] The input image first passes through a regular convolution with a kernel size of 3*3 and a stride of 2, using the ReLU6 activation function. Then, it passes through two branches: one branch uses a 2*2 pooling kernel, and the other branch uses a regular convolution with a kernel size of 1*1 and a stride of 1, using the Silu activation function, and then another regular convolution with a kernel size of 3*3 and a stride of 1, also using the Silu activation function. The two branches are then concatenated in the channel direction, and finally passed through a regular convolution with a kernel size of 3*3 and a stride of 1, using the ReLU6 activation function.

[0049] Preferably, the Mosaic data augmentation in step (6) involves setting bounding boxes for all four photos in the image, then stitching them together to obtain a new image. The new image is then fed into a neural network for learning. Data augmentation operations are performed on each of the four photos in the stitched new image, including left and right flipping, proportional scaling, color gamut changes, and proportional scaling of the bounding boxes in the image according to the image size.

[0050] Preferably, when training in step (7), it is necessary to set the initial parameters for network training. The initial parameters include the image input size, momentum parameter, weight decay regularization term parameter, image angle change parameter, saturation and exposure change parameter, hue change parameter, initial learning rate, and number of training iterations. Adjust the momentum parameter, weight decay regularization term parameter, initial learning rate, and number of training iterations. After training, the training results are stabilized, and mAP is used to evaluate the network performance to obtain the trained YOLOv5-CBAM network model.

[0051] In step (8) of this invention, the image to be detected is input into the network model, and detection boxes of three scales are output. Then, the detection boxes are processed as follows:

[0052] Detection boxes with confidence scores below the threshold are filtered out, and then non-maximum suppression algorithm is used to filter the remaining detection boxes to obtain the best crested ibis detection box.

[0053] The nonmaximum prediction algorithm is as follows: First, find the detection box with the highest confidence among all detection boxes. Then, calculate the I0U between each detection box and the remaining detection boxes. The I0U is the intersection of two detection boxes divided by the union of two detection boxes. If the value is greater than a set threshold, the detection box is removed. The remaining detection boxes are the best ones.

[0054] The above-described embodiments merely illustrate several implementations of the present invention, and while their descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art would be able to make numerous variations and improvements without departing from the spirit of the present invention, all of which fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be determined by the appended claims.

Claims

1. A real-time detection method for crested ibises in the wild based on YOLOv5-CBAM, characterized in that, Includes the following steps: (1) Collect image data of crested ibises in the wild, and perform image annotation and data augmentation to obtain a crested ibis image database; (2) Divide the images in the crested ibis image database into a training set and a test set in an 8:2 ratio; (3) Construct a YOLOv5-CBAM network model using the CBAM attention module and the Stem module; (4) Use the K-means clustering algorithm to cluster the crested ibis anchor frame size in the wild crested ibis dataset; (5) Reduce the image size in the training set to a multiple of 32 in the range of 320-640K, while keeping the input image size consistent in length and width; (6) Perform Mosaic data augmentation on the training set images processed in step (5); (7) Use the training set images processed in step (6) to train the YOLOv5-CBAM network model described in step (3) to obtain the trained YOLOv5-CBAM network model. (8) Input the real-time images of wild crested ibises to be detected into the trained YOLOv5-CBAM network model for detection; Step (3) Replace the focus layer in YOLOv5s with the Stem module. The Stem module extracts features through two branch networks. The specific steps are as follows: The input image first passes through a regular convolution with a kernel size of 3*3 and a stride of 2, using the ReLU6 activation function. Then, it passes through two branches: one branch uses a 2*2 pooling kernel, and the other branch uses a regular convolution with a kernel size of 1*1 and a stride of 1, using the Silu activation function, and then another regular convolution with a kernel size of 3*3 and a stride of 1, also using the Silu activation function. The two branches are then concatenated in the channel direction, and finally passed through a regular convolution with a kernel size of 3*3 and a stride of 1, using the ReLU6 activation function.

2. The real-time detection method for crested ibises in the wild based on YOLOv5-CBAM according to claim 1, characterized in that, Step (1) involves collecting image data of crested ibises from the Hanzhong Crested Ibis National Nature Reserve, labeling the crested ibises in the images using LabelImg, and performing data enhancement processing such as rotation, tangent, random cropping, and color space transformation on the images to obtain a crested ibis image database.

3. The real-time detection method for crested ibises in the field based on YOLOv5-CBAM according to claim 1, characterized in that, Step (3) is to remove the first layer of YOLOv5m, namely the Focus layer, and add the Stem module; add the CBAM attention module to the backbone network of YOLOv5m, and add the CBAM attention module to the feature fusion module of YOLOv5m, so as to obtain the YOLOv5-CBAM network model.

4. The real-time detection method for crested ibises in the wild based on YOLOv5-CBAM according to claim 1, characterized in that, The CBAM attention module in step (3) includes a channel attention module (CAM) and a spatial attention module (SAM); The channel attention module first processes the input feature map through global max pooling and global average pooling to obtain two 1*1*C feature maps. Then, it feeds them into a shared fully connected layer containing two neural networks. The shared fully connected layer uses the ReLU activation function. Then, the two feature vectors output by the shared fully connected layer are element-wise summed and activated by Sigmoid. The generated feature vector is the attention weight of the channel dimension of the original input feature map. The spatial attention module takes the output feature map of the channel attention module as the input feature map. First, it performs global max pooling and global average pooling on the input feature map to obtain two H*W*1 feature maps. These feature maps are then concatenated along the channel dimension and convolution is used for feature extraction. The convolution operation uses a 7*7 kernel with a stride of 1 and a sigmoid activation function to reduce the dimensionality to 1. The spatial attention weights are then generated by the sigmoid function and element-wise multiplied with the input feature map of the module to regenerate the feature map.

5. The real-time detection method for crested ibises in the wild based on YOLOv5-CBAM according to claim 1, characterized in that, The Mosaic data augmentation in step (6) involves setting bounding boxes for all four photos in the image, then stitching them together to obtain a new image. The new image is then fed into a neural network for learning. Data augmentation operations are performed on each of the four photos in the stitched new image, including left and right flipping, proportional scaling, color gamut changes, and scaling the bounding boxes in the image proportionally to the image size.

6. The real-time detection method for crested ibises in the wild based on YOLOv5-CBAM according to claim 1, characterized in that, Step (7) When training, it is necessary to set the initial parameters of network training. The initial parameters include image input size, momentum parameter, weight decay regularization term parameter, image angle change parameter, saturation and exposure change parameter, hue change parameter, initial learning rate and number of training iterations. Adjust the momentum parameter, weight decay regularization term parameter, initial learning rate and number of training iterations. After training, the training results were stabilized, and the network performance was evaluated using mAP to obtain the trained YOLOv5-CBAM network model.

7. The real-time detection method for crested ibises in the wild based on YOLOv5-CBAM according to claim 1, characterized in that, Step (8) Input the image to be detected into the network model, output detection boxes at three scales, and then perform the following operations on the detection boxes: Detection boxes with confidence scores below the threshold are filtered out, and then non-maximum suppression algorithm is used to filter the remaining detection boxes to obtain the best crested ibis detection box. The nonmaximum prediction algorithm is as follows: First, find the detection box with the highest confidence among all detection boxes. Then, calculate the I0U between each detection box and the remaining detection boxes. The I0U is the intersection of two detection boxes divided by the union of two detection boxes. If the value is greater than a set threshold, the detection box is removed. The remaining detection boxes are the best ones.

Citation Information

Patent Citations

  • Bridge surface crack detection method based on YOLO v3 and attention mechanism

    CN111681240A

  • YOLOv5 neural network vehicle detection method added with attention mechanism

    CN114092764A

  • Construction method of lightweight algae target detection algorithm Alga-YOLO based on YOLOv5

    CN115601559A