Ship image classification and recognition method based on global attention and stripe attention

By introducing global attention and stripe attention mechanisms in ship image classification recognition, combined with Swin Transformer and SSR image enhancement, the problems of large amount of calculation and redundant parameters in the existing technology are solved, and the accuracy of ship image classification recognition is improved Rate.

CN117593571BActive Publication Date: 2025-02-07NAVAL AVIATION UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311548538.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-20
Publication Date
2025-02-07
Estimated Expiration
2043-11-20

AI Technical Summary

Technical Problem

The existing ship image classification and recognition method based on deep learning is large in calculation and redundant in parameters, resulting in a low accuracy of ship image classification and recognition.

Method used

A ship image classification recognition method based on global attention and striped attention is proposed. By constructing an image classification model, Swin Transformer is used for feature extraction, combined with SSR image enhancement and striped self-attention mechanism, feature fusion and aggregation are performed. Finally, Feature extraction and optimization using NetVLAD and spatial attention.

Benefits of technology

It effectively reduces the calculation amount of the recognition process, reduces parameter redundancy, and improves the accuracy of ship image classification recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117593571B_ABST
    Figure CN117593571B_ABST
Patent Text Reader

Abstract

The present invention discloses a ship image classification and recognition method based on global attention and stripe attention. The method is based on an image classification model, and the image classification model includes: a global feature extraction and classification module, an attention feature extraction module, a feature aggregation classification module, and an image representation extraction and classification module. The stripe attention proposed in the present invention only focuses on the longitudinal and lateral areas of the region, so it can effectively reduce the amount of calculation, reduce parameter redundancy, and ultimately improve the accuracy of ship image classification and recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of computer vision recognition and relates to a classification and recognition method for ship images. Background Art

[0002] Ship image classification and recognition is one of the hot topics in the field of remote sensing image processing.

[0003] As a maritime transport carrier and important military target, the automatic identification of ships has very important practical significance. In the civilian field, ship image classification and recognition can monitor the maritime traffic in specific ports or sea areas, assist in the rescue of distressed ships, and cooperate with security management departments to monitor and combat illegal fishing, illegal dumping of oil, smuggling, piracy and other illegal activities. In the military field, ship image classification and recognition can monitor the deployment and dynamics of ships in enemy key ports and sea areas, analyze the enemy's maritime combat strength, evaluate the effectiveness of maritime strikes during wartime, and form maritime combat intelligence.

[0004] In recent years, ship image classification and recognition methods based on deep learning have achieved excellent results. Model methods represented by VIT (Vision Transformer) have achieved remarkable results, but they have significant defects such as large amount of calculation and parameter redundancy. This is very unfavorable for the final representation modeling of ship images, resulting in low accuracy of ship image classification and recognition. Summary of the invention

[0005] The present invention proposes a ship image classification and recognition method based on global attention and stripe attention, the purpose of which is to reduce the computational complexity of the recognition process, reduce parameter redundancy, and improve the accuracy of classification and recognition.

[0006] The technical solution of the present invention is as follows:

[0007] A ship image classification and recognition method based on global attention and stripe attention, comprising the following steps:

[0008] Step 1: construct an image classification model, wherein the input of the image classification model is a ship image; the image classification model includes:

[0009] A global feature extraction and classification module, used to extract the global features of the input image and obtain a first classification result based on the global features;

[0010] An attention feature extraction module, used to extract attention features of the input image;

[0011] A feature aggregation classification module is used to aggregate the global features and the attention features, and obtain a second classification result based on the aggregation result;

[0012] An image representation extraction and classification module, used to obtain an image representation based on the attention feature, and obtain a third classification result based on the image representation;

[0013] The output of the image classification model is a final classification result obtained based on the first classification result, the second classification result and the third classification result;

[0014] Step 2: Train the image classification model;

[0015] Step 3: Input the ship image to be classified into the trained image classification model to obtain the final classification result.

[0016] As a further improvement of the ship image classification and recognition method based on global attention and stripe attention, the processing process of the global feature extraction and classification module is as follows:

[0017] Step A1: Assume the input ship image is x∈R C×H×W , C is the number of channels of the image, H is the height of the image, and W is the width of the image; the image is divided into blocks to obtain a sequence F containing m image blocks = (x1, x2, ..., x j ,…x m ), where x j represents the jth image block, x j ∈R C×p×p , p×p represents the dimension of each image block, that is, the length of the image block is p pixels, the width is p pixels, and m = (H×W) / p 2 ;

[0018] Step A2: embed the image block sequence F to obtain feature F0:

[0019] F0 = LN(Conv(F));

[0020] Among them, F0∈R m×D , Conv(·) represents the convolution operation, and LN(·) represents the normalization process;

[0021] Step A3, inputting feature F0 into the Transformer encoder module to obtain a global feature; the Transformer encoder includes 4 sub-modules connected in sequence, and the 4 sub-modules include 2, 2, 6, and 2 sequentially stacked processing modules in the order of connection, and each of the processing modules includes a Patch module and an STB module connected in sequence;

[0022] Step A4: Use a set of learnable position encoding parameters to perform position encoding enhancement processing on the global features, and then perform a linear transformation on the result of the position encoding enhancement processing to obtain a first classification result.

[0023] As a further improvement of the ship image classification and recognition method based on global attention and stripe attention, the specific method of step A3 is as follows:

[0024] Each Patch module converts the features input to its processing module as follows:

[0025] F t′ =Conv(LN(Flatten(Concat(Split(F t-1 )))));

[0026] Among them, F t-1 is the feature input to the processing module, the total number of processing modules is 12, t = 1, 2 ... 12; Conv (·) is a convolution operation, LN (·) is a normalization operation, Flatten (·) represents a flattening operation, Concat (·) represents a concatenation operation, and Split (·) represents a segmentation operation; and in the same submodule, the convolution operation parameters of the Patch module of the first processing module are different from the convolution operation parameters of the Patch modules of other processing modules: for the Patch module of the first processing module, the convolution operation in the formula doubles the number of channels of the input feature and reduces the number of features to one quarter, and for the Patch modules of other processing modules, the convolution operation in the formula does not change the number of channels and the number of features of the input feature;

[0027] Each STB module consists of two window multi-head attention calculations, and the processing process is as follows:

[0028] F t″ =LN(WMSA(F t′ ))+F t′ ;

[0029]

[0030] Among them, F t′ is the output feature of the Patch module of the same processing module as the STB module, MLP(·) represents multi-layer perceptron, WMSA(·) represents window multi-head attention calculation, and SWMSA(·) represents sliding window multi-head attention calculation;

[0031] The output features of the STB module of the last processing module of the last submodule in the Transformer encoder are recorded as D1=16D;F 12 This is the extracted global feature.

[0032] As a further improvement of the ship image classification and recognition method based on global attention and stripe attention, the specific method of step A4 is as follows:

[0033] Assume that the global feature extracted in step A3 is F 12 , the position encoding parameter is PE∈R M×1 , then the first classification result is:

[0034]

[0035] Among them, Softmax(·) represents the activation function that converts a set of arbitrary real numbers into real numbers representing probability distribution, and Linear(·) represents the linear layer.

[0036] As a further improvement of the ship image classification and recognition method based on global attention and stripe attention, the processing process of the attention feature extraction module is:

[0037] Step B1: Assume the input ship image is x∈R C×H×W , C is the number of image channels, H is the height of the image, and W is the width of the image; the input ship image is subjected to SSR image enhancement processing, and the enhanced image is divided into four equal parts to obtain four sub-images:

[0038] x SSR =SSR(x);

[0039]

[0040] Among them, SSR(·) represents the SSR image enhancement method,

[0041] Step B2: Calculate Convolution and dimensionality reduction operations are performed separately to meet the computational requirements of the stripe self-attention mechanism:

[0042]

[0043] Among them, Conv(·) is the convolution operation, AvgPool(·) represents the average pooling operation, and Flatten(·) represents the flattening operation.

[0044] Step B3: Set four learnable parameter matrices W V ∈R M×M ,W K ∈R M×M , W Q ∈R M×M , respectively, and perform matrix multiplication operations with features x′1, x′2, x′3, x′4 to obtain matrix:

[0045] V=WV ×x′1;

[0046] K=W K ×x′2;

[0047] A=W A ×x′3;

[0048] Q=W Q ×x′4;

[0049] Step B4: Calculate the stripe self-attention to obtain the attention feature F at :

[0050]

[0051] Among them, Softmax(·) represents an activation function that converts a set of arbitrary real numbers into real numbers representing probability distribution.

[0052] As a further improvement of the ship image classification and recognition method based on global attention and stripe attention, the feature aggregation classification module aggregates the global features and attention features in the following process:

[0053] Step C1: Concatenate global features and attention features:

[0054] Let the global feature be The attention feature is First, the attention feature F at Perform convolution operation to obtain features Then splice: F all =Concat(F at1 ,F 12 ),feature Concat(·) represents concatenation along the channel dimension;

[0055] Step C2: Feature F all Input to the NetVLAD module to get the aggregation result F all′ The NetVLAD module includes: 1 convolutional layer, 1 SoftMax activation function, 2 normalization operations, and 1 VLAD core clustering layer. The process is as follows:

[0056] F all′ =L2_Norm(IN_Norm(Softmax(Conv(F all ))×VC(F all )));

[0057] Among them, L2_Norm(·) represents the L2 normalization operation, IN_Norm(·) represents the internal normalization, Softmax(·) represents the activation function that converts a set of arbitrary real numbers into real numbers representing probability distribution, Conv(·) is the convolution operation, and VC(·) represents the VLAD core clustering layer.

[0058] As a further improvement of the ship image classification and recognition method based on global attention and stripe attention, the process of the feature aggregation classification module obtaining the second classification result is:

[0059]

[0060] Among them, Linear(·) represents the linear layer.

[0061] As a further improvement of the ship image classification and recognition method based on global attention and stripe attention, the processing process of the image representation extraction and classification module is as follows:

[0062] Step D1: Assume the attention feature is For the attention feature F at Perform two independent convolution operations with different parameters to obtain the feature F at1 and F at2 ; F at1 ,

[0063] Compute image representation F at′ :

[0064] F at′ =(F at1 ×(F at1 ×F at2 T ))+F at2 ;

[0065] Step D2: Characterize F based on the image at′ The third classification result is:

[0066]

[0067] Among them, Softmax(·) represents the activation function that converts a set of arbitrary real numbers into real numbers representing probability distribution, and Linear(·) represents the linear layer.

[0068] As a further improvement of the ship image classification and recognition method based on global attention and stripe attention, the final classification result is calculated as follows:

[0069]

[0070] in, is the first classification result, is the second classification result, is the third classification result; Y is a one-dimensional vector, representing the final classification result predicted by the classification network model; Indicates that The value of the largest element in is set to 1, and the other elements are set to 0, that is The category corresponding to the largest element in is the final classification result.

[0071] As a further improvement of the ship image classification and recognition method based on global attention and stripe attention, the specific training method of step 2 is:

[0072] Step 2-1: Obtain ship images with image labels and construct a sample dataset; each ship image and its corresponding category are recorded as Among them, X i ∈R C×H×W represents the i-th ship image, C represents the number of image channels, H represents the image height, W represents the image width, and Y i Represents the ship image X i The corresponding real category; i = 1, 2, ..., N, N represents the number of ship images;

[0073] Step 2-2: Input the ship images in the sample data set into the image classification model to obtain the first classification result, the second classification result and the third classification result; let the first classification result corresponding to the i-th ship image be The second classification results are The third classification result is

[0074] Step 2-3, calculate the cross entropy loss:

[0075]

[0076] Step 2-4, calculate the total loss function:

[0077] L total =αL1+βL2+ηL3;

[0078] Among them, α, β, and η are all preset hyperparameters;

[0079] Step 2-5: According to L total Update parameters in the classification network model;

[0080] Step 2-6: Determine whether the number of updates reaches the preset value. If not, return to step 2-2 to continue updating and optimizing. If it reaches the preset value, the training is completed.

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

[0082] The present invention first uses Swin Transformer to extract features to obtain global features, then uses the SSR (Single Scale Retinex) method to enhance the image, divides the enhanced image into four equal parts, uses the stripe self-attention mechanism to obtain the attention features for the four images, and then uses the NetVLAD method to fuse the global features and the attention features, and uses spatial attention to further extract the attention features, and finally uses the loss obtained from the above three parts of multidimensional features to perform back propagation optimization on the network model. Compared with natural images, the distribution of ships in ship images is often horizontal or vertical. Since the stripe attention proposed by the present invention only focuses on the longitudinal and lateral areas of the region, it can effectively reduce the amount of calculation, reduce parameter redundancy, and ultimately improve the accuracy of ship image classification and recognition. BRIEF DESCRIPTION OF THE DRAWINGS

[0083] Figure 1 Flow chart of the method of the present invention. DETAILED DESCRIPTION

[0084] The technical solution of the present invention is described in detail below with reference to the accompanying drawings:

[0085] like Figure 1 , a ship image classification and recognition method based on global attention and stripe attention, the steps include:

[0086] Step 1: construct an image classification model, wherein the input of the image classification model is a ship image.

[0087] Image classification models include:

[0088] 1. A global feature extraction and classification module is used to extract the global features of the input image and obtain a first classification result based on the global features.

[0089] Specifically, the processing process of the global feature extraction and classification module is as follows:

[0090] Step A1: Assume the input ship image is x∈R C×H×W , C is the number of channels of the image, H is the height of the image, and W is the width of the image; the image is divided into blocks to obtain a sequence F containing m image blocks = (x1, x2, ..., x j ,…x m ), where x j represents the jth image block, x j ∈R C×p×p, p×p represents the dimension of each image block, that is, the length of the image block is p pixels, the width is p pixels, and m = (H×W) / p 2 .

[0091] Step A2: embed the image block sequence F to obtain feature F0:

[0092] F0 = LN(Conv(F));

[0093] Among them, F0∈R m×D , Conv(·) represents the convolution operation, and LN(·) represents the normalization process.

[0094] Step A3, input feature F0 into the Transformer encoder module to obtain a global feature; the Transformer encoder includes 4 sub-modules connected in sequence, and the 4 sub-modules include 2, 2, 6, and 2 sequentially stacked processing modules in the order of connection, and each of the processing modules includes a sequentially connected Patch module and an STB module (SwinTransformer Block).

[0095] Furthermore, the specific method of step A3 is:

[0096] (1) Each Patch module converts the features input to its processing module as follows:

[0097] F t′ =Conv(LN(Flatten(Concat(Split(F t-1 )))));

[0098] Among them, F t-1 is the feature input to the processing module, the total number of processing modules is 12, t = 1, 2 ... 12; Conv (·) is a convolution operation, LN (·) is a normalization operation, Flatten (·) represents a flattening operation, Concat (·) represents a concatenation operation, and Split (·) represents a segmentation operation. Moreover, in the same submodule, the convolution operation parameters of the Patch module of the first processing module are different from the convolution operation parameters of the Patch modules of other processing modules: for the Patch module of the first processing module, the convolution operation in the formula doubles the number of channels of the input feature and reduces the number of features to one quarter, and for the Patch modules of other processing modules, the convolution operation in the formula does not change the number of channels and the number of features of the input feature.

[0099] (2) Each STB module consists of two window multi-head attention calculations, and the processing process is as follows:

[0100] F t″=LN(WMSA(F t′ ))+F t′ ;

[0101]

[0102] Among them, F t′ are the output features of the Patch module of the same processing module as the STB module, MLP(·) represents a multi-layer perceptron, WMSA(·) represents a window multi-head attention calculation, and SWMSA(·) represents a sliding window multi-head attention calculation.

[0103] The output features of the STB module of the last processing module of the last submodule in the Transformer encoder are recorded as D1=16D;F 12 This is the extracted global feature.

[0104] Step A4: Use a set of learnable position encoding parameters to perform position encoding enhancement processing on the global features, and then perform a linear transformation on the result of the position encoding enhancement processing to obtain a first classification result.

[0105] The specific method of step A4 is:

[0106] Assume that the global feature extracted in step A3 is F 12 , the position encoding parameter is PE∈R M×1 , then the first classification result is:

[0107]

[0108] Among them, Softmax(·) represents the activation function that converts a set of arbitrary real numbers into real numbers representing probability distribution, and Linear(·) represents the linear layer.

[0109] 2. Attention feature extraction module, used to extract the attention features of the input image.

[0110] Specifically, the processing process of the attention feature extraction module is:

[0111] Step B1: Assume the input ship image is x∈R C×H×W , C is the number of image channels, H is the height of the image, and W is the width of the image; the input ship image is subjected to SSR image enhancement processing, and the enhanced image is divided into four equal parts to obtain four sub-images:

[0112] x SSR =SSR(x);

[0113]

[0114] Where SSR(·) represents the SSR image enhancement method,

[0115] Step B2: Calculate Convolution and dimensionality reduction operations are performed separately to meet the computational requirements of the stripe self-attention mechanism:

[0116]

[0117] Among them, Conv(·) is the convolution operation, AvgPool(·) represents the average pooling operation, and Flatten(·) represents the flattening operation.

[0118] Step B3: Set four learnable parameter matrices W V ∈R M×M ,W K ∈R M×M , W Q ∈R M×M , respectively, and perform matrix multiplication operations with features x′1, x′2, x′3, x′4 to obtain matrix:

[0119] V=W V ×x′1;

[0120] K=W K ×x′2;

[0121] A=W A ×x′3;

[0122] Q=W Q ×x′4.

[0123] Step B4: Calculate the stripe self-attention to obtain the attention feature F at :

[0124]

[0125] Among them, Softmax(·) represents an activation function that converts a set of arbitrary real numbers into real numbers representing probability distribution.

[0126] 3. Feature aggregation classification module, used to aggregate global features and attention features, and obtain the second classification result based on the aggregation result.

[0127] Specifically, the feature aggregation classification module aggregates the global features and attention features in the following process:

[0128] Step C1: Concatenate global features and attention features:

[0129] Let the global feature be The attention feature is First, the attention feature F at Perform convolution operation to obtain features Then splice: F all =Concat(F at1 ,F 12 ),feature Concat(·) represents concatenation along the channel dimension.

[0130] Step C2: Feature F all Input to the NetVLAD module to get the aggregation result F all′ The NetVLAD module includes: 1 convolutional layer, 1 SoftMax activation function, 2 normalization operations, and 1 VLAD core clustering layer. The process is as follows:

[0131] F all′ =L2_Norm(IN_Norm(Softmax(Conv(F all ))×VC(F all )));

[0132] Among them, L2_Norm(·) represents the L2 normalization operation, IN_Norm(·) represents the internal normalization, Softmax(·) represents the activation function that converts a set of arbitrary real numbers into real numbers representing probability distribution, Conv(·) is the convolution operation, and VC(·) represents the VLAD core clustering layer.

[0133] Furthermore, the process of the feature aggregation classification module obtaining the second classification result is:

[0134]

[0135] Among them, Linear(·) represents the linear layer.

[0136] 4. An image representation extraction and classification module is used to obtain image representation based on attention features and obtain a third classification result based on the image representation.

[0137] Specifically, the processing process of the image representation extraction and classification module is as follows:

[0138] Step D1: Assume the attention feature is For the attention feature F at Perform two independent convolution operations with different parameters to obtain the feature F at1 (already obtained in the previous article) and F at2 ; F at1 ,

[0139] Compute image representation F at′ :

[0140] F at′ =(F at1 ×(F at1 ×F at2 T ))+F at2 .

[0141] Step D2: Characterize F based on the image at′ The third classification result is:

[0142]

[0143] Among them, Softmax(·) represents the activation function that converts a set of arbitrary real numbers into real numbers representing probability distribution, and Linear(·) represents the linear layer.

[0144] The output of the image classification model is the final classification result obtained based on the first classification result, the second classification result and the third classification result. The calculation method of the final classification result is:

[0145]

[0146] in, is the first classification result, is the second classification result, is the third classification result; Y is a one-dimensional vector, representing the final classification result predicted by the classification network model; Indicates that The value of the largest element in is set to 1, and the other elements are set to 0, that is The category corresponding to the largest element in is the final classification result.

[0147] Step 2: Train the image classification model.

[0148] The specific training methods are:

[0149] Step 2-1: Obtain ship images with image labels and construct a sample dataset; each ship image and its corresponding category are recorded as Among them, X i ∈R C×H×W represents the i-th ship image, C represents the number of image channels, H represents the image height, W represents the image width, and Y i Represents the ship image X i The corresponding true category; i = 1, 2, ..., N, where N represents the number of ship images.

[0150] Step 2-2: Input the ship images in the sample data set into the image classification model to obtain the first classification result, the second classification result and the third classification result; let the first classification result corresponding to the i-th ship image be The second classification results are The third classification result is

[0151] Step 2-3, calculate the cross entropy loss:

[0152]

[0153] Step 2-4, calculate the total loss function:

[0154] L total =αL1+βL2+ηL3;

[0155] Wherein α, β, and η are all preset hyperparameters. In this embodiment, α is set to 0.4, β is set to 0.2, and η is set to 0.4.

[0156] Step 2-5: According to L total Update parameters in a classification network model.

[0157] Step 2-6: Determine whether the number of updates reaches the preset value. If not, return to step 2-2 to continue updating and optimizing. If it reaches the preset value, the training is completed.

[0158] In this embodiment, the Adam optimizer is used to optimize and solve the loss function, thereby adjusting the parameters of the network model and obtaining the optimal network model for analyzing remote sensing scene images to achieve image classification.

[0159] Step 3: Input the ship image to be classified into the trained image classification model to obtain the final classification result.

Claims

1. A ship image classification and recognition method based on global attention and stripe attention, characterized in that the steps include: Step 1: construct an image classification model, wherein the input of the image classification model is a ship image; Image classification models include: A global feature extraction and classification module, used to extract the global features of the input image and obtain a first classification result based on the global features; An attention feature extraction module, used to extract attention features of the input image; A feature aggregation classification module is used to aggregate the global features and the attention features, and obtain a second classification result based on the aggregation result; An image representation extraction and classification module, used to obtain an image representation based on the attention feature, and obtain a third classification result based on the image representation; The output of the image classification model is a final classification result obtained based on the first classification result, the second classification result and the third classification result; Step 2: Train the image classification model; Step 3: Input the ship image to be classified into the trained image classification model to obtain the final classification result; The processing process of the global feature extraction and classification module is as follows: Step A1: Assume the input ship image is x∈R C×H×W , C is the number of channels of the image, H is the height of the image, and W is the width of the image; the image is divided into blocks to obtain a sequence F containing m image blocks = (x1, x2, ..., x j ,…x m ), where x j represents the jth image block, x j ∈R C×p×p , p×p represents the dimension of each image block, that is, the length of the image block is p pixels, the width is p pixels, and m = (H×W) / p 2 ; Step A2: embed the image block sequence F to obtain feature F0: F0 = LN(Conv(F)); Among them, F0∈R m×D , Conv(·) represents the convolution operation, and LN(·) represents the normalization process; Step A3, inputting feature F0 into the Transformer encoder module to obtain a global feature; the Transformer encoder includes 4 sub-modules connected in sequence, and the 4 sub-modules include 2, 2, 6, and 2 sequentially stacked processing modules in the order of connection, and each of the processing modules includes a Patch module and an STB module connected in sequence; The specific method of step A3 is: Each Patch module converts the features input to its processing module as follows: F t′ =Conv(LN(Flatten(Concat(Split(F t-1 ))))); Among them, F t-1 is the feature input to the processing module, the total number of processing modules is 12, t = 1, 2 ... 12; Conv (·) is a convolution operation, LN (·) is a normalization operation, Flatten (·) represents a flattening operation, Concat (·) represents a concatenation operation, and Split (·) represents a segmentation operation; and in the same submodule, the convolution operation parameters of the Patch module of the first processing module are different from the convolution operation parameters of the Patch modules of other processing modules: for the Patch module of the first processing module, the convolution operation in the formula doubles the number of channels of the input feature and reduces the number of features to one quarter, and for the Patch modules of other processing modules, the convolution operation in the formula does not change the number of channels and the number of features of the input feature; Each STB module consists of two window multi-head attention calculations, and the processing process is as follows: F t″ =LN(WMSA(F t′ ))+F t′ ; Among them, F t′ is the output feature of the Patch module of the same processing module as the STB module, MLP(·) represents multi-layer perceptron, WMSA(·) represents window multi-head attention calculation, and SWMSA(·) represents sliding window multi-head attention calculation; The output features of the STB module of the last processing module of the last submodule in the Transformer encoder are recorded as D1=16D;F 12 That is the extracted global feature; Step A4: using a set of learnable position encoding parameters to perform position encoding enhancement processing on the global features, and then performing a linear transformation on the result of the position encoding enhancement processing to obtain a first classification result; The specific method of step A4 is: Assume that the global feature extracted in step A3 is F 12 , the position encoding parameter is PE∈R M×1 , then the first classification result is: Among them, Softmax(·) represents the activation function that converts a set of arbitrary real numbers into real numbers representing probability distribution, and Linear(·) represents the linear layer; The processing process of the attention feature extraction module is: Step B1: Assume the input ship image is x∈R C×H×W , C is the number of image channels, H is the height of the image, and W is the width of the image; the input ship image is subjected to SSR image enhancement processing, and the enhanced image is divided into four equal parts to obtain four sub-images: x SSR =SSR(x); Among them, SSR(·) represents the SSR image enhancement method, Step B2: Calculate Convolution and dimensionality reduction operations are performed separately to meet the computational requirements of the stripe self-attention mechanism: Among them, Conv(·) is the convolution operation, AvgPool(·) represents the average pooling operation, and Flatten(·) represents the flattening operation. Step B3: Set four learnable parameter matrices W V ∈R M×M ,W K ∈R M×M , W Q ∈R M×M , respectively, and perform matrix multiplication operations with features x′1, x′2, x′3, x′4 to obtain matrix: V=W V ×x′1; K=W K ×x′2; A=W A ×x′3; Q=W Q ×x′4; Step B4: Calculate the stripe self-attention to obtain the attention feature F at : Among them, Softmax(·) represents an activation function that converts a set of arbitrary real numbers into real numbers representing probability distribution. The feature aggregation classification module aggregates the global features and attention features in the following process: Step C1: Concatenate global features and attention features: Let the global feature be The attention feature is First, the attention feature F at Perform convolution operation to obtain features Then splice: F all =Concat(F at1 ,F 12 ),feature Concat(·) represents concatenation along the channel dimension; Step C2: Feature F all Input to the NetVLAD module to get the aggregation result F all′ The NetVLAD module includes: 1 convolutional layer, 1 SoftMax activation function, 2 normalization operations, and 1 VLAD core clustering layer. The process is as follows: F all′ =L2_Norm(IN_Norm(Softmax(Conv(F all ))×VC(F αll ))); Among them, L2_Norm(·) represents the L2 normalization operation, IN_Norm(·) represents the internal normalization, Softmax(·) represents the activation function that converts a set of arbitrary real numbers into real numbers representing probability distribution, Conv(·) is the convolution operation, and VC(·) represents the VLAD core clustering layer; The process of the feature aggregation classification module obtaining the second classification result is as follows: Among them, Linear(·) represents the linear layer; The processing process of the image representation extraction and classification module is as follows: Step D1: Assume the attention feature is For the attention feature F at Perform two independent convolution operations with different parameters to obtain the feature F at1 and F at2 ; Compute image representation F at′ : F at′ =(F at1 ×(F at1 ×F at2 T ))+F at2 ; Step D2: Characterize F based on the image at′ The third classification result is: Among them, Softmax(·) represents the activation function that converts a set of arbitrary real numbers into real numbers representing probability distribution, and Linear(·) represents the linear layer.

2. The ship image classification and recognition method based on global attention and stripe attention as claimed in claim 1, characterized in that: The final classification result is calculated as: in, is the first classification result, is the second classification result, is the third classification result; Y is a one-dimensional vector, representing the final classification result predicted by the classification network model; Indicates that The value of the largest element in is set to 1, and the other elements are set to 0, that is The category corresponding to the largest element in is the final classification result.

3. The ship image classification and recognition method based on global attention and stripe attention as claimed in claim 1 or 2, characterized in that: The specific training method for step 2 is: Step 2-1: Obtain ship images with image labels and construct a sample dataset; each ship image and its corresponding category are recorded as Among them, X i ∈R C×H×W represents the i-th ship image, C represents the number of image channels, H represents the image height, W represents the image width, and Y i Represents the ship image X i The corresponding real category; i = 1, 2, ..., N, N represents the number of ship images; Step 2-2: Input the ship images in the sample data set into the image classification model to obtain the first classification result, the second classification result and the third classification result; let the first classification result corresponding to the i-th ship image be The second classification results are The third classification result is Step 2-3, calculate the cross entropy loss: Step 2-4, calculate the total loss function: L total =αL1+βL2+ηL3; Among them, α, β, and η are all preset hyperparameters; Step 2-5: According to L total Update parameters in the classification network model; Step 2-6: Determine whether the number of updates reaches the preset value. If not, return to step 2-2 to continue updating and optimizing. If it reaches the preset value, the training is completed.

Citation Information

Patent Citations

  • Image classification method, device and equipment and readable storage medium

    CN116206159A