Hyperspectral image classification method, device and electronic equipment
By improving the SegNet feature extraction network and combining transfer learning and contrastive learning, the problems of limited receptive fields and redundant calculations in small sample hyperspectral image classification are solved, the classification accuracy and reasoning speed are improved, and the classification accuracy in a small number of labeled samples is achieved. Efficient feature extraction.
Patent Information
- Application Number
- CN202410962597.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-07-18
AI Technical Summary
Existing small-sample hyperspectral image classification methods are based on image block input, resulting in limited network receptive fields and redundant calculations, and too few labeled samples lead to insufficient feature information and substandard classification accuracy.
Improve the SegNet feature extraction network, add the fusion lateral connection module and ASPP-PA module, and train the model through a combination of transfer learning, global prototype representation learning strategy and supervised contrastive learning to extract the spatial spectrum features of hyperspectral images.
It improves the prediction accuracy and reasoning speed of the model, can extract more information from a small number of labeled samples, and performs better than traditional methods in terms of classification accuracy and computational efficiency.
Smart Images

Figure CN118506111B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a hyperspectral image classification method, device and electronic equipment. Background Art
[0002] At present, the input of hyperspectral image classification methods in small sample scenarios is based on image blocks, which not only limits the network receptive field, but also generates a large amount of redundant calculations, resulting in a decrease in model inference speed. In addition, due to the small number of labeled samples of hyperspectral images, the model will not be able to extract sufficient feature information from the labeled samples, ultimately resulting in the classification accuracy failing to meet the standards for practical applications. Summary of the invention
[0003] The purpose of this application is to provide a hyperspectral image classification method, device and electronic device, improve the architecture of the SegNet feature extraction network, add a fusion lateral connection module and an ASPP-PA module, and train the model by combining transfer learning, global prototype representation learning strategy and supervised contrast learning, and improve the prediction accuracy of the model.
[0004] In a first aspect, the present application provides a hyperspectral image classification method, the method comprising: obtaining a hyperspectral image to be classified; inputting the hyperspectral image into an image classification model to obtain a classification result corresponding to the hyperspectral image; wherein the image classification model is a classification model based on an improved global prototype segmentation framework trained by transfer learning; the improved global prototype segmentation framework comprises: a SegNet feature extraction network optimized based on an improved global prototype representation learning strategy and a nearest neighbor algorithm classification network; the improved global prototype representation learning strategy comprises: a global prototype representation learning strategy introducing supervised contrastive learning; the SegNet feature extraction network comprises: an encoder network, a fused lateral connection module, an ASPP-PA module, and a decoder network; the SegNet feature extraction network is used to extract spatial spectral features of hyperspectral images; the spatial spectral features comprise feature vectors corresponding one-to-one to each pixel in the hyperspectral image.
[0005] Furthermore, the transfer learning training process of the above-mentioned image classification model includes: obtaining a training sample set; pre-training the SegNet feature extraction network using a source domain data set including a specified number of labeled samples in the training sample set; fine-tuning the pre-trained network using a target domain data set including a small number of labeled samples; wherein the steps of pre-training and fine-tuning are the same, and when fine-tuning the network, some parameters of the encoder in the pre-trained SegNet feature extraction network are retained; after the network fine-tuning training is completed, the nearest neighbor algorithm classification network is used for classification to obtain an image classification model.
[0006] Furthermore, the improved global prototype representation learning strategy used in the pre-training and fine-tuning process includes: for each round of training data sets, extracting labeled samples therein and dividing them into a support set and a query set; processing the support set based on a supervised contrastive learning method; averaging the feature vectors of all labeled samples of each category in the data set to obtain a global prototype representation feature vector for each category; averaging the feature vectors of samples of each category in the support set to obtain a scenario prototype representation feature vector for each category; calculating the cross entropy loss between the scenario prototype representation feature vector and the global prototype representation feature vector to obtain the support set loss; updating the global prototype representation feature vector through the similarity between the scenario prototype representation feature vector and the global prototype representation feature vector; calculating the cross entropy loss between the query set samples and the updated global prototype representation feature vector to obtain the query set loss; calculating the noise contrast estimation loss between the support set samples to obtain the contrast loss; summing the support set loss, the query set loss and the contrast loss to obtain the total model loss; and updating the model network parameters based on the total model loss.
[0007] Furthermore, the above-mentioned supervised contrastive learning processing method includes: dividing the support set samples into two groups, respectively , Indicates that Subscript Indicates group A, represents group B, and the superscript represents the category number. Each group has only one sample per category, and the two groups of samples do not intersect with each other. In supervised contrastive learning, two samples with the same category in the two support sets form a positive sample pair. Supervised contrastive learning is implemented through the InfoNCE loss function. and The loss function based on InfoNCE It can be expressed as:
[0008] ;
[0009] in Used to indicate and The similarity of is the temperature coefficient; the existence of the denominator of the loss function makes , therefore, the total contrast loss in a scene training is It is expressed as:
[0010] ;
[0011] The total loss in one training scenario It is expressed as:
[0012] ;
[0013] in, is a hyperparameter, The larger the value, the greater the contrast loss during back propagation. It will have greater weight.
[0014] Furthermore, the encoder network includes 4 encoder basic blocks and 3 maximum pooling downsampling networks; the encoder basic block includes a 1x1 convolution layer, a residual block, a spectral attention module and a 3x3 convolution layer; the 1x1 convolution layer is used to adjust the dimension of the feature map; the residual block is used to extract the spatial information of the hyperspectral image; the spectral attention module is used to extract the spectral information of the hyperspectral image; the 3x3 convolution layer is used to integrate the extracted feature information; group normalization is used in each encoder basic block; a fusion horizontal connection module is used to fuse the three feature maps output by the three encoder basic blocks before each downsampling with the feature map of the corresponding upsampling output, wherein the 1x1 convolution layer is used to adjust the dimension of the feature map output by the encoder basic block so that it is consistent with the shape of the feature map of the corresponding upsampling output; the decoder network includes: 3 decoder basic blocks ; The operation flow of each decoder basic block is as follows: the input feature map with higher dimensional spatial spectral information is upsampled by 2 times using bilinear interpolation; it is added and fused with the feature map with finer spatial spectral information output by the fused lateral connection to restore the spatial details of the input; the fused feature information is extracted through a 3x3 convolution layer; the ASPP-PA module includes: a series of atrous spatial convolution pooling pyramid ASPP module and a position attention PA module; the ASPP module obtains feature information of different scales in the spatial dimension by performing atrous convolution operations with different expansion rates and global pooling operations on the input feature map, and fuses the feature information of different scales through addition operations to obtain a fused feature map; the PA module obtains the dependency of the spatial position of the same scale in the fused feature map through self-attention operations to output the final feature map.
[0015] Furthermore, the ASPP module outputs the fused feature map according to the following formula:
[0016] ;
[0017] in, represents the input feature map, represents a fused feature map with multi-scale information, Represents 4 dilated convolution operations, represents the global average pooling operation, and There are 5 learnable parameters, and their initialization values are all 1.
[0018] Furthermore, the above-mentioned PA module is also used to: perform shape transformation on the fused feature map output by ASPP through a convolutional layer to generate a first feature mapping matrix, a second feature mapping matrix and a third feature mapping matrix; multiply the first feature mapping matrix and the second feature mapping matrix, and process them through a softmax function to obtain a spatial position attention map; multiply the third feature mapping matrix with the spatial position attention map, multiply it by a variable parameter, and then add it element by element with the fused feature map to obtain a final feature map.
[0019] In a second aspect, the present application also provides a hyperspectral image classification device, which includes: an image acquisition module for acquiring a hyperspectral image to be classified; a classification module for inputting the hyperspectral image into an image classification model to obtain a classification result corresponding to the hyperspectral image; wherein the image classification model is a classification model based on an improved global prototype segmentation framework trained by transfer learning; the improved global prototype segmentation framework includes: a SegNet feature extraction network optimized based on an improved global prototype representation learning strategy and a nearest neighbor algorithm classification network; the improved global prototype representation learning strategy includes: a global prototype representation learning strategy that introduces supervised contrast learning; the SegNet feature extraction network is used to extract spatial-spectral features of hyperspectral images; the spatial-spectral features include feature vectors that correspond one-to-one to each pixel in the hyperspectral image.
[0020] In a third aspect, the present application further provides an electronic device, comprising a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method described in the first aspect above.
[0021] In a fourth aspect, the present application further provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the method described in the first aspect above.
[0022] In the hyperspectral image classification method, device and electronic device provided by the present application, the image classification model is a classification model based on an improved global prototype segmentation framework trained by transfer learning; the improved global prototype segmentation framework includes: a SegNet feature extraction network optimized based on an improved global prototype representation learning strategy and a nearest neighbor algorithm classification network; the improved global prototype representation learning strategy includes: a global prototype representation learning strategy introducing supervised contrast learning; the SegNet feature extraction network includes: an encoder network, a fusion lateral connection module, an ASPP-PA module, and a decoder network; the SegNet feature extraction network is used to extract the spatial spectrum features of the hyperspectral image; the spatial spectrum features include a feature vector corresponding to each pixel point in the hyperspectral image. First, the hyperspectral image to be classified is obtained; then the hyperspectral image is input into the image classification model trained by the above method, so that the prediction accuracy of the classification result corresponding to the obtained hyperspectral image can be higher; that is, the present application improves the architecture of the SegNet feature extraction network, adds a fusion lateral connection module and an ASPP-PA module, and trains the model by combining transfer learning, global prototype representation learning strategy and supervised contrast learning, and can improve the prediction accuracy of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0024] Figure 1 A schematic diagram of overlapping adjacent image blocks in the prior art provided in an embodiment of the present application;
[0025] Figure 2 A flowchart of a hyperspectral image classification method provided in an embodiment of the present application;
[0026] Figure 3 A schematic diagram of an AGPS framework provided in an embodiment of the present application;
[0027] Figure 4 A SegNet feature extraction network architecture diagram provided for an embodiment of the present application;
[0028] Figure 5 An ASPP-PA module architecture diagram provided for an embodiment of the present application;
[0029] Figure 6An OA evolution diagram with the number of retained dimensions and an OA evolution diagram with the value of the contrast loss coefficient provided in an embodiment of the present application;
[0030] Figure 7 A structural block diagram of a hyperspectral image classification device provided in an embodiment of the present application;
[0031] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] The technical solution of the present application will be described clearly and completely below in conjunction with the embodiments. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0033] The input of existing methods for classifying small sample hyperspectral images is based on image blocks. They divide the hyperspectral image into image blocks according to pixels and use the image blocks as the input of the network, such as Figure 1 The image blocks generated by adjacent pixels are overlapped. The pixels in the light gray area are both the domain pixels of the t1 image block and the domain pixels of the t2 image block. Therefore, the pixels in this area will participate in multiple calculations, resulting in a large amount of computational redundancy. In addition, the size of the image block will limit the receptive field of the entire network, which will hinder the connection between distant pixels. At present, the input of the hyperspectral image classification method in small sample scenarios is based on image blocks, which not only limits the network receptive field, but also generates a large amount of redundant calculations, resulting in a decrease in the model inference speed. In addition, due to the small number of labeled samples of hyperspectral images, the model will not be able to extract enough feature information from the labeled samples, which ultimately leads to the classification accuracy not meeting the standards for practical applications.
[0034] Based on this, the embodiments of the present application provide a hyperspectral image classification method, device and electronic device, which improve the architecture of the SegNet feature extraction network, add a fusion lateral connection module and an ASPP-PA module, and train the model by combining transfer learning, global prototype representation learning strategy and supervised comparative learning, and can improve the prediction accuracy of the model.
[0035] To facilitate understanding of this embodiment, a hyperspectral image classification method disclosed in an embodiment of the present application is first introduced in detail.
[0036] Figure 2 A flowchart of a hyperspectral image classification method provided in an embodiment of the present application, the method comprising the following steps:
[0037] Step S202, obtaining a hyperspectral image to be classified;
[0038] Step S204, input the hyperspectral image into the image classification model to obtain the classification result corresponding to the hyperspectral image; wherein the image classification model is a classification model based on the improved global prototype segmentation framework trained by transfer learning; the improved global prototype segmentation framework includes: a SegNet feature extraction network optimized based on an improved global prototype representation learning strategy and a nearest neighbor algorithm classification network; the improved global prototype representation learning strategy includes: a global prototype representation learning strategy introducing supervised contrastive learning; the SegNet feature extraction network includes: an encoder network, a fused lateral connection module, an ASPP-PA module, and a decoder network; the SegNet feature extraction network is used to extract the spatial spectral features of the hyperspectral image; the spatial spectral features include a feature vector corresponding to each pixel in the hyperspectral image.
[0039] In the hyperspectral image classification method provided in the embodiment of the present application, an improved global prototype segmentation framework (Advanced Global Prototypical Segmentation, referred to as AGPS) is proposed. In view of the shortcomings of computational redundancy and insufficient feature extraction caused by image block feature extraction in the prior art, the AGPS framework adopts SegNet based on the encoder-decoder architecture as a feature extractor. Its input is the entire hyperspectral image and it is a forward calculation that will not be limited by the size of the image block. The network receptive field and redundant calculation will not be generated. In order to effectively extract features at different levels, SegNet also introduces the ASPP-PA module and fused lateral connections to improve the performance of the feature extractor. In view of the problem of fewer labeled samples in hyperspectral images, the idea of transfer learning is used in this embodiment to train the network and an improved global prototype representation learning strategy is adopted. Supervised contrast learning is introduced in the improved global prototype representation learning strategy. Since contrast learning uses positive and negative sample pairs for training, more information can be extracted from a small number of labeled samples to optimize the network.
[0040] Furthermore, the transfer learning training process of the above image classification model includes:
[0041] (1) Obtain a training sample set;
[0042] (2) Use the source domain dataset that includes a specified number of labeled samples in the training sample set to pre-train the SegNet feature extraction network;
[0043] (3) Fine-tune the pre-trained network using a target domain dataset that includes a small number of labeled samples. The pre-training and fine-tuning steps are the same. When fine-tuning the network, some parameters of the encoder in the pre-trained SegNet feature extraction network are retained. After the network fine-tuning training is completed, the nearest neighbor algorithm classification network is used for classification to obtain an image classification model.
[0044] In specific implementation, the network can be pre-trained using a source domain dataset with sufficient labeled samples, i.e., a training set, and then the pre-trained network can be fine-tuned using a target domain dataset with only a small number of labeled samples, i.e., a test set. The steps of pre-training and fine-tuning are the same, but when fine-tuning the network, the parameters of the encoder basic blocks #1 and 2 in the pre-trained SegNet need to be retained, such as Figure 3 As shown in . After the network fine-tuning training is completed, the nearest neighbor (NN) algorithm can be used for classification, that is, the feature vector of the unlabeled sample point after SegNet mapping is directly calculated with the trained global prototype representation of each category for similarity calculation (or Euclidean distance), and the category of the global prototype representation that is most similar (or closest) to the sample point is selected as the predicted category of the sample.
[0045] Furthermore, the improved global prototype representation learning strategy used in the pre-training and fine-tuning process includes:
[0046] For each round of training data set, the labeled samples are extracted and divided into a support set and a query set; the support set is processed based on a supervised contrastive learning method; the feature vectors of all labeled samples of each category in the data set are averaged to obtain the global prototype representation feature vector of each category; the feature vectors of samples of each category in the support set are averaged to obtain the scenario prototype representation feature vector of each category; the cross entropy loss between the scenario prototype representation feature vector and the global prototype representation feature vector is calculated to obtain the support set loss; the global prototype representation feature vector is updated through the similarity between the scenario prototype representation feature vector and the global prototype representation feature vector; the cross entropy loss between the query set samples and the updated global prototype representation feature vector is calculated to obtain the query set loss; the noise contrast estimation loss between the support set samples is calculated to obtain the contrast loss; the support set loss, query set loss and contrast loss are summed to obtain the total model loss; based on the total model loss, the model network parameters are updated.
[0047] In specific implementation, the improved global prototype representation learning strategy optimizes the feature extractor by calculating the total loss. The specific approach is: in each round of training, randomly extract the labeled samples in the data set and divide them into the support set and the query set. The feature vectors of all labeled samples of each category in the data set are averaged to obtain the global prototype representation feature vector of each category, and the feature vectors of samples of each category in the support set are averaged to obtain the scenario prototype representation feature vector of each category. The support set loss can be obtained by calculating the cross entropy loss between the scenario prototype representation feature vector and the global prototype representation feature vector. Then, the global prototype representation feature vector is updated by the similarity between the scenario prototype representation feature vector and the global prototype representation feature vector. The query set loss can be obtained by calculating the cross entropy loss between the query set samples and the updated global prototype representation feature vector. , the contrast loss is obtained by calculating the noise contrast estimation loss between the support set samples Therefore, the total loss in a scenario training is that is, , and The sum of the total loss is finally used to update the network parameters.
[0048] See also Figure 3 As shown in the figure, the improved global prototype segmentation framework AGPS framework consists of two parts: SegNet and improved global prototype representation learning strategy.
[0049] The above-mentioned SegNet feature extraction network includes: encoder network, fusion lateral connection module, ASPP-PA module, and decoder network; SegNet, as the feature extractor of the AGPS framework, is responsible for extracting the spatial-spectral features of the hyperspectral image. SegNet will generate a feature vector for each pixel point of the hyperspectral image. The final output feature map has the same size as the hyperspectral image, and each feature vector of the feature map corresponds to the pixel point at the corresponding position of the original hyperspectral image.
[0050] In the AGPS framework, the embodiment of the present application provides a SegNet feature extraction network based on an encoding-decoding architecture, including: an encoder network, a fusion lateral connection module, an ASPP-PA module, and a decoder network; the original hyperspectral image is directly input into the SegNet feature extraction network after dimension reduction by principal component analysis (PCA). The core idea of the SegNet feature extraction network is to replace fixed image blocks with the receptive field of the model, avoid redundant calculations in overlapping areas, and obtain more extensive spatial context information. Its goal is to be able to learn a mapping function: : → ( is the original hyperspectral image dimension, is the dimension of the feature map output by SegNet), mapping the hyperspectral image to a feature space that is easy to classify. Among them, the encoder is responsible for extracting the spatial-spectral features of the hyperspectral image. The ASPP-PA module connects the atrous spatial convolution pooling pyramid and the position attention module in series. Passing the feature map output by the encoder through the ASPP-PA module can make the feature map have both multi-scale information and spatial position information. The decoder gradually restores the size of the feature map to the size of the original hyperspectral image by adding and fusing the spatial-spectral feature information of the hyperspectral image transmitted by the fusion lateral connection with the feature map after upsampling. Finally, each pixel of the original hyperspectral image corresponds to the feature vector of the corresponding position of the final feature map output by the decoder, and the feature vector is used for the final classification of the pixel. The structure of SegNet is as follows Figure 4 As shown, each module will be introduced in detail below.
[0051] (1) Encoder network: It includes 4 encoder basic blocks and 3 maximum pooling downsampling networks; the encoder basic block includes a 1x1 convolution layer, a residual block, a spectral attention module (SE Block) and a 3x3 convolution layer; the 1x1 convolution layer is used to adjust the dimension of the feature map; the residual block is used to extract the spatial information of the hyperspectral image; the spectral attention module is used to extract the spectral information of the hyperspectral image; the 3x3 convolution layer is used to integrate the extracted feature information; group normalization is used in each encoder basic block;
[0052] The residual block is responsible for extracting the spatial information of the hyperspectral image. Its structure is Figure 4It is shown in Figure 2 that the residual structure can effectively prevent the problem of gradient disappearance and improve the performance of the neural network. It should be noted that since the input of SegNet is a whole hyperspectral image, batch normalization (BN) cannot be used. Group normalization (GN) is used here as an alternative to BN. It is independent of the batch size and can achieve performance comparable to BN. The SE block spectral attention module is mainly used to extract the spectral information of the hyperspectral image. The specific operation is to first encode the entire spatial feature on a spectral channel into a global feature through global average pooling (GAP), and then pass the global features of all dimensions through two fully connected layers (FC). The first fully connected layer compresses c channels to c / r (r can be set to 16 in this embodiment), and the second one restores the number of channels to c, so as to obtain the weight of each channel. Finally, these weights are multiplied with the corresponding channels of the original feature map to give greater weight to important channels, thereby increasing the model's attention to these important channels. The 3x3 convolution layer is used to integrate the extracted feature information.
[0053] (2) Fusion Horizontal Connection Module: It is used to fuse the three feature maps output by the three encoder basic blocks before each downsampling with the feature maps of the corresponding upsampling output. The 1x1 convolution layer is used to adjust the dimension of the feature map output by the encoder basic block to keep it consistent with the shape of the feature map of the corresponding upsampling output.
[0054] The feature map output after upsampling in the decoder network has deeper features, but these features are not sufficient to support the classification of each pixel of the hyperspectral image. The feature map output by the shallow convolution layer in the encoder network contains rich detail features. Fusion of these detail features with deep features can greatly improve the accuracy of the entire network classification. Unlike ordinary 3D images, each pixel of a hyperspectral image contains a large amount of information. Therefore, in order to allow the feature map output by upsampling in the decoder to fuse more underlying detail information, the fusion lateral connection module proposed in the embodiment of the present application fuses the three feature maps output by the basic module in the encoder network before each downsampling with the feature map of the corresponding upsampling output, where the 1x1 convolution layer is to adjust the dimension of the feature map output by the basic module of the encoder so that it is consistent with the shape of the feature map of the corresponding upsampling output. The operational logic of the fusion lateral connection module can be expressed as:
[0055] (1)
[0056] in, Representing a decoder basic block# The fused feature map, Representing a decoder basic block# The output of the upsampling layer, It represents the encoder basic block# Middle The output of a module.
[0057] (3) Decoder network: It includes three decoder basic blocks. The operation flow of each decoder basic block is as follows: the input feature map with higher dimensional spatial spectrum information is upsampled by 2 times using bilinear interpolation; it is added and fused with the feature map with finer spatial spectrum information output by the fusion lateral connection to restore the spatial details of the input; and the fused feature information is extracted through a 3x3 convolution layer.
[0058] Unlike the decoder in the previous segmentation network, the decoder network proposed in the embodiment of the present application is not used to directly predict the pixel category, but is only used as a part of the feature extraction network. Similar to the encoder network, the decoder network also adopts a modular design. The decoder network consists of three decoder basic blocks. Figure 4 The basic block flow of the decoder network is as follows: first, the input feature map with higher-dimensional spatial spectral information is upsampled by 2 times using bilinear interpolation, and then fused with the feature map with finer spatial spectral information output by the fusion lateral connection by addition to restore the input spatial details, and finally a 3x3 convolution layer is used to extract the fused feature information.
[0059] (4) ASPP-PA module: It includes a serially connected atrous spatial convolutional pooling pyramid ASPP module and a position attention PA module. The ASPP module obtains feature information of different scales in the spatial dimension by performing atrous convolution operations with different dilation rates and global pooling operations on the input feature map, and fuses the feature information of different scales through addition operations to obtain a fused feature map. The PA module obtains the dependency relationship of the spatial position of the same scale in the fused feature map through self-attention operations to output the final feature map.
[0060] In this embodiment, the Atrous Spatial Pyramid Pooling (ASPP) module and the Position attention (PA) module are connected in series to form an ASPP-PA module. The ASPP module obtains spatial context information of multiple scales through dilated convolution operations with different dilation rates. Compared with ordinary convolution, dilated convolution introduces holes (dilation rates) in the convolution kernel to increase the receptive field size of the convolution kernel, so that the network can obtain a larger perception range without increasing parameters and computational complexity. The PA module obtains the dependency relationship of the same scale spatial position in the feature map through self-attention operations. Therefore, after passing through the ASPP-PA module, the feature map will contain both multi-scale information and spatial position information.
[0061] The ASPP module is used to capture spatial context information at different scales in the feature map, thereby enhancing the model's ability to understand the semantics of hyperspectral images. Figure 5 As shown in the figure, the ASPP module obtains feature information of different scales in the spatial dimension by performing dilated convolution operations and global pooling operations on the feature map with different expansion rates, and finally fuses this information through addition operations. , then the feature map S with multi-scale information after being processed by the ASPP module is expressed as follows:
[0062] (2)
[0063] in, , Represents 4 dilated convolution operations, It represents the global average pooling operation, and There are five learnable parameters, and their initialization values are all 1. Due to the setting of learnable parameters, the ASPP module can give greater weight to important scale information when extracting multi-scale information.
[0064] It should be noted that unlike ordinary convolution, although the dilated convolution can increase the size of the receptive field obtained in the original image without reducing the spatial resolution, and obtain long-distance information. However, during the dilated convolution calculation, due to the filling of 0 pixel values, not all pixels in the feature map are involved in the calculation. Therefore, continuous convolution calculations using dilated convolutions of the same size will lose the continuity of information in the original image. When the constraint relationship between a set of dilated convolution expansion rate values is that the greatest common divisor does not exceed 1, all pixels in the feature map can be involved in the calculation, thereby avoiding information loss. Therefore, in this embodiment, the expansion rates of the four dilated convolution operations are set to [1, 2, 3, 5] respectively.
[0065] The ASPP module can only capture spatial context information of different scales, but cannot obtain the dependency of spatial positions of the same scale. In order to obtain the position information of the same scale space, in this embodiment, a position attention (PA) module is connected in series after the ASPP module. The PA module encodes more extensive context information into local features, thereby improving its representation ability.
[0066] The PA module transforms the shape of the fused feature map output by ASPP through a convolutional layer to generate the first feature mapping matrix, the second feature mapping matrix and the third feature mapping matrix; the first feature mapping matrix and the second feature mapping matrix are multiplied and processed through a softmax function to obtain a spatial position attention map; the third feature mapping matrix is multiplied by the spatial position attention map, multiplied by a variable parameter, and then added element by element to the fused feature map to obtain the final feature map.
[0067] When implementing it, Figure 5 As shown, first, the output of ASPP (feature map integrating multi-scale information) Input into the convolutional layer and perform shape transformation to generate two new feature mapping matrices and ,in , , = is the number of pixels in the feature map, and then the new feature mapping matrix and Multiply and pass through a softmax function to get the spatial position attention map :
[0068] (3)
[0069] Representation feature map Middle Position to The more similar the feature representations of the two positions are, The bigger it is.
[0070] Afterwards, Input convolutional layer generates new feature map matrix , it should be noted that although , , are generated in the same way, but due to the generation , , When each 1x1 convolution parameter is different, so , , are not exactly the same. The new feature map matrix Attention map with spatial position The shape of the multiplied feature map is restored to the original feature map The shape of , multiplying it by the variable parameter After and original feature map The final feature map can be obtained by adding element by element :
[0071] (4)
[0072] in, are learnable parameters, The initial value is set to 1. Represents the final feature map The eigenvector of the position, as shown in equation (4), is The eigenvectors of all positions in Therefore, the final feature map Each feature vector in contains global information and selectively aggregates context according to the spatial attention map.
[0073] The following is a detailed description of the improved global prototype representation learning strategy and supervised contrastive learning:
[0074] In this embodiment, the training is performed in the form of episode training, that is, in each episode training, only the support set and query set selected in the episode are used to train the network. The training methods of the training set (source domain data set) and the test set (target domain data set) are exactly the same. In each episode training, the labeled data needs to be divided into the support set and the query set first, and the network is trained using the support set and the query set. It should be noted that since this embodiment uses transfer learning to pre-train the network, the training set and the test set are trained in sequence. First, a training set with sufficient labeled samples is used to pre-train the network. After the network training is completed, the parameters of the encoder basic blocks #1 and 2 in SegNet are retained, and then the test set data is used to fine-tune the network. The steps for fine-tuning the network are exactly the same as those for pre-training, except that the parameters of the encoder basic blocks #1 and 2 in SegNet are no longer updated.
[0075] The purpose of the improved global prototype representation learning strategy is to optimize the feature extraction network and generate a global prototype representation feature vector for each category that can represent the category. The improved global prototype representation learning strategy is exactly the same in the training set and the test set. Taking a scenario training of the test set as an example, the implementation of the learning strategy is introduced in detail. The training process is as follows:
[0076] The input includes: label sets of all classes ;
[0077] Labeled examples for all classes;
[0078] Network learnable parameters ;
[0079] The specific algorithm is described as follows:
[0080] Input the hyperspectral image after PCA dimension reduction into SegNet to obtain the embedded feature vectors of all samples;
[0081] For Do
[0082] Calculated by equation (5) The global prototype representation of ;
[0083] Calculated by equation (6) The scenario prototype representation ;
[0084] End
[0085] For Do
[0086] For Do
[0087] Calculated by equation (7) and Similarity score ;
[0088] End
[0089] The support set is calculated by equation (8) Cross-entropy loss ;
[0090] The updated The global prototype representation is obtained ;
[0091] End
[0092] The loss on the support set is calculated by Equation (9): ;
[0093] For Do
[0094] For Do
[0095] For Do
[0096] Calculated by equation (11) and Similarity score ;
[0097] End
[0098] The query set is calculated by equation (12) of Cross-entropy loss of samples ;
[0099] End
[0100] End
[0101] The loss of the query set is calculated by equation (13) ;
[0102] For Do
[0103] Calculated by equation (14) The contrast loss and ;
[0104] End
[0105] The contrast loss is calculated by equation (15) ;
[0106] The total loss is calculated by equation (16) ;
[0107] .
[0108] The improved global prototype representation learning strategy is essentially the introduction of supervised contrastive learning on the basis of the global prototype representation learning strategy. The following is a detailed introduction to the global prototype representation learning strategy and supervised contrastive learning:
[0109] (1) The global prototype representation learning strategy is as follows:
[0110] First, the labeled samples in the test set are divided into a query set and a support set. is the label set of all classes, and K samples are randomly selected from each class of the N categories of labeled samples (K is set to 2 in the experiment) to form a support set , and then randomly select M samples from each category from the remaining samples (M is set to 2 in the experiment) as the query set, that is, the query set is , the support set samples are disjoint from the query set samples.
[0111] In a scenario training, Global prototype representation of categories It can be expressed as:
[0112] (5)
[0113] It is composed of the test set The feature vectors of all labeled samples of the category are averaged, where Represents the test set The labeled samples in the class, j represents the sample number, is the number of all labeled samples of each class, is the feature extraction network mapping function, . Combine the global prototype representations of all categories into a matrix , .
[0114] In the same training scenario, Contextual Prototype Representation of Categories It can be expressed as:
[0115] (6)
[0116] It is supported by the central The feature vectors of samples of the category are averaged, where Support set The labeled samples in the class, j represents the sample number. K is the number of samples in each class in the support set. The scene prototype representations of all categories are combined into a matrix , .
[0117] calculate Similarity to the global prototype representation of all categories:
[0118] (7)
[0119] This formula is the cosine similarity calculation formula, where: and They are and The module length, express With category The similarity of the global prototype representation of , Combine into a tensor , . Right now The similarity matrix with the global prototype representation of all categories will be Transformed into probability distribution through softmax function , . Then the support set The cross-entropy loss can be expressed as:
[0120] (8)
[0121] in is the true probability, only when hour, , the rest of the time . The total loss of the support set is It can be expressed as:
[0122] (9)
[0123] Below through Probability distribution of global prototype representations for all categories To update The global prototype representation of The update formula is as follows:
[0124] (10)
[0125] From equation (10), we know that Updated global prototype representation Contains the information of the initial global prototype representation of all categories. By analogy with the above method, the updated global prototype representation of all categories can be obtained. .
[0126] Query Set Sample ( Represents the sample number) and the similarity between the updated global prototype representation of each category can be expressed as:
[0127] (11)
[0128] This formula is also used to calculate cosine similarity, where Representation sample After mapping, the feature vector is express Feature vectors and categories after mapping The similarity of the global prototype representation of , Combine into a tensor , . Right now The similarity matrix with the updated global prototype representation of all categories will be Transformed into probability distribution through sofamax function , . Query Set Sample The cross-entropy loss can be expressed as:
[0129] (12)
[0130] in is the true probability, only when hour, , the rest of the time . The total loss of the query set is It can be expressed as:
[0131] (13)
[0132] in is the number of samples in the query set.
[0133] (2) Supervised contrastive learning is as follows:
[0134] In order to obtain more information from only a small number of labeled samples to optimize the feature extraction network, in this embodiment, the global prototype representation learning strategy is combined with supervised contrastive learning to optimize the feature extraction network, so that the similarity between the feature vectors of the samples after being mapped by the feature extraction network increases, and the similarity between different classes decreases, thereby improving the classification performance of the network.
[0135] In the AGPS framework, supervised contrastive learning is performed on support set samples, which are divided into two groups: , Indicates that Subscript Indicates group A, Indicates group B, and the superscript indicates the category number. Each group has only one sample per category, and the two groups of samples do not intersect with each other. In supervised contrastive learning, two samples of the same category can form a positive sample pair. In group B, only They can form positive sample pairs with each other.
[0136] In this embodiment, contrastive learning is implemented by the InfoNCE (Noise Contrastive Estimation) loss function. and The loss function based on InfoNCE It can be expressed as:
[0137] (14)
[0138] in Used for calculation and The similarity of is the temperature coefficient, which is set to 0.5 in the experiment
[17] . , therefore, the total contrast loss in a scene training is It can be expressed as:
[0139] (15)
[0140] The total loss in one training scenario It can be expressed as:
[0141] (16)
[0142] in, is a hyperparameter, The larger the value, the greater the contrast loss during back propagation. In this example, Adam optimizer is used to optimize the network, and the initial learning rate Set to 0.0001.
[0143] The hyperspectral image classification method provided in the embodiment of the present application has the following advantages:
[0144] 1) In view of the problem that the previous small sample hyperspectral image classification methods use image blocks as the input of the network, which leads to the limited network receptive field and generates a large amount of redundant calculations, this embodiment selects the SegNet feature extraction network based on the encoder-decoder architecture as the feature extractor. The input of the SegNet feature extraction network is the entire hyperspectral image. There is no need to divide the hyperspectral image into image blocks by pixels and it is a one-time forward calculation. Therefore, this embodiment is superior to the previous small sample hyperspectral image classification methods in terms of the ability to integrate long-distance pixel information of hyperspectral images and the reasoning speed. In addition, the ASPP-PA module is introduced into the SegNet feature extraction network to enhance the network's ability to obtain the dependency of spatial context information of different scales and the spatial position of the same scale. And based on the characteristics of hyperspectral images and the SegNet structure, the fusion lateral connection module is proposed to fuse rich detail features with deep features to enhance the feature extraction capability of the SegNet feature extraction network.
[0145] 2) In response to the problem that the existing small-sample hyperspectral image classification methods based on prototype networks cannot extract enough information from a small number of labeled samples, the embodiment of the present application improves the global prototype learning strategy and adds supervised contrastive learning to the global prototype learning strategy. Since contrastive learning uses positive and negative sample pairs for training, compared with other small-sample hyperspectral image classification methods based on prototype networks, this embodiment can extract more information from a small number of labeled samples to optimize the network.
[0146] To evaluate the effectiveness of the above method, the Chikusei hyperspectral image dataset is used as a training set to pre-train the network, and the training set has sufficient labeled samples. The Indian Pines (IP), Pavia University (UP) and Salinas (SA) hyperspectral image datasets are used as test sets to fine-tune the network, and each test set has 5 randomly selected labeled samples for each category. In order to verify the effectiveness of the above method, the current classic and more advanced hyperspectral image classification methods, namely SVM, 3-D-CNN, DFSL+SVM, DCFSL, S3Net, CRSSNet and other methods are selected in this embodiment, and 5 labeled samples are randomly selected for each category in the above method experiments for training, and the effectiveness of the proposed method is verified through comparative analysis.
[0147] There are three evaluation indicators for the experiment: Overall Accuracy (OA), Kappa coefficient and Average Accuracy (AA). OA represents the ratio of the number of correctly classified pixels in the hyperspectral data to the total number of test pixels, and AA represents the average accuracy of each category classification. The Kappa coefficient is an indicator used to measure the consistency between the classification results of the hyperspectral dataset and the actual effect. The range is between 0 and 1. A value of 1 indicates complete consistency, greater than 0.75 indicates satisfactory consistency, and less than 0.4 indicates less than ideal consistency. The larger the values of these three evaluation indicators, the better the model performance.
[0148] First, let’s analyze the impact of the number of dimensions (PCs) retained after PCA dimensionality reduction on OA. The dimension of the pre-training dataset Chikusei is 128, so even if the dimension of the SA and IP datasets is greater than 120, the maximum number of PCs retained after PCA dimensionality reduction for the SA and IP datasets is set to 120. The dimension of the UP dataset is 103, so the maximum number of PCs retained after PCA dimensionality reduction for the UP dataset is set to 100. The evolution of OA and the retained PCs is shown in Figure 2. Figure 6 (a) When the number of PCs is 30, the OA of the UP and SA datasets can achieve the maximum value. Although the OA of the IP dataset can achieve the maximum value when the number of PCs is 40, in order to ensure that the retained PCs can achieve good results on the three datasets, the retained PCs are set to 30 in subsequent experiments.
[0149] Next, we analyze the contrast loss The coefficient of The impact of the value on OA. The contrast loss of the three data sets The coefficient of Set to {0.1, 0.2, 0.3, …, 0.9}, OA with coefficient The evolution of Figure 8 (b). It can be seen that when the coefficient When the value of is set to 0.9, OA is higher than Therefore, in subsequent experiments, the coefficient The value of is set to 0.9.
[0150] The experimental results of the methods provided in this embodiment and other methods on the three datasets of Indian Pines, Pavia University, and Salinas are shown in Tables 1-3 below. Table 1 shows the classification accuracy of the Indian Pines hyperspectral remote sensing image dataset; Table 2 shows the classification accuracy of the Pavia University hyperspectral remote sensing image dataset; Table 3 shows the classification accuracy of the Salinas hyperspectral remote sensing image dataset.
[0151] Table 1
[0152]
[0153] Table 2
[0154]
[0155] Table 3
[0156]
[0157] Table 1-3 shows the classification results of each category of the above method on the IP, SA, and UP datasets. It can be seen that the AGPS framework proposed in this embodiment has the best OA and kappa coefficient on the three datasets. The performance of the AGPS framework on the three datasets is greatly improved compared with the traditional method (SVM), deep learning method (3D-CNN) and early FSL method (DFSL+SVM), among which OA is improved by 17.24%-33.13% in the IP dataset, 9.56%-15.9% in the SA dataset, and 11.45%-26.96% in the UP dataset. Compared with the latest FSL methods (S3Net and CRSSNet), the method provided in this embodiment has a slight improvement in the IP and SA datasets, and in the UP dataset, even compared with the latest small sample method OA has an improvement of about 3%-4%.
[0158] In order to verify the superiority of the proposed AGPS in inference speed, this embodiment selects the most advanced CRSSNet, S3Net and DCFSL methods to compare the inference speed with this solution. Five labeled samples are randomly selected from each category in the IP, SA and UP3 datasets to train the model, and then the trained model is used to predict the category of the remaining unlabeled samples. The length of the model prediction time is used to compare the inference speed of different methods.
[0159] The inference time (in seconds) of the four methods on the three data sets is shown in Table 4. It can be seen that the inference speed of this method is much faster than that of CRSSNet, S3Net and DCFSL. This is because the image block-based method will cause a lot of computational redundancy in the model due to the overlap of image blocks, while this method inputs the entire image into the network together and performs a forward calculation, so computational redundancy can be avoided.
[0160] Table 4
[0161]
[0162] The embodiment of the present application proposes an improved global prototype segmentation framework (AGPS) and applies the framework to the field of small sample hyperspectral image classification. In the AGPS framework, SegNet is proposed, which is a segmentation network based on the encoder-decoder architecture. The input of SegNet is the entire hyperspectral image, which avoids redundant calculations in overlapping areas and improves the reasoning speed. The ASPP-PA module in SegNet is used to obtain the dependency relationship between spatial context information of different scales and spatial positions of the same scale. The fused lateral connection structure proposed based on the characteristics of hyperspectral images and the SegNet structure fuses rich detail features with deep features to enhance the feature extraction capability of SegNet. Finally, in the AGPS framework, contrastive learning is combined with the global prototype representation learning strategy to obtain more information from a small number of labeled samples to optimize SegNet. The experimental results on three data sets demonstrate the superiority of this method.
[0163] Based on the above method embodiment, the present application embodiment also provides a hyperspectral image classification device, see Figure 7As shown, the device includes: an image acquisition module 102, used to acquire a hyperspectral image to be classified; a classification module 104, used to input the hyperspectral image into an image classification model to obtain a classification result corresponding to the hyperspectral image; wherein the image classification model is a classification model based on an improved global prototype segmentation framework trained by transfer learning; the improved global prototype segmentation framework includes: a SegNet feature extraction network optimized based on an improved global prototype representation learning strategy and a nearest neighbor algorithm classification network; the improved global prototype representation learning strategy includes: a global prototype representation learning strategy introducing supervised contrast learning; the SegNet feature extraction network includes: an encoder network, a fused lateral connection module, an ASPP-PA module, and a decoder network; the SegNet feature extraction network is used to extract spatial spectral features of hyperspectral images; the spatial spectral features include feature vectors corresponding one to one to each pixel in the hyperspectral image.
[0164] Furthermore, the transfer learning training process of the above-mentioned image classification model includes: obtaining a training sample set; pre-training the SegNet feature extraction network using a source domain data set including a specified number of labeled samples in the training sample set; fine-tuning the pre-trained network using a target domain data set including a small number of labeled samples; wherein the steps of pre-training and fine-tuning are the same, and when fine-tuning the network, some parameters of the encoder in the pre-trained SegNet feature extraction network are retained; after the network fine-tuning training is completed, the nearest neighbor algorithm classification network is used for classification to obtain an image classification model.
[0165] Furthermore, the improved global prototype representation learning strategy used in the pre-training and fine-tuning process includes: for each round of training data set, extracting labeled samples therein and dividing them into a support set and a query set; the support set is processed based on a supervised contrast learning method; averaging the feature vectors of all labeled samples of each category in the data set to obtain a global prototype representation feature vector for each category; averaging the feature vectors of samples of each category in the support set to obtain a scenario prototype representation feature vector for each category; calculating the cross entropy loss between the scenario prototype representation feature vector and the global prototype representation feature vector to obtain the support set loss; updating the global prototype representation feature vector through the similarity between the scenario prototype representation feature vector and the global prototype representation feature vector; calculating the cross entropy loss between the query set samples and the updated global prototype representation feature vector to obtain the query set loss; calculating the noise contrast estimation loss between the support set samples to obtain the contrast loss; summing the support set loss, the query set loss and the contrast loss to obtain the total model loss; and updating the model network parameters based on the total model loss.
[0166] Furthermore, the above-mentioned supervised contrastive learning processing method includes: dividing the support set samples into two groups, respectively , Indicates that Subscript Indicates group A, represents group B, and the superscript represents the category number. Each group has only one sample per category, and the two groups of samples do not intersect with each other. In supervised contrastive learning, two samples with the same category in the two support sets form a positive sample pair. Supervised contrastive learning is implemented through the InfoNCE loss function. and The loss function based on InfoNCE It can be expressed as:
[0167] ;
[0168] in Used to indicate and The similarity of is the temperature coefficient; the existence of the denominator of the loss function makes , therefore, the total contrast loss in a scene training is It is expressed as:
[0169] ;
[0170] The total loss in one training scenario It is expressed as:
[0171] ;
[0172] in, is a hyperparameter, The larger the value, the greater the contrast loss during back propagation. It will have greater weight.
[0173] Furthermore, the encoder network includes 4 encoder basic blocks and 3 maximum pooling downsampling networks; the encoder basic block includes a 1x1 convolution layer, a residual block, a spectral attention module and a 3x3 convolution layer; the 1x1 convolution layer is used to adjust the dimension of the feature map; the residual block is used to extract the spatial information of the hyperspectral image; the spectral attention module is used to extract the spectral information of the hyperspectral image; the 3x3 convolution layer is used to integrate the extracted feature information; group normalization is used in each encoder basic block; a fusion horizontal connection module is used to fuse the three feature maps output by the three encoder basic blocks before each downsampling with the feature map of the corresponding upsampling output, wherein the 1x1 convolution layer is used to adjust the dimension of the feature map output by the encoder basic block so that it is consistent with the shape of the feature map of the corresponding upsampling output; the decoder network includes: 3 decoder basic blocks ; The operation flow of each decoder basic block is as follows: the input feature map with higher dimensional spatial spectral information is upsampled by 2 times using bilinear interpolation; it is added and fused with the feature map with finer spatial spectral information output by the fused lateral connection to restore the spatial details of the input; the fused feature information is extracted through a 3x3 convolution layer; the ASPP-PA module includes: a series of atrous spatial convolution pooling pyramid ASPP module and a position attention PA module; the ASPP module obtains feature information of different scales in the spatial dimension by performing atrous convolution operations with different expansion rates and global pooling operations on the input feature map, and fuses the feature information of different scales through addition operations to obtain a fused feature map; the PA module obtains the dependency of the spatial position of the same scale in the fused feature map through self-attention operations to output the final feature map.
[0174] Furthermore, the ASPP module outputs the fused feature map according to the following formula:
[0175] ;
[0176] in, represents the input feature map, represents a fused feature map with multi-scale information, Represents 4 dilated convolution operations, represents the global average pooling operation, and There are 5 learnable parameters, and their initialization values are all 1.
[0177] Furthermore, the above-mentioned PA module is also used to: perform shape transformation on the fused feature map output by ASPP through a convolutional layer to generate a first feature mapping matrix, a second feature mapping matrix and a third feature mapping matrix; multiply the first feature mapping matrix and the second feature mapping matrix, and process them through a softmax function to obtain a spatial position attention map; multiply the third feature mapping matrix with the spatial position attention map, multiply it by a variable parameter, and then add it element by element with the fused feature map to obtain a final feature map.
[0178] The device provided in the embodiment of the present application has the same implementation principle and technical effects as those of the aforementioned method embodiment. For the sake of brief description, for matters not mentioned in the embodiment of the device, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0179] The present application also provides an electronic device, such as Figure 8 As shown, it is a schematic diagram of the structure of the electronic device, wherein the electronic device includes a processor 111 and a memory 110, the memory 110 stores computer executable instructions that can be executed by the processor 111, and the processor 111 executes the computer executable instructions to implement the above method.
[0180] exist Figure 8 In the illustrated embodiment, the electronic device further includes a bus 112 and a communication interface 113 , wherein the processor 111 , the communication interface 113 and the memory 110 are connected via the bus 112 .
[0181] Among them, the memory 110 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 113 (which can be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. can be used. The bus 112 can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 112 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0182] The processor 111 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 111. The above processor 111 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to execute, or the hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor 111 reads the information in the memory and completes the steps of the method of the above embodiment in combination with its hardware.
[0183] An embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the above method. The specific implementation can be found in the aforementioned method embodiment, which will not be repeated here.
[0184] The computer program products of the methods, devices, and electronic devices provided in the embodiments of the present application include a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the previous method embodiments. The specific implementation can be found in the method embodiments, which will not be repeated here.
[0185] Unless otherwise specifically stated, the relative steps, numerical expressions and values of the components and steps set forth in these embodiments do not limit the scope of the present application.
[0186] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0187] In the description of the present application, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present application. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0188] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A hyperspectral image classification method, characterized in that: The method comprises: Acquire a hyperspectral image to be classified; The hyperspectral image is input into an image classification model to obtain a classification result corresponding to the hyperspectral image; wherein the image classification model is a classification model based on an improved global prototype segmentation framework trained by transfer learning; the improved global prototype segmentation framework includes: a SegNet feature extraction network optimized based on an improved global prototype representation learning strategy and a nearest neighbor algorithm classification network; the improved global prototype representation learning strategy includes: a global prototype representation learning strategy introducing supervised contrastive learning; the SegNet feature extraction network includes: an encoder network, a fused lateral connection module, an ASPP-PA module, and a decoder network; the SegNet feature extraction network is used to extract spatial spectral features of hyperspectral images; the spatial spectral features include feature vectors corresponding one-to-one to each pixel in the hyperspectral image; The encoder network includes 4 encoder basic blocks and 3 maximum pooling downsampling networks; the encoder basic block includes a 1x1 convolution layer, a residual block, a spectral attention module and a 3x3 convolution layer; the 1x1 convolution layer is used to adjust the dimension of the feature map; the residual block is used to extract the spatial information of the hyperspectral image; the spectral attention module is used to extract the spectral information of the hyperspectral image; the 3x3 convolution layer is used to integrate the extracted feature information; each encoder basic block adopts a group normalization method; The fusion lateral connection module is used to fuse the three feature maps output by the three encoder basic blocks before each downsampling with the feature map of the corresponding upsampling output, wherein the 1x1 convolution layer is used to adjust the dimension of the feature map output by the encoder basic block to keep it consistent with the shape of the feature map of the corresponding upsampling output; The decoder network includes: 3 decoder basic blocks; the operation flow of each decoder basic block is as follows: the input feature map with higher dimensional spatial spectrum information is upsampled by 2 times using bilinear interpolation; it is added and fused with the feature map with finer spatial spectrum information output by the fusion lateral connection to restore the input spatial details; the fused feature information is extracted through a 3x3 convolution layer; The ASPP-PA module includes: a series-connected atrous spatial convolution pooling pyramid ASPP module and a position attention PA module; the ASPP module obtains feature information of different scales in the spatial dimension by performing atrous convolution operations with different expansion rates and global pooling operations on the input feature map, and fuses the feature information of different scales through addition operations to obtain a fused feature map; the PA module obtains the dependency relationship of the same scale spatial position in the fused feature map through self-attention operations to output the final feature map.
2. The method according to claim 1, characterized in that The transfer learning training process of the image classification model includes: Obtain a training sample set; Pre-train the SegNet feature extraction network using a source domain dataset that includes a specified number of labeled samples in the training sample set; Using a target domain dataset that includes a small number of labeled samples, fine-tune the pre-trained network; the pre-training and fine-tuning steps are the same, and when fine-tuning the network, some parameters of the encoder in the pre-trained SegNet feature extraction network are retained; After the network fine-tuning training is completed, the nearest neighbor algorithm classification network is used for classification to obtain the image classification model.
3. The method according to claim 2, characterized in that The improved global prototype representation learning strategy used in the pre-training and fine-tuning process includes: For each round of training data set, the labeled samples are extracted and divided into a support set and a query set; the support set is processed based on a supervised contrastive learning method; The feature vectors of all labeled samples of each category in the data set are averaged to obtain the global prototype representation feature vector of each category; The feature vectors of samples of each category in the support set are averaged to obtain the feature vector representing the scenario prototype of each category; Calculate the cross entropy loss between the scene prototype representation feature vector and the global prototype representation feature vector to obtain the support set loss; According to the similarity between the scenario prototype representation feature vector and the global prototype representation feature vector, the global prototype representation feature vector is updated; Calculate the cross entropy loss between the query set samples and the updated global prototype representation feature vector to obtain the query set loss; Calculate the noise contrast estimation loss between the support set samples to obtain the contrast loss; Sum the support set loss, query set loss, and contrast loss to get the total model loss; Based on the total model loss, update the model network parameters.
4. The method according to claim 3, characterized in that Supervised contrastive learning approaches include: The support set samples are divided into two groups: , Indicates that Subscript Indicates group A, represents group B, and the superscript represents the category number. Each group has only one sample per category, and the two groups of samples do not intersect with each other. In supervised contrastive learning, two samples with the same category in the two support sets form a positive sample pair. Supervised contrastive learning is implemented through the InfoNCE loss function. and The loss function based on InfoNCE It can be expressed as: ; in Used to indicate and similarity; Representation sample Feature vector after being mapped by the feature extraction network; Representation sample The feature vector after feature extraction network mapping, is the temperature coefficient; the existence of the denominator of the loss function makes , therefore, the total contrast loss in a scene training is It is expressed as: ; The total loss in one training scenario It is expressed as: ; in, is a hyperparameter, The larger the value, the greater the contrast loss during back propagation. It will have greater weight; represents the total loss of the query set; represents the total loss on the support set.
5. The method according to claim 1, characterized in that The ASPP module outputs the fused feature map according to the following formula: ; in, represents the input feature map, represents a fused feature map with multi-scale information, Represents 4 dilated convolution operations, represents the global average pooling operation, and There are 5 learnable parameters, and their initialization values are all 1.
6. The method according to claim 3, characterized in that The PA module is also used to: perform shape transformation on the fused feature map output by the ASPP through a convolutional layer to generate a first feature mapping matrix, a second feature mapping matrix and a third feature mapping matrix; multiply the first feature mapping matrix and the second feature mapping matrix, and process them through a softmax function to obtain a spatial position attention map; multiply the third feature mapping matrix with the spatial position attention map, multiply it by a variable parameter, and then add it element by element with the fused feature map to obtain a final feature map.
7. A hyperspectral image classification device, characterized in that: The device comprises: An image acquisition module, used for acquiring a hyperspectral image to be classified; A classification module, used for inputting the hyperspectral image into an image classification model to obtain a classification result corresponding to the hyperspectral image; wherein the image classification model is a classification model based on an improved global prototype segmentation framework trained by transfer learning; the improved global prototype segmentation framework includes: a SegNet feature extraction network optimized based on an improved global prototype representation learning strategy and a nearest neighbor algorithm classification network; the improved global prototype representation learning strategy includes: a global prototype representation learning strategy introducing supervised contrastive learning; the SegNet feature extraction network includes: an encoder network, a fused lateral connection module, an ASPP-PA module, and a decoder network; the SegNet feature extraction network is used to extract spatial spectral features of hyperspectral images; the spatial spectral features include feature vectors corresponding one-to-one to each pixel in the hyperspectral image; The encoder network includes 4 encoder basic blocks and 3 maximum pooling downsampling networks; the encoder basic block includes a 1x1 convolution layer, a residual block, a spectral attention module and a 3x3 convolution layer; the 1x1 convolution layer is used to adjust the dimension of the feature map; the residual block is used to extract the spatial information of the hyperspectral image; the spectral attention module is used to extract the spectral information of the hyperspectral image; the 3x3 convolution layer is used to integrate the extracted feature information; each encoder basic block adopts a group normalization method; The fusion lateral connection module is used to fuse the three feature maps output by the three encoder basic blocks before each downsampling with the feature map of the corresponding upsampling output, wherein the 1x1 convolution layer is used to adjust the dimension of the feature map output by the encoder basic block to keep it consistent with the shape of the feature map of the corresponding upsampling output; The decoder network includes: 3 decoder basic blocks; the operation flow of each decoder basic block is as follows: the input feature map with higher dimensional spatial spectrum information is upsampled by 2 times using bilinear interpolation; it is added and fused with the feature map with finer spatial spectrum information output by the fusion lateral connection to restore the input spatial details; the fused feature information is extracted through a 3x3 convolution layer; The ASPP-PA module includes: a series-connected atrous spatial convolution pooling pyramid ASPP module and a position attention PA module; the ASPP module obtains feature information of different scales in the spatial dimension by performing atrous convolution operations with different expansion rates and global pooling operations on the input feature map, and fuses the feature information of different scales through addition operations to obtain a fused feature map; the PA module obtains the dependency relationship of the same scale spatial position in the fused feature map through self-attention operations to output the final feature map.
8. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the method according to any one of claims 1 to 6.
