Improved B-CNN shark population fine-grained classification method based on attention mechanism
By using the improved ResNet network and attention mechanism in Bilinear CNN, combined with the cross-channel loss function, the problem of high-dimensional features and poor interpretability in underwater shark classification is solved, the classification accuracy and generalization ability are improved, and detailed classification is achieved. Better capture and interpretation of granular features.
Patent Information
- Application Number
- CN202410655852.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2024-09-06
AI Technical Summary
Bilinear CNN has high-dimensional features in underwater shark classification, which leads to high computational costs and over-fitting risks. It lacks interpretability of local features and parts, and its performance depends on the quality of the basic convolutional network, making it difficult to provide intuitive classification decisions.
The improved ResNet network structure is used to replace the VGG feature extractor, the attention mechanism and cross-channel loss function are introduced, the feature extraction capability is enhanced through bilinear pooling and deformable convolution, and the accuracy of capturing and classifying fine-grained features is improved.
It improves the accuracy and interpretability of image classification, enhances the ability to recognize subtle differences in underwater shark images, and improves the generalization ability of the model, achieving higher accuracy and better interpretability.
Smart Images

Figure CN118609162A
Abstract
Description
Technical Field
[0001] The present invention is an improved B-CNN shark population fine-grained classification method based on attention mechanism, belonging to the field of fine-grained underwater shark image classification in computer vision. Background Art
[0002] Bilinear CNN (bilinear convolutional neural network) is a model used in computer vision for fine-grained image classification, especially for weakly supervised scenarios. This model structure consists of two convolutional networks (usually pre-trained VGG), which extract two feature maps of the image respectively and combine these features through a bilinear fusion operation. Bilinear fusion is achieved by calculating the outer product of the two feature maps and averaging the results. The generated bilinear feature vector is then used for classification tasks. This method can capture fine-grained features in the image, which is very important for distinguishing categories with similar appearance.
[0003] Although Bilinear CNN performs well in fine-grained image classification, it also has some shortcomings in underwater shark classification and recognition. First, the feature vector generated by bilinear confluence has a high dimension, which may lead to high computational cost and the risk of overfitting. Second, because the model mainly captures the interrelationships of global features, coupled with the dim and complex background of underwater images, it lacks the interpretability of local features and parts. In addition, the performance of Bilinear CNN depends largely on the quality of the underlying convolutional network it uses, and the nature of high-dimensional features may lead to difficulties in the optimization process.
[0004] The technical defects faced by Bilinear CNN in weakly supervised fine-grained image classification mainly include high-dimensional features and poor interpretability. The problem of high-dimensional features is manifested in the fact that the dimension of the feature vector generated by bilinear convergence is very high, which leads to a sharp increase in computational cost and storage requirements, while increasing the risk of model overfitting. Poor interpretability is a more prominent problem, because Bilinear CNN mainly captures the relationship between global features and lacks interpretability of local features and parts, which makes it difficult for the model to provide an intuitive understanding of classification decisions. The difficulty in solving poor interpretability lies in how to enhance the model's attention to local features and parts while maintaining model performance.
[0005] SUMMARY OF THE INVENTION
[0006] In view of the problems in the prior art, the present invention provides an improved B-CNN shark population fine-grained classification method based on attention mechanism.
[0007] The technical solution adopted by the present invention to solve the technical problem is: an improved B-CNN shark population fine-grained classification method based on attention mechanism, the method comprising:
[0008] Preprocessing of shark image data;
[0009] Input the preprocessed shark image data into the DM-BCNN model for training;
[0010] After determining the optimal number of iterations, the best experimental results are output.
[0011] The preprocessing of the shark image data includes adjusting and cutting the shark image to obtain standardized image data.
[0012] The step of inputting the pre-processed shark image data into the DM-BCNN model for training includes:
[0013] Input the preprocessed shark image data into DRAM_ResNet for processing;
[0014] Perform bilinear pooling on the features extracted from the network terminal layer;
[0015] Compute the outer product of the feature maps of the two streams A and B to capture high-order feature interactions that are critical for refinement;
[0016] The feature map data extracted by the model are used as the input of the fully connected layer (FC) of the traditional cross entropy loss function and the L MC The input of the discriminant component and the diversity component. Finally, L CE and L MC The weighted sum of the discriminant component and the diversity component is added.
[0017] The inputting of the pre-processed shark image data into DRAM_ResNet for processing comprises:
[0018] The preprocessed shark images are fed into DRAM_ResNet;
[0019] After the first layer of convolution with a convolution kernel size of 7×7, the output is 64×112×112;
[0020] Continue to enter the maxpool layer with a convolution kernel size of 3×3 to obtain an output of 64×56×56;
[0021] Enter the 4 layers in turn for processing.
[0022] The entering layer for processing includes:
[0023] The image data is processed by the conv-dconv-conv structure in D_ResNet;
[0024] The image data enters the newly introduced NAM attention mechanism and is processed using the scaling factor of batch normalization (BN).
[0025] The image data is processed by the conv-dconv-conv structure in D_ResNet including:
[0026] A 1×1 convolution operation is used to reduce the dimension of the feature image;
[0027] Use the normalization (BN) operation to keep the input of each layer of the neural network in the same distribution
[0028] Use a deformable convolution of size 3×3 and learn 2×3×3×56×56 (2*K*K*H*W) parameters;
[0029] Restore the dimension through a 1×1 standard convolution;
[0030] Perform BN and RELU operations.
[0031] The image data enters the newly introduced NAM attention mechanism, and the data is processed using the scaling factor of batch normalization (BN) including:
[0032] Keep the input residual and then normalize it;
[0033] Calculate the ratio of the absolute value of the normalized layer weight to the sum of the absolute values of the weights;
[0034] The feature map is weighted and multiplied with the residual.
[0035] The DM-BCNN model includes:
[0036] A bilinear convolutional neural network (B-CNN) is used as the basic model, the VGG feature extractor of the initial model is replaced by an improved ResNet network structure, the NAM attention mechanism is introduced, and the mutual channel loss function (Mutual Channel Loss) is used.
[0037] Beneficial effects of the present invention:
[0038] The present invention is an improvement on the bilinear convolutional neural network Bilinear CNN. By replacing the feature extractor in the original model from the VGG network to the deeper ResNet network, the feature extraction capability of the model is enhanced, so that it can capture richer image features, thereby improving the accuracy of image classification. In addition, by introducing deformable convolution and attention mechanism NAM (Normalization-based Attention Module) in the ResNet convolution layer, the model's ability to capture fine-grained features in underwater shark images is enhanced, and the ability to recognize subtle differences in categories is improved. At the same time, the interpretability of the model is improved, so that it can pay more attention to the areas in underwater shark images that have an important impact on classification decisions.
[0039] In addition, the present invention improves the generalization ability of the model by replacing the original loss function with the mutual channel loss function Mutual Channel Loss, and enhances the adaptability of the model to new samples by promoting the mutual independence of different channel features. The improvement of the present invention solves the problems of the Bilinear CNN model in insufficient feature extraction ability on underwater shark images, weak ability to capture fine-grained features, poor model interpretability and limited generalization ability, thereby achieving an image classification model with higher accuracy, better interpretability and stronger generalization ability. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0041] Figure 1 It is a method flow chart of the improved B-CNN shark population fine-grained classification method based on the attention mechanism of the present invention;
[0042] Figure 2 This is the overall framework diagram of the improved model in the improved B-CNN shark population fine-grained classification method based on the attention mechanism of the present invention;
[0043] Figure 3 This is a flowchart of the DRAM_ResNet part of the improved B-CNN shark population fine-grained classification method based on the attention mechanism of the present invention;
[0044] Figure 4 This is a schematic diagram of the attention mechanism of the NAM channel in the improved B-CNN shark population fine-grained classification method based on the attention mechanism of the present invention. DETAILED DESCRIPTION
[0045] In order to make the technical means, creative features, objectives and effects achieved by the present invention easy to understand, the present invention is further explained below in conjunction with specific implementation methods.
[0046] This application provides a technical solution, please refer to Figure 1-Figure 4 ,An improved B-CNN shark population fine-grained classification method based on attention mechanism, the method includes the following steps;
[0047] S01: Preprocessing of shark image data;
[0048] First, the shark images were resized to a uniform size of 256 × 256 pixels and then randomly cropped to 224 × 224 pixels to fit the network’s input size requirement. This resizing and cropping process helps standardize the input data and enhance the dataset to prevent overfitting.
[0049] S02: Input the preprocessed shark image data into the DM-BCNN model for training;
[0050] The specific steps include:
[0051] S21: input the preprocessed shark image data into DRAM_ResNet for processing;
[0052] Specifically, the 224×224×3 image data is input into the new backbone network DRAM_ResNet. The DRAM_ResNet flow chart is as follows: Figure 2 As shown in the figure, when the image data enters DRAM_ResNet, it first passes through the first convolution layer with a convolution kernel size of 7×7 to obtain an output of 64×112×112, and then continues to enter the maxpool layer with a convolution kernel size of 3×3 to obtain an output of 64×56×56, thereby reducing the dimension while retaining the important features of the shark image. After the initial convolution layer and the maximum pooling layer, it begins to enter the four layers in sequence, each layer consisting of several Bottlenecks;
[0053] Taking the Bottleneck in the first layer1 as an example, the image data of size 64×56×56 is first reduced in dimension by a 1×1 convolution, followed by a BN operation to keep the input of each layer of the neural network in the same distribution. Subsequently, after a 3×3 deformable convolution, 2×3×3×56×56 (2*K*K*H*W) parameters are learned so that each convolution sampling point in the convolution kernel area learns an offset to perform a deformable convolution operation, where K*K is the convolution kernel size and H*W is the input image size. After adjusting the input shape using a 3×3 deformable convolution, the model can focus on features that are critical to distinguishing shark categories. Then the dimension is restored through a 1×1 standard convolution, and finally the BN and RELU operations are performed.
[0054] After the image data is processed by the conv-dconv-conv structure in D_ResNet, it enters the next stage of model feature extraction. At this time, the image data enters the newly introduced NAM attention mechanism and processes the data using the scaling factor of batch normalization (BN). First, the input residual is retained and then normalized. Then, the ratio of the absolute value of the normalization layer weight to the sum of the absolute values of the weights is calculated to represent the different importance of each channel. Finally, the feature map is weighted and multiplied with the residual to make it emphasize some important channels and suppress some unimportant channels, thereby improving the ability to extract key features of shark images. As the image data is transmitted in the network, each layer block in the DRAM_ResNet architecture may use deformable convolution to adjust the input shape and key feature points under the NAM attention mechanism. The channel attention mechanism in the NAM attention mechanism is as follows Figure 4 shown.
[0055] S22: Perform bilinear pooling on the features extracted from the network terminal layer;
[0056] S23: Calculate the outer product of the feature maps of the two streams A and B to capture the high-order feature interactions that are critical for refinement. Then, the feature map data extracted by the model is used as the input of the fully connected layer (FC) of the traditional cross entropy loss function and the L in the mutual channel loss. MC The input of the discriminant component and the diversity component. Finally, L CE and L MC The weighted sum of the discriminant component and the diversity component is added to enhance the network's discriminant ability for shark image features and obtain the best shark population classification result.
[0057] S03: After determining the optimal number of iterations, output the best experimental results.
[0058] Regarding the above DM-BCNN model, it includes the following structure:
[0059] A bilinear convolutional neural network (B-CNN) is used as the basic model, and the improved ResNet network structure is used to replace the VGG feature extractor of the initial model to more effectively capture the deep features of shark images. At the same time, the NAM attention mechanism is introduced to further enhance the model's ability to identify and extract key features of shark images. Finally, a novel mutual channel loss function is used to strengthen the semantic relevance of different features to improve the overall classification performance of the model.
[0060] Specifically, the VGG16 backbone network used in dual channels A and B in the original model (bilinear convolutional neural network (B-CNN)) was replaced with an improved DRAM_ResNet backbone network. This network has a deeper network structure and performs well in feature representation capability, training stability, and speed. On this basis, a convolution operation with adaptive shape sampling was added, and the standard convolution kernel in the initial ResNet50 was replaced with a deformable convolution kernel. This operation can adjust the shape of the convolution kernel. Combined with the conv-dconv-conv structure, the model can better capture the irregular shapes and local structures in the input image, and better capture the irregular patterns found in underwater images. It is particularly suitable for identifying shark species in complex backgrounds, and can more flexibly identify the morphology and key features of sharks in complex backgrounds, which helps to extract richer and more discriminative local features, and significantly improves the ability to capture small category features on shark images.
[0061] Finally, the Normalization-based Attention Module (NAM) attention mechanism and mutual channel loss function are introduced. The attention mechanism further improves the attention and classification accuracy of the model. By emphasizing important channels and suppressing unimportant channels, the model's ability to extract key features of shark images is improved. The loss function in the model is replaced by the mutual channel loss function, which improves the semantic correlation between different channels of the image and further improves the performance of the model in fine-grained classification tasks.
[0062] These improvements enable the model to have better performance in fine-grained classification of sharks, and to more accurately identify and distinguish different species of sharks, especially in complex seabed environments. These technical advantages are expected to play an important role in the fields of marine biological research, shark population monitoring and protection.
[0063] Although this specification is described according to implementation modes, not every implementation mode includes only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.
Claims
1. An improved B-CNN shark population fine-grained classification method based on attention mechanism, characterized by: The method comprises: Preprocessing of shark image data; Input the preprocessed shark image data into the DM-BCNN model for training; After determining the optimal number of iterations, the best experimental results are output.
2. The improved B-CNN shark population fine-grained classification method based on the attention mechanism according to claim 1 is characterized by: The preprocessing of the shark image data includes adjusting and cutting the shark image to obtain standardized image data.
3. The improved B-CNN shark population fine-grained classification method based on attention mechanism according to claim 1 or 2, characterized in that: The step of inputting the pre-processed shark image data into the DM-BCNN model for training includes: Input the preprocessed shark image data into DRAM_ResNet for processing; Perform bilinear pooling on the features extracted from the network terminal layer; Compute the outer product of the feature maps of the two streams A and B to capture high-order feature interactions that are critical for refinement; The feature map data extracted by the model are used as the input of the fully connected layer (FC) of the traditional cross entropy loss function and the L MC The input of the discriminant component and the diversity component is L CE and L MC The weighted sum of the discriminant component and the diversity component is added.
4. The improved B-CNN shark population fine-grained classification method based on attention mechanism according to claim 3 is characterized by: The inputting of the pre-processed shark image data into DRAM_ResNet for processing comprises: The preprocessed shark images are fed into DRAM_ResNet; After the first layer of convolution with a convolution kernel size of 7×7, the output is 64×112×112; Continue to enter the maxpool layer with a convolution kernel size of 3×3 to obtain an output of 64×56×56; Enter the 4 layers in turn for processing.
5. The improved B-CNN shark population fine-grained classification method based on attention mechanism according to claim 4 is characterized by: The entering layer for processing includes: The image data is processed by the conv-dconv-conv structure in D_ResNet; The image data enters the newly introduced NAM attention mechanism and is processed using the scaling factor of batch normalization (BN).
6. The improved B-CNN shark population fine-grained classification method based on attention mechanism according to claim 5 is characterized by: The image data is processed by the conv-dconv-conv structure in D_ResNet including: A 1×1 convolution operation is used to reduce the dimension of the feature image; Use the normalization (BN) operation to keep the input of each layer of the neural network in the same distribution Use a deformable convolution of size 3×3 and learn 2×3×3×56×56 (2*K*K*H*W) parameters; Restore the dimension through a 1×1 standard convolution; Perform BN and RELU operations.
7. The improved B-CNN shark population fine-grained classification method based on attention mechanism according to claim 6 is characterized by: The image data enters the newly introduced NAM attention mechanism, and the data is processed using the scaling factor of batch normalization (BN) including: Keep the input residual and then normalize it; Calculate the ratio of the absolute value of the normalized layer weight to the sum of the absolute values of the weights; The feature map is weighted and multiplied with the residual.
8. The improved B-CNN shark population fine-grained classification method based on attention mechanism according to claim 7 is characterized by: The DM-BCNN model includes: A bilinear convolutional neural network (B-CNN) is used as the basic model, the VGG feature extractor of the initial model is replaced by an improved ResNet network structure, the NAM attention mechanism is introduced, and the mutual channel loss function (Mutual Channel Loss) is used.
