A method for style word diversification to achieve domain generalization via entropy maximization
Optimizing style word prompts through entropy maximization and style diversity constraints simulates visual feature diversity, solves the single-source domain generalization problem in remote sensing target recognition, and achieves high generalization and robustness under single-source domain data Classification performance.
Patent Information
- Application Number
- CN202411069095.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-08-06
AI Technical Summary
Traditional remote sensing target recognition algorithms fail to effectively consider the distribution differences between different data sets during training and testing, resulting in a decrease in classification accuracy. It is especially difficult to achieve high generalization in the case of a single source domain.
Optimize style word prompts through entropy maximization and style diversity loss constraints, generate diverse style word prompts, simulate visual feature diversity in feature space, use CLIP text encoder and image encoder to learn domain invariant features, and realize remote sensing Single-source domain generalization for object recognition.
By using only a single source domain data, the domain generalization performance of the classification network is improved, the robustness and classification accuracy of the model are enhanced, and the dependence on diverse image data is reduced.
Smart Images

Figure CN118587723B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer vision image processing and relates to a method for achieving domain generalization by diversifying style words through entropy maximization. Background Art
[0002] Remote sensing target recognition refers to the process of using algorithms to identify and classify ground objects based on the spectral characteristics, spatial characteristics, and temporal characteristics of the ground objects in remote sensing images. Remote sensing image target recognition technology can extract basic information from images and is the basis for many other remote sensing image processing studies. It is widely used in geographic surveying and mapping, military activities, and disaster relief. Early remote sensing target recognition work was mainly done manually. In recent years, with the continuous development of intelligent algorithms, neural networks have gradually occupied an increasingly important position in the field of remote sensing target recognition. The most widely used one is the ResNet network proposed in the paper "Deep Residual Learning for Image Recognition". It is an image classification network proposed by He et al. in the 2015 ImageNet large-scale visual recognition competition. It solves the gradient vanishing and gradient exploding problems and the degradation problem in deep networks by using BN layers and residual structures. In addition to traditional classification networks represented by ResNet, the idea of adversarial games can also be used to help train classification networks. In the paper "Generative Adversarial Nets", Ian Goodfellow et al. designed a GAN model using the mutual confrontation between the generator and the discriminator, and achieved higher-precision image classification through adversarial training of the two. In 2021, Alec Radford et al. proposed the CLIP model in the paper "Learning Transferable Visual Models From Natural Language Supervision", which uses text information to train a visual model with good transferability, and can achieve zero-sample classification on multiple data sets.
[0003] With the wide application of remote sensing image recognition technology in real life, some urgent problems have gradually emerged. One of them is the distribution difference between training data and target data, that is, the domain generalization problem. Most traditional remote sensing target recognition algorithms use data from the same domain for training and testing. The distribution difference between data in different data sets is not considered during model training. Therefore, they often face the problem of reduced classification accuracy in practical applications. In fact, in the field of remote sensing image processing, this distribution difference is very common. The image styles between different data sets are very different. It is difficult to maintain a high classification accuracy by directly applying a model trained on one data set to the target data set. Therefore, many new studies have been proposed to solve the domain generalization problem in the field of remote sensing target recognition. For example, Fan et al. used adaptive normalization and rescaling regularization in the paper "Adversarially adaptive normalization for single domain generalization" to make the learned statistical features better fit the data in different domains. Nam et al. proposed a style-ignoring network in "Reducing domain gap by reducing style bias". By randomizing the style in the latent feature space and separating the style from the category, the influence of image style differences on the network output results is reduced.
[0004] However, most existing domain generalization methods require the use of data from multiple domains for training, which is often difficult to meet in practical applications. The present invention is dedicated to solving the single-source domain generalization problem of remote sensing image recognition. During training, only one domain is used as the source domain without using data from other domains, and a model with high generalization can be trained. Summary of the invention
[0005] Aiming at the generalization problem in the remote sensing target recognition domain, the present invention designs style diversity loss and entropy maximization constraints to optimize style word cues, enforces the diversity of style word input, and then uses the learned diverse style word cues to simulate the diversity of visual features in the feature space, thereby achieving high generalization of the model while using only a single source domain data.
[0006] The technical solution of the present invention:
[0007] A method for achieving domain generalization by diversifying style words through entropy maximization is divided into two stages. The first stage learns style words and generates diversified style word prompts. The second stage uses the generated diversified style word prompts as the input of the CLIP text encoder to simulate the diversity of visual features in the feature space, guide the image encoder to learn domain invariant features, and finally achieve domain generalization of remote sensing target recognition.
[0008] In the first stage, the text encoder of CLIP is used to learn diverse text prompts; for a given source domain image and its corresponding label (i.e. category identifier) , first randomly initialize the style word prompt , and input it into the text encoder of CLIP to get the style word feature , and then the obtained style word features Transmitted to the classification head to obtain the prediction vector corresponding to the current input , where the classification head consists of a pooling layer, a flattening layer, and a fully connected layer; in addition, the style word prompt Category Identifier Combined to get the complete text prompt , also the text prompt Input CLIP's text encoder to generate text features , Then the prediction vector is obtained through classification head processing ; In order to make the style word prompts more diverse, the style word features output by the text encoder of CLIP Add style diversity constraints to force different style words to be different from each other, thereby constraining their diversity; similarly, for text features , and a style diversity constraint is added to it to further increase the diversity of style word prompts; therefore, the loss function corresponding to the final style diversity constraint is for:
[0009] (1)
[0010] in, represents the number of style word prompts, Indicates The style word features corresponding to the style word prompts are Indicates The text features corresponding to the complete text prompt;
[0011] In addition, the ideal style word prompt should not contain any category information. Therefore, the style word features generated by using only style words without combining them with category identifiers as input It should not contain any category information, when it is input into the classification head to generate the prediction vector When , it should be impossible to distinguish any category. It is not difficult to imagine that for the prediction vector , if the probability of the predicted input text belonging to each category is the same, it means that the style word cannot distinguish between categories, which means that the style word does not contain any category-related information. Translated into mathematical calculations, that is, when the prediction vector When its own entropy is the largest, it can meet the requirement that style words do not contain category information. Based on the above analysis, the prediction vector Adding entropy maximization constraint :
[0012] (2)
[0013] (3)
[0014] in, Indicates The entropy of the prediction vector corresponding to the style word prompt, Indicates that it belongs to The probability of the class, Indicates the total number of categories;
[0015] Secondly, while increasing the diversity of style word prompts, there is a special case. If the information learned by the style word is an orthogonal class that is unrelated to the target class (for example, the target class is cat, dog, tiger, and the style word represents an unrelated class, such as car), the above-mentioned diversity constraint and entropy maximization constraint can be met at this time, but it does not actually meet the learning goal of the present invention. In order to avoid the situation where the style word learns style information that is unrelated to the category information instead of an orthogonal class that is unrelated to the target class, the present invention performs a An additional classification loss is added as a constraint to ensure that the category can be correctly identified when the style word is combined with the category identifier, thus avoiding the above situation. The corresponding classification loss is the cross entropy loss :
[0016] (4)
[0017] in, Indicates The true label corresponding to the text prompt, Indicates The predicted label corresponding to the text prompt;
[0018] The total loss function of the first stage is:
[0019] (5)
[0020] After the first stage of training, we can get style word prompts containing various styles and information. The goal of the second stage is to use these style word prompts to help the classification network learn domain invariant features. Since the text features and visual features of CLIP are aligned in the feature space, we can use text prompts containing a variety of style information to generate diversified features in the feature space, and then align the visual features with them. In this way, we can achieve the diversity of visual features at the feature level while using only one source domain image without the need to use additional images from other domains. Specifically, the final style word prompts obtained in the first stage Category Identifier Combined to get the complete text prompt , and Input CLIP's text encoder to get text features , the source domain image Input classification network to get image features ; then calculate and The cosine similarity of ; In addition to the prediction vector Adding basic cross entropy loss In addition to ensuring the correctness of the classification results, three additional losses are added as constraints during the training process; first, for the prediction vectors obtained between images of different categories and the same text prompt, an orthogonal loss is added To ensure that the features generated between images of different categories in the feature space are far away from each other; secondly, for the prediction vectors obtained between images of the same category and text prompts containing different styles, a consistency constraint loss is added This will cause the network to only learn category information and ignore style information during the optimization process; finally, since the CLIP model itself has been pre-trained with massive data and has strong basic classification capabilities, in order to enable the classification network to better inherit the original classification capabilities of CLIP, the source domain image is input into the CLIP visual encoder to obtain image features , then and Add distillation loss between To help the classification network learn the pre-trained knowledge contained in the CLIP model.
[0021] (6)
[0022] (7)
[0023] (8)
[0024] in, represents the number of input images, Indicates that it contains The text prompts of the style words and the The prediction result between the input images is express and The Euclidean distance between express The mean value of , express and The KL divergence between them.
[0025] Therefore, the total loss function of the second stage is:
[0026] (9).
[0027] Beneficial effects of the present invention: The present invention uses the pre-trained CLIP model to help the classification network learn domain-invariant features using only one source domain data. In the first stage, style word prompts containing multiple styles are generated through style diversity constraints and entropy maximization constraints; in the second stage, the diversity of visual features is simulated in the feature space using diversified style word prompts, reducing the dependence of the classification network on diversified image data and improving the domain generalization performance of the classification network, thereby making the classification network more robust in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 Schematic diagram for diverse style word prompt generation.
[0029] Figure 2 Framework for learning domain-invariant features using diverse style word cues. DETAILED DESCRIPTION
[0030] The specific implementation of this patent is further explained below in combination with the accompanying drawings and technical solutions.
[0031] The present invention is mainly divided into two stages. The schematic diagram of the first stage is as follows: Figure 1 First, the style word prompt is randomly initialized and input into the text encoder of CLIP to obtain several style word features, and style diversity constraints are added to these style word features. To increase the difference between style word prompts. Then input the style word features into the classification head to obtain the corresponding prediction vector , for the prediction vector Adding entropy maximization constraint , ensuring that the style word prompt contains only style information but not category information. Finally, in order to avoid the extreme situation that the style word prompt learns an orthogonal class that is irrelevant to the target class, the present invention combines the style word with the category identifier as input, obtains the corresponding prediction result through the CLIP text encoder and classification head, and applies the classification loss to the final result This avoids extreme situations.
[0032] After the first stage, the style word prompts containing various style information are combined with the category identifiers to generate complete text prompts. Then, the diverse text prompts and CLIP encoders are used to simulate the diversity of visual features to help the classification network learn domain-invariant features. The specific process is as follows: Figure 2 As shown. The input image is processed by the classification network to obtain image features, and the text prompt is processed by the CLIP text encoder to obtain text features. The cosine similarity between the two is calculated to obtain the prediction vector ,right Adding forecast consistency constraints and orthogonality constraints To guide the classification network to learn domain invariant features and calculate the classification loss between them and the true label Finally, to help the classification network learn the underlying classification capabilities of CLIP, a distillation loss is calculated between the image features produced by the classification network and the image features produced by the CLIP visual encoder. .
[0033] In general, the core idea of the present invention is to train a classification network that can generate domain-invariant features when training data is scarce. The diversity of image features is simulated by making full use of the fact that text features and image features of CLIP are aligned in feature space. Even if only image data from one source domain can be used during training, diversified image features can be obtained by aligning with diversified text features, thereby helping the classification network learn domain-invariant features and ultimately achieving domain generalization of image classification tasks.
Claims
1. A method for diversifying style words to achieve domain generalization through entropy maximization, It is characterized in that This method of style word diversification through entropy maximization to achieve domain generalization consists of two stages; In the first stage, the text encoder of CLIP is used to learn diverse text prompts; for a given source domain image and its corresponding label, i.e., category identifier , first randomly initialize the style word prompt , and input it into the text encoder of CLIP to get the style word feature , and then the obtained style word features Transmitted to the classification head to obtain the prediction vector corresponding to the current input , where the classification head consists of a pooling layer, a flattening layer, and a fully connected layer; in addition, the style word prompt Category Identifier Combined to get the complete text prompt , the text prompt Input CLIP's text encoder to generate text features , Then the prediction vector is obtained through classification head processing ; In order to make the style word prompts more diverse, the style word features output by the text encoder of CLIP Add style diversity constraints to force different style words to be different from each other, thereby constraining their diversity; similarly, for text features , and a style diversity constraint is added to it to further increase the diversity of style word cues; therefore, the loss function corresponding to the style diversity constraint is for: (1) in, represents the number of style word prompts, Indicates The style word features corresponding to the style word prompts are Indicates The text features corresponding to the complete text prompt; The idealized style word prompt does not contain any category information. Therefore, the style word features generated by using only the style word prompt without combining it with the category identifier as input It does not contain any category information, and when it is input into the classification head to generate the prediction vector When , it is impossible to distinguish any category; for the prediction vector , if the probability of the predicted input text belonging to each category is the same, it means that the style word prompt cannot distinguish between categories, which means that the style word prompt does not contain any category-related information; converted to mathematical calculation, that is, when the prediction vector When its own entropy is the largest, it can meet the requirement that style words do not contain category information; based on this, the prediction vector Adding entropy maximization constraint : (2) (3) in, Indicates The entropy of the prediction vector corresponding to the style word prompt, Indicates that it belongs to The probability of the class, Indicates the total number of categories; In order to avoid that the style words learn style information that is irrelevant to the category information, the prediction vector Add a classification loss as a constraint to ensure that the category can be correctly distinguished when the style word is combined with the category identifier; the classification loss is the cross entropy loss : (4) in, Indicates The true label corresponding to the text prompt, Indicates The predicted label corresponding to the text prompt; The total loss function of the first stage is: (5) After the first stage of training, style word prompts containing various style information are obtained; the second stage is to use the obtained style word prompts to help the classification network learn domain invariant features; because the text features and visual features of CLIP are aligned in the feature space, the text prompts containing multiple style information are used to generate diversified features in the feature space, and then the visual features are aligned with them, so that the diversity of visual features can be achieved at the feature level when only one source domain image is used without the need to use additional images from other domains; the details are as follows: the final style word prompts obtained in the first stage are used Category Identifier Combined to get the complete text prompt , and Input CLIP's text encoder to get text features , the source domain image Input classification network to get image features ; then calculate and The cosine similarity of ; In addition to the prediction vector Adding cross entropy loss In addition to ensuring the correctness of the classification results, three additional losses are added as constraints during the training process; first, for the prediction vectors obtained between images of different categories and the same text prompt, an orthogonal loss is added To ensure that the features generated between images of different categories in the feature space are far away from each other; secondly, for the prediction vectors obtained between images of the same category and text prompts containing different styles, a consistency constraint loss is added This will cause the network to only learn category information and ignore style information during the optimization process; finally, the source domain image is input into the CLIP visual encoder to obtain image features , then and Add distillation loss between To help the classification network learn the pre-trained knowledge contained in the CLIP model; (6) (7) (8) in, represents the number of input images, Indicates that it contains The text prompts of the style words and the The prediction result between the input images is express and The Euclidean distance between express The mean value of , express and The KL divergence between Therefore, the total loss function of the second stage is: (9)。
Citation Information
Patent Citations
Product appearance style evaluation method and system based on image and text multi-modal data
CN112862569A
Image semantic understanding and text generation based on fine-grained visual information control network
CN114972848A
Text-pedestrian retrieval method based on bounding box extraction and semantic consistency constraint
CN116842212A
Training method for character generation model, character generation method, apparatus, and medium
US20220189083A1
Counterfactual Text Stylization
US20230137209A1
