Remote sensing image caption generation method based on topic-guided Transformer

By adopting the topic-guided Transformer structure and random masking strategy in remote sensing image subtitle generation, the problem of insufficient description accuracy and diversity in the existing technology is solved, more accurate and diverse subtitle generation is achieved, and the remote sensing image subtitle generation is promoted. Application development.

CN115035508BActive Publication Date: 2024-09-27XIAN CHUXIAO SHANGFAN TECHNOLOGY SERVICE CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202210689905.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-17
Publication Date
2024-09-27
Estimated Expiration
2042-06-17

AI Technical Summary

Technical Problem

Existing remote sensing image subtitle generation methods cannot effectively represent the correlation and detailed content between features in the image, resulting in insufficient accuracy and diversity of generated descriptions, which limits the development of high-precision remote sensing image applications.

Method used

Using a topic-guided Transformer structure, the image semantic information is extracted through a pre-trained topic encoder, and a random masking strategy is used in the decoder to enhance the generation diversity, and combined with image features to generate rich and accurate subtitle descriptions.

Benefits of technology

The accuracy and diversity of subtitles are improved, and the generated descriptions can more comprehensively represent the relevance and details of features in the image, improving the accuracy and practicality of remote sensing image applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115035508B
    Figure CN115035508B
Patent Text Reader

Abstract

The present invention discloses a Transformer remote sensing image subtitle generation method based on topic guidance, which mainly solves the problem that the description generated by the prior art is single and cannot accurately represent the semantic information in the image. Its implementation scheme is: build a topic encoder composed of a Transformer and a topic vector, and pre-train it on a classification data set; build a semantic decoder composed of a random mask layer, an embedding layer, a Transformer decoder and a cascade of soft‑max layers; connect the topic encoder and the semantic decoder to obtain a remote sensing image subtitle generation network; set training parameters, and iteratively train the remote sensing image subtitle generation network with a standard RSICD data set; use the trained remote sensing image subtitle generation network to generate subtitle descriptions. The present invention improves the diversity and accuracy of the generated descriptions, and can be used for ground object image retrieval, disaster prediction, and image understanding.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of image language interaction, and further relates to a remote sensing image caption generation method, which can be used for ground object image retrieval, disaster prediction, and image understanding. Background Art

[0002] Remote sensing images have been widely used in various fields such as object image retrieval, disaster prediction, and image understanding in recent years due to their rich object information. Conventional remote sensing image applications are based on target detection and image segmentation techniques, which can only simply describe the object information in the image and cannot represent the correlation between objects. However, with the continuous development of remote sensing technology, it is necessary to associate object information to obtain a more specific and accurate description. In this case, relying solely on conventional target detection and image segmentation methods cannot meet the requirements, which limits the development of high-precision remote sensing image applications.

[0003] Image caption generation originated from the field of natural image understanding. Its task is to generate corresponding text descriptions based on the content in the image. The current mainstream image caption generation model is based on the encoder-decoder network structure. The encoder maps image features to text space, and the decoder generates corresponding text descriptions based on image features. Using text to describe the content in remote sensing images can obtain the ground feature and position association of each part of the image at one time. Compared with single target features and segmentation features, this method can more accurately express the information in the image and contribute to the development of high-precision remote sensing image applications.

[0004] Transformer is a network framework based on a multi-head attention mechanism, first proposed by Vaswani et al. in the field of machine translation. The structure consists of several attention modules, each of which can represent the relationship between different parts of a sequence. The parallel operation of multiple attention modules greatly enhances the learning ability and performance of the model, and has achieved new breakthroughs in the field of natural language processing.

[0005] In recent years, many scholars have conducted relevant research on remote sensing image caption generation:

[0006] In 2016, Qu et al. first annotated the UCM dataset and the Sydney dataset, which are standard datasets for remote sensing image caption generation. In addition, Qu et al. used the natural image caption generation model NIC to test on these two datasets, laying the foundation for subsequent research.

[0007] In 2017, Lu et al. further enriched the dataset for remote sensing image caption generation. They annotated the RSICD dataset. Compared with the previous two datasets, the RSICD dataset has a larger data volume and richer descriptions. In addition, Lu et al. optimized the NIC model using the attention mechanism and used the average value of the feature map to represent the semantic information in the image. This method preliminarily described the semantic information in the image, which improved the accuracy of the generated description.

[0008] In 2020, Zhao et al. used a structured attention mechanism to optimize the encoder part. This method first used Selective search to perform a rough segmentation of the image, and then multiplied the segmentation map and the feature map to obtain a feature map with regional information. Using this method, the structured information of the features of the objects can be obtained, thereby improving the quality of the generated text description.

[0009] In 2021, Li et al. proposed a recurrent attention mechanism that can utilize previous sequence information and use a new semantic gating unit. These two methods can effectively prevent the decoder from obtaining meaningless information, making the generated text more targeted and able to describe most of the features of the objects in the image.

[0010] The above methods combine machine learning and deep learning technologies, and their performance is improved compared to traditional algorithms. However, these methods cannot accurately represent the rich semantic information in remote sensing images. In addition, the descriptions generated by these methods are very single, and only conventional ground object information can appear in the descriptions, and the detailed content in the image cannot be represented. These defects make the generation of remote sensing image subtitles still have a certain gap from practical applications. Summary of the invention

[0011] The purpose of the present invention is to address the deficiencies of the above-mentioned prior art and propose a topic-guided Transformer remote sensing image subtitle generation method, so as to obtain rich semantic information in the image by using topic identification information, and improve the diversity of generated text descriptions through a mask network, so as to finally obtain subtitles with stronger readability and accurate information expression.

[0012] The technical idea of ​​the present invention is: based on the Transformer framework, a remote sensing classification data set is used to pre-train the subject encoder part so that the encoder can extract semantic information in the image; then the decoder is trained on the remote sensing subtitle generation data set, and when the decoder inputs text, a part of the text is first randomly masked to enhance the learning ability of the model and facilitate the generation of diverse subtitles; then the semantic information and text information in the subject encoder are spliced ​​so that the semantic information can guide the generation of the text; the spliced ​​text information interacts with the image information to generate the corresponding text description; after a certain number of iterations on the data set, the final model can generate rich and accurate subtitle descriptions.

[0013] According to the above ideas, the implementation scheme of the present invention includes the following:

[0014] 1) Pre-trained topic encoder:

[0015] 1a) Obtain the training set and test set of the remote sensing caption generation dataset RSICD from the public website, and use the image names of the training set as the category labels and the images of the training set as the data to obtain the classification dataset;

[0016] 1b) Build a topic encoder consisting of an embedding layer, a Transformer encoder, and a topic vector T;

[0017] 1c) Using the classification dataset, the topic encoder is pre-trained by the gradient descent method to obtain a trained topic encoder;

[0018] 2) Build a topic-guided Transformer remote sensing image caption generation network based on topic-guided Transformer:

[0019] 2a) Build a semantic decoder consisting of a random mask layer, an embedding layer, a Transformer decoder, and a soft-max layer cascaded;

[0020] 2b) Connect the trained topic encoder and semantic decoder to obtain a topic-guided Transformer remote sensing image caption generation network;

[0021] 3) Iterative training of the topic-guided Transformer remote sensing image caption generation network:

[0022] 3a) Set the maximum number of iterations E for network training and the initial learning rate Lr;

[0023] 3b) Input the image in the training set from the topic encoder to obtain the image embedding feature V I and topic embedding feature V T;

[0024] 3c) Input the text data into the semantic decoder, first pass through its random mask layer to randomly replace some text with special identifiers [Mask], and then output the masked text embedding feature X through the embedding layer;

[0025] 3d) Embed the topic into feature V T Concatenate with the masked text embedding feature X to get the topic text embedding feature X T ;

[0026] 3e) Embed the topic text into feature X T Input to the self-attention layer in the semantic decoder to obtain the self-attention text embedding feature X S ;

[0027] 3f) Embed the self-attention text into feature X S It is input into the interactive attention layer in the semantic decoder and combined with the image features V I Perform interactive attention calculation to obtain the interactive attention text embedding feature X I ;

[0028] 3g) Embed the interactive attention text into feature X I As the input of the next decoding layer, use X I as the masked text embedding feature X in (3d);

[0029] 3h) Repeat 3d) to 3g) to get the final output X F ;

[0030] 3i) The final output X F Input to the soft-max layer of the semantic decoder to obtain the probability distribution p of the generated description θ ;

[0031] 3j) According to the probability distribution p of the generated description θ , calculate the cross entropy loss Loss;

[0032] 3k) Perform back propagation based on the cross entropy loss Loss to update the network parameters;

[0033] 3l) Repeat 3b) to 3k) until the maximum number of iterations E is reached, and a trained topic-guided Transformer remote sensing image caption generation network is obtained.

[0034] 4) Input the test set remote sensing images into the trained topic-guided Transformer remote sensing image caption generation network to obtain the captions corresponding to the images.

[0035] Compared with the prior art, the present invention has the following advantages:

[0036] 1) The generated subtitles are more accurate

[0037] The present invention adopts the Transformer structure for encoding and decoding. Since the multi-head attention mechanism of the Transformer is very consistent with the characteristics of multiple land features in remote sensing images, it can more comprehensively represent the correlation between various land features. In addition, since the present invention adds a topic vector in the topic encoder to extract semantic information in the image, and this information can guide the generation of subtitles in the decoder, the generated subtitles are more accurate.

[0038] 2) Generated subtitles are more diverse

[0039] The present invention uses a mask strategy to enhance the diversity of generated subtitles. In each iteration process, the mask setting is random, which not only enhances the learning ability of the model, but also forces the model to learn some unknown word associations, and can generate subtitles with greater diversity. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 It is a flow chart of the implementation of the present invention;

[0041] Figure 2 It is a schematic diagram of the structure of the theme encoder in the present invention;

[0042] Figure 3 It is a schematic diagram of the network structure of remote sensing image caption generation based on topic guidance constructed in the present invention;

[0043] Figure 4 This is a comparison chart of subtitles generated by the present invention and a conventional training method. DETAILED DESCRIPTION

[0044] The embodiments and effects of the present invention are further described in detail below with reference to the accompanying drawings.

[0045] Reference Figure 1 , the implementation steps of the present invention are as follows:

[0046] Step 1. Pre-train the topic encoder.

[0047] (1.1) Obtain the training set and test set of the remote sensing caption generation dataset RSICD from the public website, and use the image names of the training set as the category labels y and the images of the training set as data to obtain the classification dataset;

[0048] (1.2)Reference Figure 2 , build a topic encoder consisting of an encoding embedding layer, a Transformer encoder, and a topic vector T;

[0049] (1.2.1) Establish an encoding embedding layer with a dimension of 768 to map the image to the high-dimensional feature and then interact with the text feature;

[0050] (1.2.2) Create a Transformer encoder consisting of 12 base encoders and a soft-max layer cascade, where each base encoder consists of a normalization layer, a multi-head attention layer, a normalization layer, and a multi-layer perceptron cascade;

[0051] (1.2.3) Set the topic vector T as a trainable parameter of the topic encoder to extract the global semantic information in the image. That is, when inputting image features, the topic vector T and the image features are concatenated together, and the topic vector can interact with each image feature through the multi-head attention module of the Transformer;

[0052] (1.2.4) Connect the Transformer encoder to the embedding layer to extract image features;

[0053] (1.3) Using the classification dataset, the topic encoder is pre-trained using the gradient descent method:

[0054] (1.3.1) Set the pre-training learning rate to L = 3 × 10 -5 , the maximum number of pre-training iterations E pre =20;

[0055] (1.3.2) Concatenate the image data and the topic vector to obtain the input feature V of the topic encoder in ;

[0056] (1.3.3) Input feature V in Input to the topic encoder to obtain the pre-trained image embedding feature V′ I , and the pre-trained topic embedding feature V′ T ;

[0057] (1.3.4) Embed the pre-trained topic into feature V′ T Input into the existing soft-max layer to obtain the category estimation probability p;

[0058] (1.3.5) Calculate the classification loss Loss based on the label and category estimated probability p c :

[0059]

[0060] Among them, i is the subscript of the category, p iis the estimated probability of the i-th category, C is the total number of categories, y i is the category label of the i-th category;

[0061] (1.3.6) According to the classification loss Loss c Use gradient descent method to update network parameters

[0062]

[0063] Among them, α is the network parameter of the topic encoder to be updated, α′ is the network parameter of the updated topic encoder, and L is the learning rate of pre-training;

[0064] (1.3.7) Repeat (1.3.2) to (1.3.6) until the maximum number of iterations E is reached. pre , and get the trained topic encoder.

[0065] Step 2. Build a topic-guided Transformer remote sensing image caption generation network.

[0066] Reference Figure 3 As shown, the specific implementation of this step is as follows:

[0067] (2.1) Build a semantic decoder;

[0068] (2.1.1) Construct a random mask layer to enhance the learning ability of the model and increase the diversity of generated text, and set the mask probability of the random mask layer to 0.3, that is, for each input word, there is a 30% probability of replacing it with a special identifier [Mask];

[0069] (2.1.2) Establish a decoding embedding layer for mapping text information into a high-dimensional space and then interacting with image features, and set the embedding dimension of the decoding embedding layer to 768;

[0070] (2.1.3) Build the Transformer decoder

[0071] A Transformer decoder consisting of two basic decoders is established to generate text by combining topic information and image features. Each basic decoder consists of a normalization layer, a self-attention layer, a normalization layer, an interactive attention layer, and a multi-layer perceptron cascade.

[0072] (2.1.4) Select the soft-max layer to generate the probability distribution of text description;

[0073] (2.1.5) The random mask layer, embedding layer, Transformer decoder and soft-max layer are cascaded to form a semantic decoder;

[0074] (2.2) A topic-guided Transformer remote sensing image caption generation network is obtained from the trained topic encoder and semantic decoder. The output of the topic encoder is divided into two parts, one is the topic feature and the other is the image feature. The topic feature is connected to the self-attention layer in the semantic decoder, and the image feature is connected to the interactive attention layer in the semantic decoder.

[0075] Step 3. Iteratively train the topic-guided Transformer remote sensing image caption generation network.

[0076] (3.1) Set the maximum number of iterations of network training E = 20 and the initial learning rate Lr = 3 × 10 -5 ;

[0077] (3.2) Input the image in the training set from the topic encoder to obtain the image embedding feature V I , and the topic embedding feature V T ;

[0078] (3.3) Input the text data into the semantic decoder, first pass through its random mask layer to randomly replace some text with special identifiers [Mask], and then output the masked text embedding feature X through the decoding embedding layer;

[0079] (3.4) Embed the topic into feature V T Concatenate with the masked text embedding feature X to get the topic text embedding feature X T ;

[0080] X T =[V T ,X·M]

[0081] Among them, V T is the topic embedding feature, X is the masked text embedding feature, and M is the lower triangular matrix;

[0082] (3.5) Embed the topic text into feature X T Input to the self-attention layer in the semantic decoder to obtain the self-attention text embedding feature X S ;

[0083] X s =Norm(X+MHA(X,X T ,X T ))

[0084] Among them, X is the masked text embedding feature, X T is the topic text embedding feature, and Norm is the normalization operation;

[0085] MHA is a multi-head attention mechanism, and its formula is as follows:

[0086] MHA(Q,K,V)=Concat(head 1 ,head 2 ,...,head j ,...,head N )W

[0087]

[0088]

[0089] Where Q, K, and V represent the query, key, and value vectors in the multi-head attention, respectively, j is the subscript of the attention head, and head j represents the jth attention head, N is the number of attention heads, W is the weight vector, d is the scale factor, is the weight matrix of the jth attention head;

[0090] (3.6) Embed the self-attention text into feature X S It is input into the interactive attention layer in the semantic decoder and combined with the image features V I Perform interactive attention calculation to obtain the interactive attention text embedding feature X I ;

[0091] X I =Norm(X s +MHA(X s ,V I ,V I ))

[0092] Among them, X s is the self-attention text embedding feature, V I is the image embedding feature, MHA is the multi-head attention mechanism, and Norm is the normalization operation;

[0093] (3.7) Embed the interactive attention text into feature X I As the input of the next decoding layer, use X I As the masked text embedding feature X in (3.3), repeat (3.3) to (3.6) to obtain the final semantic decoder output X F ;

[0094] (3.8) The final semantic decoder outputs X F Input to the soft-max layer of the semantic decoder to obtain the probability distribution p of the generated description θ ;

[0095] (3.9) will generate the probability distribution p described by θ And the description label Y is input into the cross entropy loss function to calculate the cross entropy Loss;

[0096]

[0097] Among them, p θ is the probability distribution of the generated description, t is the current time step, Y t is the word at time t, Y mask 1:t-1 is the masked label sequence from time 1 to time t-1, and Len is the total length of the label sequence;

[0098] (3.10) Back propagation is performed based on the cross entropy loss Loss to update the network parameters;

[0099]

[0100] Where θ is the network parameter to be updated, θ′ is the updated network parameter, is the partial derivative of the final loss with respect to the network parameter θ, and Lr is the preset learning rate;

[0101] (3.11) Repeat (3.2) to (3.10) until the maximum number of iterations E is reached, and the trained topic-guided Transformer remote sensing image caption generation network is obtained.

[0102] Step 4 inputs the test set remote sensing images into the trained topic-guided Transformer remote sensing image caption generation network to obtain the captions corresponding to the images.

[0103] The effect of the present invention can be further illustrated by the following experiments.

[0104] 1. Experimental environment

[0105] The experimental environment is the Pycharm platform under Windows 10, the language used is Python 3.7, the deep learning framework used is Pytorch, the optimizer is the Adam optimizer, the processor is Intel i7-8700k, and the graphics card is GeForce RTX 2080.

[0106] 2. Experimental content

[0107] Experiment 1: Using the above environment, the invention and the existing six topic-guided Transformer remote sensing image caption generation networks are used to conduct experiments on the RSICD dataset, with the initial learning rate set to 3×10 -5, the maximum number of iterations is set to 20, the batch size is set to 5, BLEU, CIDEr, Meteor, Rouge-L are used as evaluation indicators, the subtitle descriptions generated by different models are calculated using the above indicators, and the scores of subtitles generated by different models are obtained, as shown in Table 1.

[0108] Table 1 Scores of subtitles generated by 6 existing methods and the proposed method

[0109] method BLEU-1 BLEU-2 BLEU-3 BLEU-4 Meteor Rouge-L CIDEr Soft-attention 67.53 53.08 43.33 36.17 32.55 61.09 196.43 Hard-attention 66.69 51.82 41.64 34.07 32.01 60.84 179.25 Structured-attention 70.16 56.14 46.48 39.34 32.91 57.06 170.31 AttrAttention 75.71 63.36 53.85 46.12 35.13 64.58 235.63 MLA 77.25 62.90 53.28 46.08 44.71 69.10 236.37 VRTMM 78.13 67.21 56.45 51.23 37.37 67.13 271.50 RASG 77.29 66.51 57.82 50.62 36.26 66.91 275.49 The present invention 80.42 69.96 61.36 54.14 39.37 70.58 298.39

[0110] In Table 1, Soft-attention and Hard-attention are two different basic attention methods, Structured-attention is an attention method based on image segmentation; AttrAttention is a method based on attribute attention, MLA is a remote sensing image caption generation method using three feature maps of different scales, VRTMM is a method based on autoencoder and Transformer, and RASG is a remote sensing image caption generation method based on recurrent attention and semantic gating units.

[0111] It can be seen from Table 1 that the present invention achieves better results in every indicator compared with some conventional methods.

[0112] Experiment 2, the mask strategy proposed in the present invention and the conventional strategy are used to train the topic-guided Transformer remote sensing image caption generation network proposed in the present invention, and the results of subtitle generation are compared. The index Self-CIDEr for evaluating diversity is introduced, and the scores of generated subtitles are calculated using the Self-CIDEr, BLEU, Rouge, Meteor and CIDEr indicators. The results of the experiment on RSICD are shown in Table 2.

[0113] Table 2 Index scores of subtitles generated using conventional strategies and the mask strategy of the present invention

[0114]

[0115] As can be seen from Table 2, the Self-CIDEr value of the diversity index of the present invention is significantly improved compared with the score of the conventional method, indicating that the diversity of the generated subtitles is greatly improved.

[0116] Experiment 3 visualizes some of the subtitles generated using the conventional strategy and the mask strategy of the present invention. The results are as follows: Figure 4 As shown, Figure 4 (a) is a beach scene picture. Figure 4 (b) is a stadium scene picture. Figure 4(c) is a desert scene picture. Figure 4 (d) is a playground scene picture. Figure 4 (e) is a port scene picture. Figure 4 (f) is a scene diagram of a resort area. The left side of each diagram is a remote sensing image for testing. Each scene corresponds to two subtitle descriptions, namely, the prior art and the present invention. That is, the prior art corresponds to a subtitle description generated using a conventional strategy, and the present invention corresponds to a subtitle description generated using the mask strategy of the present invention, which are described as follows.

[0117] Figure 4 In (a), the subtitles generated by using the conventional training strategy are: yellow beach is near a piece of green ocean., i.e., the yellow beach is near a piece of green ocean; the subtitles generated by using the masking strategy of the present invention are: yellow beach is near a piece of green ocean with white waves., i.e., the yellow beach is near a piece of green ocean with white waves;

[0118] Figure 4 In (b), the subtitles generated by the conventional training strategy are: many buildings and green trees are around a center building., i.e., many buildings and green trees surround a central building; the subtitles generated by the mask strategy of the present invention are: some green trees and a parking lot are around a circle building., i.e., some green trees and a parking lot surround a circular building;

[0119] Figure 4 In (c), the subtitles generated by using the conventional training strategy are: it is a piece of yellow desert., i.e., this is a piece of yellow desert; the subtitles generated by using the mask strategy of the present invention are: some ripples are in a piece of yellow desert., i.e., there are some ripples in a piece of yellow desert;

[0120] Figure 4In (d), the subtitles generated by the conventional training strategy are: many buildings and some green trees are around a playground., i.e., there are many buildings and some green trees around the playground; the subtitles generated by the mask strategy of the present invention are: the playground consists of a red track and a green football field., i.e., the playground consists of a red track and a green football field;

[0121] Figure 4 In (e), the subtitles generated by the conventional training strategy are: many boats are in a port near many buildings. That is, many boats are in a port near many buildings; the subtitles generated by the mask strategy of the present invention are: several boats are in a port near a wharf. That is, several boats are parked in a port near the wharf;

[0122] Figure 4 In (f), the subtitles generated by the conventional training strategy are: many buildings and green trees are in a resort near a beach. That is, many buildings and green trees are in a resort near the beach; the subtitles generated by the mask strategy of the present invention are: several buildings with swimming pools are in aresort near a beach. That is, several buildings with swimming pools are in a resort near the beach;

[0123] from Figure 4 It can be found that the conventional training method often generates some single subtitle descriptions, such as many buildings and green trees; while the mask technology in the present invention is used to train the model, it can generate more diverse subtitle descriptions, such as waves, runways, docks, swimming pools, ripples, etc.

[0124] From Table 2 and Figure 4 It shows that the mask strategy used in the present invention has greatly improved the diversity of generated descriptions compared with conventional training methods without losing accuracy.

Claims

1. A topic-guided Transformer remote sensing image caption generation method, It is characterized in that include: 1) Pre-trained topic encoder: 1a) Obtain the training set and test set of the remote sensing caption generation dataset RSICD from the public website, and use the image names of the training set as the category labels and the images of the training set as the data to obtain the classification dataset; 1b) Build a topic encoder consisting of an embedding layer, a Transformer encoder, and a topic vector T; 1c) Using the classification dataset, the topic encoder is pre-trained by the gradient descent method to obtain a trained topic encoder; 2) Build a topic-guided Transformer remote sensing image caption generation network: 2a) Build a semantic decoder consisting of a cascade of random mask layers, embedding layers, Transformer decoders, and soft-max layers; 2b) Connect the trained topic encoder and semantic decoder to obtain a topic-guided Transformer remote sensing image caption generation network; 3) Iterative training of the topic-guided Transformer remote sensing image caption generation network: 3a) Set the maximum number of iterations E for network training and the initial learning rate Lr; 3b) Input the image in the training set from the topic encoder to obtain the image embedding feature V I and topic embedding feature V T ; 3c) Input the text data into the semantic decoder, first pass through its random mask layer to randomly replace some text with special identifiers [Mask], and then output the masked text embedding feature X through the embedding layer; 3d) Embed the topic into feature V T Concatenate with the masked text embedding feature X to get the topic text embedding feature X T ; 3e) Embed the topic text into feature X T Input to the self-attention layer in the semantic decoder to obtain the self-attention text embedding feature X S ; 3f) Embed the self-attention text into feature X S It is input into the interactive attention layer in the semantic decoder and combined with the image features V I Perform interactive attention calculation to obtain the interactive attention text embedding feature X I ; 3g) Embed the interactive attention text into feature X I As the input of the next decoding layer, use X I as the masked text embedding feature X in (3d); 3h) Repeat 3d) to 3g) to get the final semantic decoder output X F ; 3i) Output the final semantic decoder X F Input to the soft-max layer of the semantic decoder to obtain the probability distribution p of the generated description θ ; 3j) According to the probability distribution p of the generated description θ , calculate the cross entropy loss Loss; 3k) Perform back propagation based on the cross entropy loss Loss to update the network parameters; 3l) Repeat 3b) to 3k) until the maximum number of iterations E is reached, and a trained topic-guided Transformer remote sensing image caption generation network is obtained; 4) Input the test set remote sensing images into the trained topic-guided Transformer remote sensing image caption generation network to obtain the captions corresponding to the images.

2. The method according to claim 1, wherein the structure and function of each module in the theme encoder constructed in step 1b) are as follows: The embedding layer has a dimension of 768 and is used to map the image to high-dimensional features, which then interact with the text features; The Transformer encoder is composed of 12 basic encoders and a soft-max layer cascade. Each basic encoder is composed of a normalization layer, a multi-head attention layer, a normalization layer and a multi-layer perceptron cascade, which is connected to the embedding layer to extract the features of the image. The topic vector T is used to extract global semantic information in the image. It is a trainable parameter of the topic encoder. When the image features are input, the topic vector T and the image features are spliced ​​together. Through the multi-head attention module of the Transformer, the topic vector can interact with each image feature.

3. The method according to claim 1, wherein in step 1c), the subject encoder is pre-trained using a gradient descent method, which is implemented as follows: (1c1) Set the learning rate of pre-training to L and the maximum number of pre-training iterations to E pre ; (1c2) Concatenate the image data and the topic vector to obtain the input feature V of the topic encoder in ; (1c3) Input feature V in Input to the topic encoder to obtain the pre-trained image embedding feature V′ I , and the pre-trained topic embedding feature V′ T ; (1c4) Embed the pre-trained topic into feature V′ T Input into the existing soft-max layer to obtain the category estimation probability p; (1c5) Calculate the classification loss Loss based on the label and category estimated probability p c : in, i is the subscript of the category, p i is the estimated probability of the i-th category, C is the total number of categories, y i is the category label of the i-th category; (1c6) Update network parameters using gradient descent method based on classification loss Among them, α is the network parameter of the topic encoder to be updated, α′ is the network parameter of the updated topic encoder, and L is the learning rate of pre-training; (1c7) Repeat (1c2) to (1c6) until the maximum number of pre-training iterations E is reached. pre , and get the trained topic encoder.

4. The method according to claim 1, wherein in the semantic decoder constructed in step 2a), the structure and function of each module are as follows: The random mask layer is used to enhance the learning ability of the model and increase the diversity of generated text. The mask probability of the random mask layer is set to 0.3, that is, for each input word, there is a 30% probability of replacing it with a special identifier [Mask]; The embedding layer is used to map text information into a high-dimensional space, and then interact with image features. The embedding dimension of the embedding layer is set to 768; The Transformer decoder is used to generate text by combining subject information and image features, and is composed of two basic decoders, each of which is composed of a normalization layer, a self-attention layer, a normalization layer, an interactive attention layer, and a multi-layer perceptron cascade; The soft-max layer is used to generate the probability distribution of text descriptions.

5. According to the method described in claim 1, wherein in step 2b), the trained topic encoder is connected to the semantic decoder, and the output of the topic encoder is divided into two parts, one part is the topic feature and the other part is the image feature; the topic feature is connected to the self-attention layer in the semantic decoder, and the image feature is connected to the interactive attention layer in the semantic decoder.

6. The method according to claim 1, wherein in step 3d), the topic embedding feature V is calculated T The concatenated topic text embedding feature X T , the formula is as follows: X T =[V T ,X·M] in, V T is the topic embedding feature, X is the masked text embedding feature, and M is the lower triangular matrix.

7. The method according to claim 1, wherein in step 3e), the self-attention text embedding feature X is obtained S , which is expressed as follows: X s =Norm(X+MHA(X,X T ,X T )) in, X is the masked text embedding feature, X T is the topic text embedding feature, and Norm is the normalization operation; MHA is a multi-head attention mechanism, and its formula is as follows: MHA(Q,K,V)=Concat(head 1 ,head 2 ,...,head j ,...,head N )W Where Q, K, and V represent the query, key, and value vectors in the multi-head attention, respectively, j is the subscript of the attention head, and head j represents the jth attention head, N is the number of attention heads, W is the weight vector, d is the scale factor, is the weight matrix of the jth attention head.

8. The method according to claim 1, wherein in step 3f), the interactive attention text embedding feature X is calculated I , the formula is as follows: X I =Norm(X s +MHA(X s ,V I ,V I )) in, X s is the self-attention text embedding feature, V I is the image embedding feature, MHA is the multi-head attention mechanism, and Norm is the normalization operation.

9. The method according to claim 1, wherein in step 3j), the cross entropy loss Loss is calculated, and the formula is as follows: in, p θ is the probability distribution of the generated description, t is the current time step, Y t is the word at time t, Y mask 1:t-1 is the masked label sequence from time 1 to time t-1, and Len is the total length of the label sequence.

10. The method according to claim 1, wherein in step 3k), the network parameters are updated according to the following formula: Where θ is the network parameter to be updated, θ′ is the updated network parameter, is the partial derivative of the final loss with respect to the network parameter θ, and Lr is the preset learning rate.

Citation Information

Cited By

  • Remote sensing image semantic segmentation method based on multi-stage subtitle driven diffusion model

    CN121147524A