A method for horseshoe bat recognition based on attention convolutional neural network
By adding attention module CBAM in the VGG16 architecture, the model's attention to subtle features is enhanced, and the existing convolutional neural networks have solved the problem of low recognition accuracy and insufficient representation ability in the chrysanthemum bat classification task, and high-precision chrysanthemum bat recognition is achieved.
Patent Information
- Application Number
- CN202210240860.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-10
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2042-03-10
AI Technical Summary
现有卷积神经网络在菊头蝠分类任务中识别精度不高,模型表征能力较弱,难以找到完全代表对象的细微特征。
The chrysanthemum bat recognition method based on attention convolution neural network is adopted. By adding attention module CBAM to the VGG16 architecture, the model's attention to subtle features is enhanced and the representation ability is improved.
The accuracy of chrysanthemum bat recognition was improved, and the recognition accuracy of the trained network model VGG16-CBAM reached 92.41%, and the training speed was accelerated, effectively solving the shortcomings of the existing convolutional neural network in the chrysanthemum bat classification task.
Smart Images

Figure CN114758379B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of biological image recognition and classification, and in particular to a horseshoe bat recognition method based on an attention convolutional neural network. Background Art
[0002] With the development of computer science and technology, deep learning algorithms represented by convolutional neural networks have been widely used in the field of computer vision, especially in the field of image classification. Image classification has outstanding performance in the classification of different species such as birds, flowers and bats. However, when it comes to the species of bats, if you want to complete the classification task of classifying different species of bats with subtle differences, the results are often difficult to meet expectations. The reason is that the main objects in fine-grained images differ only in subtle features, which makes fine-grained image recognition and classification itself a challenging task. It is difficult for existing convolutional neural networks to find subtle features that fully represent the objects. This also causes the shortcomings of convolutional neural networks represented by VGG, ResNet, AlexNet, etc. in the classification task of horseshoe bats.
[0003] Traditional bat classification is mainly based on the appearance of the bats. Taking the horseshoe bat as an example, due to the high similarity between individual bats, manual identification often requires the use of some professional instruments. Since the characteristics that distinguish horseshoe bats from other individuals are often subtle, pure manual identification and classification without the assistance of instruments is prone to errors and is time-consuming and labor-intensive. Summary of the invention
[0004] 1. Technical issues to be resolved
[0005] In view of the shortcomings of the prior art, the present invention provides a horseshoe bat recognition method based on an attention convolutional neural network, which has the advantages of high recognition accuracy and the ability to improve the representation ability of the model, and solves the problems of insufficient recognition accuracy and weak representation ability of the model in the existing recognition methods.
[0006] (II) Technical solution
[0007] In order to achieve the above-mentioned purpose of having high recognition accuracy and being able to improve the representation ability of the model, the present invention provides the following technical solution: a method for recognizing horseshoe bats based on an attention convolutional neural network, comprising the following steps:
[0008] S1. Original image preprocessing and dataset generation
[0009] Since the collected horseshoe bat images are stored in different formats, it is not convenient for subsequent processing. Therefore, the image format needs to be converted into JPEG format first. Considering that the existing horseshoe bat images are not shot for a single feature, the horseshoe bat features of the images in the original data set are relatively messy. Therefore, facial features need to be used for recognition and classification, and images with obvious facial features are selected as the data set.
[0010] S2. Dataset Division
[0011] After completing the image preprocessing, the data set is randomly divided into a training set and a test set in a ratio of approximately 4:1. The training set is used to train the network to determine the optimal parameters, and the test set is used to verify the reliability and feasibility of the network model.
[0012] S3. Model building
[0013] An attention convolutional neural network model VGG16-CBAM for horseshoe bat recognition and classification was established. Compared with the VGG16 convolutional neural network model, VGG16-CBAM added an attention mechanism module CBAM (Convolutional Block Attention Module) between Block4 and Block5 to further increase the representation ability of VGG16. CBAM consists of channel attention (Channel Attention) and spatial attention (Spatial Attention) connected in sequence.
[0014] S4. Model training
[0015] After the network model is established, the training set needs to be used to train the model to obtain the best network model parameters. We divide the training set into several batches according to the amount of data in the training set. The amount of data in each batch is 16 images, and the images in each batch are randomly shuffled during the training process.
[0016] S5. Model Validation
[0017] After the model training is completed, it is necessary to further verify the reliability and feasibility of the model. In this step, a test set is needed to verify the reliability and feasibility of the network. When testing the network, the BN layer and the Dropout layer are disabled to avoid changes in weights.
[0018] Preferably, in the step S1, since the pixels of the captured horseshoe bat image are relatively high and cannot be directly sent to the network for training, we compress the horseshoe bat image to 224×224 by scaling, thus completing the image preprocessing.
[0019] Preferably, in the step S2, in order to address the problem that the amount of image data of the big-eared horseshoe bat, the iron horseshoe bat, the Chiang Mai horseshoe bat, etc. in the training set is slightly lower than the amount of image data of horseshoe bats of other categories, the amount of data is increased by randomly rotating some images at different angles so that the image data of horseshoe bats of each category are roughly equal, thereby ensuring the balance of network model learning.
[0020] Preferably, in the step S3, the VGG16-CBAM network model consists of 5 convolution blocks (Block), an attention module (CBAM) and a fully connected (FC) part, each convolution block consists of several convolution layers and a maximum pooling layer (MaxPool). Taking the convolution block Block1 as an example, the input feature map is first convolved with 64 convolution kernels, then normalized by the BN (Batch Normalization) layer, and then nonlinearized by the activation function ReLU. The ReLU function is as follows:
[0021]
[0022] Then after repeating a round of the above operations, the maximum pooling layer is finally output. The tree pool that performs maximum pooling is a 2×2 matrix. The above is the entire content of convolution block Block1, and other convolution blocks are similar.
[0023] Preferably, in the S3 step, on the attention module, the channel attention is first completed: the feature map F is input, and the feature map of C×H×W is converted to a size of C×1×1 through two parallel maximum pooling and average pooling, and then passes through a Shared MLP, and the number of channels is compressed to C / r (reduction=16) through a convolution operation, and then a nonlinear operation is performed through the activation function ReLU, and then it is expanded back to C through a convolution operation to obtain two activated results, and finally the two are added and the result of a sigmoid is multiplied by the original input, and the size is changed back to C×H×W to complete the channel attention operation.
[0024] Preferably, in the step S3, spatial attention is performed: the feature map F' obtained in the previous step is divided into two tensors of size H×W×1 through maximum pooling and average pooling, and then the two are stacked together through the Concat operation (C is 2), and then the channel is changed to 1 through the convolution operation while ensuring that H and W remain unchanged. The result obtained by a sigmoid is multiplied by the input of the previous step to return to C×H×W, completing the spatial attention operation, where the sigmoid function is as follows:
[0025]
[0026] Complete the spatial attention operation.
[0027] Preferably, in the S3 step, in the fully connected part, firstly, three fully connected layers are passed, the first and second fully connected layers are composed of 4096 neurons, and after the fully connected operation, the activation function ReLU is used for nonlinear operation, the third connection layer is composed of 8 neurons, and after the fully connected operation is completed, the multi-classification output is finally converted into probability through SoftMax, as follows:
[0028]
[0029] Among them, z i is the output value of the i-th node, n is the number of output nodes, that is, the number of classified categories. At this point, the attention convolutional neural network model VGG16-CBAM is built.
[0030] Preferably, in step S4, the learning rate η is initialized to 0.01 and the weight optimization is performed using the stochastic gradient descent method. During the training process, the Dropout layer of the fully connected part needs to be enabled to randomly discard some neurons to prevent overfitting of the model.
[0031] (III) Beneficial effects
[0032] Compared with the prior art, the present invention provides a method for identifying horseshoe bats based on an attention convolutional neural network, which has the following beneficial effects:
[0033] 1. The horseshoe bat recognition method based on the attention convolutional neural network adds an attention module CBAM on the basis of the convolutional neural network VGG16 architecture, so that the model pays more attention to the subtle features of the horseshoe bat object and improves the representation ability of the model. The classification accuracy of the trained network model VGG16-CBAM is better than that of the simple VGG16 network architecture. The recognition accuracy of VGG16-CBAM reaches 92.41%, and a BN (Batch Normalization) layer is added after the convolution layer output to prevent gradient disappearance or gradient explosion and speed up training.
[0034] 2. This horseshoe bat recognition method based on attention convolutional neural network effectively solves the problem that it is difficult for existing convolutional neural networks to find subtle features that fully represent the object, which causes the convolutional neural networks represented by VGG, ResNet, AlexNet, etc. to be insufficient in horseshoe bat classification tasks. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 is a flow chart of the method of the present invention;
[0036] Figure 2 This is the network architecture diagram of the attention convolutional neural network VGG16-CBAM;
[0037] Figure 3 This is the architecture diagram of the attention module CBAM. DETAILED DESCRIPTION
[0038] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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 are within the scope of protection of the present invention.
[0039] A method for recognizing horseshoe bats based on an attention convolutional neural network, characterized in that it comprises the following steps:
[0040] S1. Original image preprocessing and dataset generation
[0041] Since the collected horseshoe bat images are stored in different formats, it is not convenient for subsequent processing. Therefore, we first need to convert the image format into JPEG format. At the same time, considering that the existing horseshoe bat images are not shot for a single feature, the horseshoe bat features of the original data set are relatively messy. For this, facial features need to be used for recognition and classification, and images with obvious facial features are selected as the data set. Since the pixels of the horseshoe bat images are relatively high, they cannot be directly sent to the network for training. Therefore, we compress the horseshoe bat images to 224×224 by scaling, thus completing the image preprocessing.
[0042] S2. Dataset Division
[0043] After completing the image preprocessing, the data set was randomly divided into a training set and a test set in a ratio of approximately 4:1. The training set was used to train the network to determine the optimal parameters, and the test set was used to verify the reliability and feasibility of the network model. In order to address the problem that the amount of image data of big-eared horseshoe bat, iron horseshoe bat, Chiang Mai horseshoe bat, etc. in the training set was slightly lower than the amount of image data of other categories of horseshoe bats, the data amount was increased by randomly rotating some images at different angles to make the image data of horseshoe bats of each category roughly equal, thereby ensuring the balance of network model learning.
[0044] S3. Model building
[0045] An attention convolutional neural network model VGG16-CBAM for horseshoe bat recognition and classification was established. Compared with the VGG16 convolutional neural network model, VGG16-CBAM added an attention mechanism module CBAM (Convolutional Block Attention Module) between Block4 and Block5 to further increase the representation ability of VGG16. CBAM consists of channel attention (Channel Attention) and spatial attention (Spatial Attention). The VGG16-CBAM network model consists of 5 convolution blocks (Block), an attention module (CBAM) and a fully connected (FC) part. Each convolution block consists of several convolution layers and a maximum pooling layer (MaxPool). Taking the convolution block Block1 as an example, the input feature map is first convolved with 64 convolution kernels, then normalized by the BN (Batch Normalization) layer, and then nonlinearized by the activation function ReLU. The ReLU function is as follows:
[0046]
[0047] Then repeat the above operation for a round, and finally pass through the maximum pooling layer output. The tree pool that performs the maximum pooling is a 2×2 matrix. The above is the entire content of the convolution block Block1. Other convolution blocks are similar. In the attention module, the channel attention is first completed: input feature map F, and after two parallel maximum pooling and average pooling, the C×H×W feature map is changed to C×1×1 size, and then passed through a Shared MLP compresses the number of channels to C / r (reduction = 16) through convolution operation, and then performs nonlinear operation through activation function ReLU, and then expands back to C through convolution operation to obtain two activated results. Finally, add the two and multiply the result of a sigmoid by the original input, and the size becomes C×H×W to complete the channel attention operation. Finally, perform spatial attention: divide the feature map F' obtained in the previous step into two tensors of size H×W×1 through maximum pooling and average pooling, and then stack the two together through the Concat operation (C is 2), and then use the convolution operation to change the channel to 1 while ensuring that H and W remain unchanged. The result obtained through a sigmoid is multiplied by the input of the previous step to become C×H×W, completing the spatial attention operation, where the sigmoid function is as follows:
[0048]
[0049] To complete the spatial attention operation, in the fully connected part, first pass through 3 fully connected layers. The first and second fully connected layers are composed of 4096 neurons. After the fully connected operation, the activation function ReLU is used for nonlinear operation. The third connection layer is composed of 8 neurons. After the fully connected operation, the multi-classification output is finally converted into probability through SoftMax, as follows:
[0050]
[0051] Among them, z i is the output value of the i-th node, n is the number of output nodes, that is, the number of classified categories. At this point, the attention convolutional neural network model VGG16-CBAM is built.
[0052] S4. Model training
[0053] After the network model is established, the training set needs to be used to train the model to obtain the best network model parameters. We divide the training set into several batches according to the amount of data in the training set. The amount of data in each batch is 16 images. The images in each batch are randomly shuffled during the training process. The initial learning rate η=0.01 uses the stochastic gradient descent method for weight optimization. During the training process, the Dropout layer of the fully connected part needs to be enabled to randomly discard some neurons to prevent overfitting of the model.
[0054] S5. Model Validation
[0055] After the model training is completed, it is necessary to further verify the reliability and feasibility of the model. In this step, a test set is needed to verify the reliability and feasibility of the network. When testing the network, the BN layer and the Dropout layer are disabled to avoid changes in weights.
[0056] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for identifying horseshoe bats based on an attention convolutional neural network, characterized in that: The following steps are involved: S1. Original image preprocessing and dataset generation Since the collected horseshoe bat images are stored in different formats, it is not convenient for subsequent processing. Therefore, the image format needs to be uniformly converted to JPEG format. At the same time, considering that the existing horseshoe bat images are not shot for a single feature, the horseshoe bat features of the original data set are relatively messy. Therefore, facial features need to be used for recognition and classification, and images with obvious facial features are selected as the data set. S2. Dataset Division After completing the image preprocessing, the data set is randomly divided into a training set and a test set at a ratio of about 4:
1. The training set is used to train the network to determine the optimal parameters, and the test set is used to verify the reliability and feasibility of the network model. S3. Model building The attention convolutional neural network model VGG16-CBAM for horseshoe bat recognition and classification was established. Compared with the VGG16 convolutional neural network model, VGG16-CBAM added an attention mechanism module CBAM (Convolutional Block Attention Module) between Block4 and Block5 to further increase the representation ability of VGG16. CBAM consists of channel attention and spatial attention connected in sequence. S4. Model training After the network model is established, the training set needs to be used to train the model to obtain the best network model parameters. We divide the training set into several batches according to the amount of data in the training set. The amount of data in each batch is 16 images. The images in each batch are randomly shuffled during the training process. S5. Model Validation After the model training is completed, it is necessary to further verify the reliability and feasibility of the model. In this step, a test set is needed to verify the reliability and feasibility of the network. When testing the network, the BN layer and the Dropout layer are disabled to avoid changes in weights.
2. The method for recognizing horseshoe bats based on an attention convolutional neural network according to claim 1, characterized in that: In the step S1, since the pixels of the horseshoe bat image are relatively high and cannot be directly sent to the network for training, we compress the horseshoe bat image to 224×224 by scaling, thus completing the image preprocessing.
3. The method for recognizing horseshoe bats based on an attention convolutional neural network according to claim 1, characterized in that: In the step S2, in order to solve the problem that the image data volume of the big-eared horseshoe bat, the iron horseshoe bat, the Chiang Mai horseshoe bat, etc. in the training set is slightly lower than the image data volume of other categories of horseshoe bats, the data volume is increased by randomly rotating some images at different angles to make the image data of horseshoe bats of each category roughly equal, thereby ensuring the balance of network model learning.
4. The method for recognizing horseshoe bats based on an attention convolutional neural network according to claim 1, characterized in that: In the S3 step, the VGG16-CBAM network model consists of 5 convolution blocks (Block), an attention module (CBAM) and a fully connected (FC) part. Each convolution block consists of several convolution layers and a maximum pooling layer (MaxPool). Taking the convolution block Block1 as an example, the input feature map is first convolved with 64 convolution kernels, then normalized by the BN (BatchNormalization) layer, and then nonlinearized by the activation function ReLU. The ReLU function is as follows: Then after repeating a round of the above operations, the maximum pooling layer is finally output. The tree pool that performs maximum pooling is a 2×2 matrix. The above is the entire content of convolution block Block1, and other convolution blocks are similar.
5. The method for recognizing horseshoe bats based on an attention convolutional neural network according to claim 1, characterized in that: In the S3 step, in the attention module, the channel attention is first completed: the feature map F is input, and the feature map of C×H×W is converted to a size of C×1×1 through two parallel maximum pooling and average pooling, and then passed through a SharedMLP, and the number of channels is compressed to C / r (reduction=16) through a convolution operation, and then a nonlinear operation is performed through the activation function ReLU, and then expanded back to C through a convolution operation to obtain two activated results. Finally, the two are added and the result of a sigmoid is multiplied by the original input, and the size is changed back to C×H×W to complete the channel attention operation.
6. The method for recognizing horseshoe bats based on an attention convolutional neural network according to claim 1, characterized in that: In the step S3, spatial attention is performed: the feature map F' obtained in the previous step is divided into two tensors of size H×W×1 through maximum pooling and average pooling, and then the two are stacked together through the Concat operation (C is 2), and then the channel is changed to 1 through the convolution operation while ensuring that H and W remain unchanged. The result obtained by a sigmoid is multiplied by the input of the previous step to return to C×H×W, completing the spatial attention operation, where the sigmoid function is as follows: Complete the spatial attention operation.
7. The method for recognizing horseshoe bats based on an attention convolutional neural network according to claim 1, characterized in that: In the S3 step, in the fully connected part, firstly, three fully connected layers are passed, the first and second fully connected layers are composed of 4096 neurons, and after the fully connected operation, the activation function ReLU is used for nonlinear operation, and the third connection layer is composed of 8 neurons. After the fully connected operation is completed, the multi-classification output is finally converted into probability through SoftMax, as follows: Among them, z i is the output value of the i-th node, n is the number of output nodes, that is, the number of classified categories. At this point, the attention convolutional neural network model VGG16-CBAM is built.
8. The method for recognizing horseshoe bats based on an attention convolutional neural network according to claim 1, characterized in that: In the step S4, the learning rate η is initialized to 0.01 and the weights are optimized using the stochastic gradient descent method. During the training process, the Dropout layer of the fully connected part needs to be enabled to randomly discard some neurons to prevent overfitting of the model.