A visual language model domain adaptation method based on adversarial double prompt learning, terminal and readable storage medium

Through the adversarial dual-cue learning method, combined with visual and text cues, the shortcomings of the visual language model in domain adaptation are solved, achieving higher accuracy and a more efficient training process, and adapting to samples from different fields and categories.

CN118334489BActive Publication Date: 2024-09-24SHANDONG UNIV OF FINANCE & ECONOMICS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410583218.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-11
Publication Date
2024-09-24
Estimated Expiration
2044-05-11

AI Technical Summary

Technical Problem

Existing cue learning techniques for visual language models cannot effectively solve the problem of domain adaptation, especially the failure to consider domain offsets, and the flexibility of visual encoders in domain adaptation is limited.

Method used

Adopt a method based on adversarial dual-cue learning to construct visual prompt words, source domain text prompt words, target domain text prompt words, and category-specific text prompt words. Text prompt words and visual prompt words are alternately learned through adversarial training, and integrated into In the collaboration framework, domain discriminators at the global level and category level are constructed to achieve domain alignment.

Benefits of technology

It improves the accuracy of domain adaptation tasks, reduces the number of model parameters, makes the training process more efficient, and can effectively handle domain adaptation tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118334489B
    Figure CN118334489B
Patent Text Reader

Abstract

The present invention provides a visual language model domain adaptation method based on adversarial dual-prompt learning, a terminal and a readable storage medium, which belong to the field of image processing technology, respectively construct relevant prompt words; input the prompt words into a text encoder together to obtain classification weights; then obtain the classification weights in the target domain; then obtain image visual features; generate pseudo labels for target domain images using the zero-sample inference capability of CLIP; alternately learn text prompt words and visual prompt words through adversarial training, thereby integrating text prompt learning and visual prompt learning into a collaborative framework; train text prompt words and visual prompt words, fix text prompt words, and maximize the prediction mutual information loss of target domain images, and maximize the domain discrimination loss of any image at the global level and category level. The domain discrimination and domain alignment at the global level and category level are realized, and the present invention improves the effect of domain adaptation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of image processing technology, and in particular relates to a visual language model domain adaptation method based on adversarial double-prompt learning, a terminal and a readable storage medium. Background Art

[0002] In the prior art, many basic visual-language models such as CLIP (Contrastive Language-Image Pretraining) are developed using large-scale image-text pairs on the Internet. These models are pre-trained to align the text and visual representations obtained from the text encoder and the visual encoder respectively. CLIP consists of a text encoder and a visual encoder. Transformer is generally selected as the text encoder and Vision Transformer (ViT) as the visual encoder.

[0003] The text encoder processes descriptions of specific classes. The description is usually in the form of "a photo of a[CLASS]", where [CLASS] represents the class name. It is then converted into m d word embedding The text encoder consists of L Transformer layers Word Embedding l With a unique stop sign are input to the lth layer together and processed by subsequent layers in sequence, that is, [s l+1 ,E l+1 ]=T l ([s l ,E l ]). Here [·,·] represents the connection operation. Finally, the last layer T L-1 The generated stop signs L Projected into the features of the input text: w = Proj t (s L ), where Proj t (·) is the projection layer of the text encoder.

[0004] The visual encoder takes an image x as input and first splits it into m v Fixed-size image patches are then projected into image patch embeddings There are also L Transformer layers in the visual encoder In the lth layer, the image block is embedded in P l and a learnable class label Used as input: [z l+1 ,Pl+1 ]=I l ([z l ,P l ]). The final representation of the image x can be obtained by using a linear projection layer f = Proj v (z L ) Process z L And obtain.

[0005] CLIP is pre-trained to determine whether an image corresponds to a category description. For the image classification task, the text encoder generates a description feature w for each category k∈{1,2,…,K} k The predicted probability of image x matching category k is calculated as follows:

[0006]

[0007] Among them, τ is the temperature parameter and cos(·,·) represents the cosine similarity. In this decision process, the text encoder plays the role of generating the classification weights w k The visual encoder is responsible for generating visual features f.

[0008] However, when adapting CLIP to downstream tasks, it is impractical to fine-tune the entire model due to its large number of parameters. Hint learning, as a popular parameter-efficient fine-tuning technique, freezes the parameters of a large model and attaches some learnable hint markers as additional input to guide CLIP.

[0009] Some current prompt learning methods, such as CoOp, pioneered the introduction of soft prompts in VLMs, demonstrating the effectiveness of carefully designed text prompts in improving image recognition performance. CoCoOp dynamically generates prompts for a single image by incorporating lightweight neural networks into the CoOp framework. VPT achieved significant performance improvements by effectively utilizing a small number of visual prompts in the context of the Transformer model. In addition, MaPLe enhances the alignment between text and image representations in CLIP by integrating text and visual prompts.

[0010] However, the above-mentioned hint learning methods cannot effectively solve domain adaptation tasks because they do not consider the domain shift problem in hint design. Based on this problem, DAPL integrates domain knowledge and category knowledge into hints, allowing VLMs to more effectively distinguish samples from different domains and categories. However, DAPL only focuses on hint learning for the language encoder while keeping the visual encoder unchanged, which may limit the flexibility of VLMs in solving domain adaptation problems. In addition, there is no domain alignment in DAPL, which means that the difference between the source domain and the target domain cannot be explicitly minimized. Summary of the invention

[0011] The present invention provides a visual language model domain adaptation method based on adversarial double prompt learning. The method is mainly to solve the problem that the prompt learning technology of the existing visual language model is not sufficient to effectively solve the unsupervised domain adaptation problem.

[0012] Methods include:

[0013] S101: construct visual prompt words, source domain text prompt words, target domain text prompt words and specific text prompt words for each category respectively;

[0014] S102: inputting the category name, source domain text prompt words and category-specific text prompt words into the text encoder to obtain the classification weights corresponding to each category in the source domain; similarly, inputting the category name, target domain text prompt words and category-specific text prompt words into the text encoder to obtain the classification weights corresponding to each category in the target domain; inputting an image and visual prompt words into the visual encoder to obtain the image visual features;

[0015] S103: For a source domain image, calculate the probability distribution of the source domain image belonging to each category based on its visual features and the classification weights corresponding to each category in the source domain; for a target domain image, calculate the probability distribution of the target domain image belonging to each category based on its visual features and the classification weights corresponding to each category in the target domain; at the same time, construct an additional classifier to determine the joint probability distribution of any image (source domain or target domain image) in domain and category. Based on the joint probability distribution, construct a global-level domain discriminator by comparing the marginal probabilities of the image in the source domain and the target domain; based on the joint probability distribution, construct a category-level domain discriminator by comparing the probability component of the image in a certain category in the source domain and the probability component of the category in the target domain;

[0016] S104: Generate pseudo labels for target domain images using CLIP’s zero-shot inference capability;

[0017] S105: Alternately learn textual cue words and visual cue words through adversarial training, thereby integrating textual cue learning and visual cue learning into a collaborative framework. During the training process, the following two steps are performed alternately, and finally domain alignment at the global level and category level is achieved;

[0018] S106: training text prompt words and fixing visual prompt words, on the one hand, minimizing the prediction classification loss of source domain images and target domain images respectively, and on the other hand, minimizing the domain discrimination loss of any image at the global level and category level respectively;

[0019] S107: Train visual prompt words and fix text prompt words to maximize the prediction mutual information loss of the target domain image on the one hand, and maximize the domain discrimination loss of any image at the global level and category level on the other hand;

[0020] It should be further explained that the step S101 also includes:

[0021] The text encoder consists of L Transformer blocks

[0022] For the lth Transformer block T l , respectively designed for the source domain and the target domain, including m d The text prompts of domain-specific prompt word units are respectively and express;

[0023] The textual hint also includes a set of m-containing c Category-specific cue units

[0024] The step S101 also includes:

[0025] The visual encoder contains L Transformer blocks

[0026] For the lth Transformer block I l , designed to include m v Visual cues for visual cues, using express;

[0027] Step S102 includes:

[0028] By or and Combine,domain information and category information into text prompts;

[0029] As shown in the following formula,

[0030]

[0031] E l and l Input to T l word embeddings and stop tags;

[0032] The classification weight of category k in the source domain is synthesized as shown in the following formula,

[0033]

[0034] Among them, Proj t (·) is the projection layer of the text encoder;

[0035] Similarly, the classification weight of category k in the target domain can be obtained

[0036] Transformer block I in the visual encoder l Insert visual cues And process it according to the following formula:

[0037] [z l+1 ,,P l+1 ]=I l ([z l ,V l ,P l ])

[0038] Among them, P l and z l is input to I l Image patch embedding and category labeling in ;

[0039] The visual representation of the final image is obtained by dividing z L It is sent to a linear projection layer for processing, as shown in the following formula:

[0040] f=Proj v (z L ).

[0041] It should be further explained that in step S103, two parallel classifiers are established for the source domain and the target domain respectively;

[0042] For images in the source domain The corresponding probability distribution is The kth element represents The probability of being classified as category k is calculated as follows:

[0043]

[0044] in represents the classification weights of all K categories in the source domain, f i s Represents the source image Visual features;

[0045] Similarly, for the target domain image Its probability distribution in different categories Obtained by the following formula,

[0046]

[0047] It should be further noted that an additional classifier is built in the method to determine the joint probability distribution p of the image on the domain and category. st ;

[0048] For any image x i ∈D s ∪D t , the joint probability distribution p st (x i )∈[0,1] 2K The calculation method is shown in the following formula:

[0049]

[0050] in, and Represents the input image x i The probability of belonging to source domain category k and target domain category k.

[0051] Step S104 includes:

[0052] Since the true labels of target domain samples are missing, the zero-shot inference capability of CLIP is used to generate pseudo labels for target domain samples.

[0053] use Represents the target image The pseudo-label of The confidence level is defined as

[0054] It should be further explained that the text prompt learning method in step S106 includes: training the source domain classifier p s To minimize the cross entropy loss on the labeled source domain samples, as shown in the following formula,

[0055]

[0056] Using the pseudo labels of the target domain samples, train the target classifier p t To minimize the cross entropy loss. During the training process, only pseudo labels with a confidence level exceeding the threshold γ are considered, that is:

[0057]

[0058] Among them, 1(·) is an indicator function that returns 1 if the input argument is true, otherwise it returns 0;

[0059] For all source domain images and target domain images, by training p st We further construct an implicit global-level domain discriminator using the binary cross entropy loss shown in the following formula:

[0060]

[0061] and can be expressed as x i as the marginal probability between the source domain image and the target domain image.

[0062] It should be further explained that in the method, a category-level discriminator is constructed for each category; the source domain images and the target domain images are divided into K subsets according to the categories respectively; is a subset of source domain images of category k, is the corresponding target domain image subset;

[0063] The category-level domain discriminator focuses on distinguishing source and target domain images in the same category by minimizing the following loss:

[0064]

[0065] in, and Represents the input image x i The probability of belonging to source domain category k and target domain category k;

[0066] For T l , learn text prompt words and The ultimate goal is as shown in the following formula

[0067]

[0068] Among them, α is a hyperparameter used to control the trade-off between classification loss and domain discrimination loss;

[0069] During this process, keep the visual cue V l constant.

[0070] It should be further explained that step S107 also includes:

[0071] In visual cue learning, by maximizing the domain discrimination loss at the global level and the category level and To perform domain alignment;

[0072] Maximize the mutual information loss predicted by the target classifier to improve its discriminative ability, as shown in the following formula,

[0073]

[0074] in, is the entropy function;

[0075] By optimizing the following formula, I l Visual cues in V l , while keeping the text prompt word and constant,

[0076]

[0077] Among them, β is a balancing hyperparameter.

[0078] The present invention also provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the visual language model domain adaptation method based on adversarial dual prompt learning are implemented.

[0079] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the visual language model domain adaptation method based on adversarial dual-prompt learning are implemented.

[0080] It can be seen from the above technical solutions that the present invention has the following advantages:

[0081] The visual language model domain adaptation method based on adversarial dual-cue learning provided by the present invention combines the classic adversarial training strategy with the cue learning technology for unsupervised domain adaptation. Unlike the existing work that simply jointly optimizes the text cues and visual cues in the visual language model, the present invention seamlessly integrates the text cue learning and the visual cue learning by performing adversarial training. In addition, the present invention effectively constructs domain discriminators at the global level and the category level by modeling the joint probability distribution of images in domains and categories. Compared with the existing methods, the present invention achieves higher accuracy in domain adaptation tasks. At the same time, since only visual and text cue words need to be trained, the model has relatively fewer parameters and the training process is more efficient. BRIEF DESCRIPTION OF THE DRAWINGS

[0082] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.

[0083] Figure 1 Flowchart of the domain adaptation method of visual language model based on adversarial dual-cue learning;

[0084] Figure 2Schematic diagram of using learnable textual and visual cues in various encoder blocks of CLIP;

[0085] Figure 3 Schematic diagram of parameter analysis and performance comparison on the Office-Home dataset. DETAILED DESCRIPTION

[0086] The domain adaptation method of visual language model based on adversarial dual-cue learning provided by the present invention introduces adversarial training into cue learning, and integrates text cues and visual cues into a collaborative framework by allowing them to participate in adversarial games. In text cue learning, the classifier is encouraged to distinguish between source domain and target domain samples while maintaining semantic understanding. In contrast, in visual cue learning, the visual encoder is encouraged to generate invariant features so that they are aligned.

[0087] The terms in this invention are explained as follows:

[0088] Unsupervised Domain Adaptation (UDA) is an important direction in the field of machine learning. It is hoped that the model trained in the source domain can be better generalized in the target domain. In this process, both the labeled data in the source domain and the unlabeled data in the target domain are used.

[0089] Adversarial Learning is a method to improve model performance by introducing adversarial training into the model. In adversarial learning, the generator and the discriminator compete with each other. The generator tries to generate realistic data to deceive the discriminator, while the discriminator strives to distinguish the generated data from the real data. This adversarial process encourages the generator to generate more realistic data, while also pushing the discriminator to better identify real data, ultimately reaching a dynamic balance.

[0090] Vision-Language Models (VLMs) are a class of models used to achieve deep interaction and joint understanding between vision and language. These models are usually composed of a text encoder and a visual encoder, and are designed to combine image and text information, so that visual and language data can be jointly modeled and processed, improving the model's ability to understand complex multimodal data.

[0091] Prompt Learning is an efficient method for fine-tuning machine learning models. With the popularity of large VLMs, fine-tuning the parameters of the entire VLM is often impractical given its huge parameter size, and may even damage the knowledge learned in the VLMs. Prompt Learning aims to freeze the parameters of VLMs while introducing only a small amount of learnable prompts as additional inputs, and guide the model to generate more accurate outputs by adjusting the input prompts.

[0092] like Figure 1 The flowchart of the preferred embodiment of the visual language model domain adaptation method based on adversarial double prompt learning of the present invention is shown. The visual language model domain adaptation method based on adversarial double prompt learning is applied to one or more terminals, which are devices that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and whose hardware includes but is not limited to microprocessors, application specific integrated circuits (ASIC), field programmable gate arrays (FPGA), digital signal processors (DSP), embedded devices, etc.

[0093] The terminal can be any electronic product that can perform human-computer interaction with a user, such as a personal computer, a tablet computer, a smart phone, a personal digital assistant (PDA), an interactive network television (IPTV), etc.

[0094] The terminal may also include network equipment and / or user equipment, wherein the network equipment includes, but is not limited to, a single network server, a server group consisting of multiple network servers, or a cloud consisting of a large number of hosts or network servers based on cloud computing.

[0095] The network where the terminal is located includes but is not limited to the Internet, wide area network, metropolitan area network, local area network, virtual private network (VPN), etc.

[0096] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0097] See also Figures 1 to 2 FIG. 1 is a flowchart of a method for domain adaptation of a visual language model based on adversarial dual-prompt learning in a specific embodiment, the method comprising:

[0098] S101: Construct visual prompt words, source domain text prompt words, target domain text prompt words and specific text prompt words for each category respectively.

[0099] S102: The category name, source domain text prompt words and category-specific text prompt words are input into the text encoder to obtain the classification weights corresponding to each category in the source domain. Similarly, the category name, target domain text prompt words and category-specific text prompt words are input into the text encoder to obtain the classification weights corresponding to each category in the target domain. An image and visual prompt words are input into the visual encoder to obtain the image visual features.

[0100] S103: For a source domain image, the probability distribution of the source domain image belonging to each category is calculated based on its visual features and the classification weights corresponding to each category in the source domain. For a target domain image, the probability distribution of the target domain image belonging to each category is calculated based on its visual features and the classification weights corresponding to each category in the target domain. At the same time, an additional classifier is constructed to determine the joint probability distribution of any image (source domain or target domain image) in domain and category. Based on the joint probability distribution, a global-level domain discriminator is constructed by comparing the marginal probabilities of the image in the source domain and the target domain. Based on the joint probability distribution, a category-level domain discriminator is constructed by comparing the probability component of the image in a certain category in the source domain and the probability component of the category in the target domain.

[0101] S104: Generate pseudo labels for target domain images using CLIP’s zero-shot inference capability.

[0102] S105: Alternately learn textual cue words and visual cue words through adversarial training, thereby integrating textual cue learning and visual cue learning into a collaborative framework. During the training process, the following two steps are performed alternately, and finally domain alignment at the global level and category level is achieved.

[0103] S106: Train text prompt words and fix visual prompt words to minimize the prediction classification loss of source domain images and target domain images respectively, and minimize the domain discrimination loss of any image at the global level and category level respectively.

[0104] S107: Train visual prompt words and fix text prompt words to maximize the prediction mutual information loss of the target domain image on the one hand, and maximize the domain discrimination loss of any image at the global level and category level on the other hand.

[0105] The visual language model domain adaptation method based on adversarial dual-cue learning involved in this embodiment does not need to introduce a separate discriminator for domain discrimination and domain alignment, but instead establishes an additional classifier to determine the joint probability distribution of all images in domains and categories. A global-level domain discriminator and a category-level domain discriminator can be implicitly constructed by comparing the components of the joint probability distribution of different categories and the components within a specific category. Thereby achieving global-level and category-level domain discrimination and domain alignment.

[0106] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0107] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to fully illustrate the specific implementation process in this embodiment, a specific implementation method of a visual language model domain adaptation method based on adversarial dual prompt learning is provided, and the method includes the following specific steps:

[0108] S201: Construct visual prompt words, source domain text prompt words, target domain text prompt words and specific text prompt words for each category respectively.

[0109] In an exemplary embodiment, the text encoder includes L Transformer blocks

[0110] For the lth Transformer block T l , respectively designed for the source domain and the target domain, including m d The text prompts of domain-specific prompt word units are respectively and express.

[0111] The textual hint also includes a set of m-containing c Category-specific cue units

[0112] Among them, the visual encoder contains L Transformer blocks

[0113] For the lth Transformer block I l , designed to include m v Visual cues for visual cues, using express.

[0114] S202: Input the category name, source domain text prompt words and category-specific text prompt words into the text encoder to obtain the classification weights corresponding to each category in the source domain. Input the category name, target domain text prompt words and category-specific text prompt words into the text encoder to obtain the classification weights corresponding to each category in the target domain. Input an image and visual prompt words into the visual encoder to obtain the image visual features.

[0115] Specifically, this embodiment is implemented by or and Combined, the domain information and category information are embedded into the text prompt. As shown in the following formula,

[0116]

[0117] E l and l Input to T l Word embeddings and stop tags.

[0118] The classification weight of category k in the source domain is synthesized as shown in the following formula,

[0119]

[0120] Among them, Proj t (·) is the projection layer of the text encoder.

[0121] Similarly, the classification weight of category k in the target domain can be obtained

[0122] Transformer block I in the visual encoder l Insert visual cues And process it according to the following formula:

[0123] [z l+1 ,,P l+1 ]=I l ([z l ,V l ,P l ])

[0124] Among them, Pl and z l is input to I l Image patch embeddings and category labels in .

[0125] The visual representation of the final image is obtained by dividing z L It is sent to a linear projection layer for processing, as shown in the following formula:

[0126] f=Proj v (z L ).

[0127] S203: For a source domain image, calculate the probability distribution of the source domain image belonging to each category according to the visual features and the classification weights corresponding to each category in the source domain.

[0128] For a target domain image, the probability distribution of the target domain image belonging to each category is calculated based on the visual features and the classification weights corresponding to each category in the target domain.

[0129] An additional classifier is constructed to determine the joint probability distribution of domains and categories for any image. Based on the joint probability distribution, a global domain discriminator is constructed by comparing the marginal probabilities of the image in the source domain and the target domain. Based on the joint probability distribution, a category-level domain discriminator is constructed by comparing the probability component of a category in the source domain with the probability component of the category in the target domain.

[0130] In this embodiment, two parallel classifiers are established in the source domain and the target domain respectively.

[0131] For images in the source domain The corresponding probability distribution is The kth element represents The probability of being classified as category k is calculated as follows:

[0132]

[0133] in represents the classification weights of all K categories in the source domain, f i s Represents the source image visual features.

[0134] Similarly, for the target domain image Its probability distribution in different categories Obtained by the following formula,

[0135]

[0136] Furthermore, this embodiment also establishes an additional classifier to determine the joint probability distribution p of the image in the domain and category. st .

[0137] For any image x i ∈D s ∪D t , the joint probability distribution p st (x i )∈[0,1] 2K The calculation method is shown in the following formula:

[0138]

[0139] in, and Represents the input image x i The probability of belonging to source domain category k and target domain category k.

[0140] S204: Generate pseudo labels for target domain images using CLIP’s zero-shot inference capability.

[0141] S205: Alternately learn textual cue words and visual cue words through adversarial training, thereby integrating textual cue learning and visual cue learning into a collaborative framework.

[0142] In an exemplary embodiment, due to the lack of true labels for target domain samples, the zero-shot inference capability of CLIP is utilized to generate pseudo labels for target domain samples.

[0143] use Represents the target image The pseudo-label of The confidence level is defined as

[0144] S206: Train text prompt words, fix visual prompt words, and minimize the prediction classification loss of source domain images and target domain images respectively, and minimize the domain discrimination loss of any image at the global level and category level respectively.

[0145] The text prompt learning method in this embodiment includes: training the source domain classifier p s To minimize the cross entropy loss on the labeled source domain samples, as shown in the following formula,

[0146]

[0147] Using the pseudo labels of the target domain samples, train the target classifier p t To minimize the cross entropy loss. During the training process, only pseudo labels with a confidence level exceeding the threshold γ are considered, that is:

[0148]

[0149] where 1(·) is an indicator function that returns 1 if the input argument is true and 0 otherwise.

[0150] For all source domain images and target domain images, by training p st We further construct an implicit global-level domain discriminator using the binary cross entropy loss shown in the following formula:

[0151]

[0152] and can be expressed as x i as the marginal probability between the source domain image and the target domain image.

[0153] In the method of this embodiment, a category-level discriminator is constructed for each category. The source domain images and the target domain images are divided into K subsets according to the categories. is a subset of source domain images of category k, is the corresponding target domain image subset.

[0154] The category-level domain discriminator focuses on distinguishing source and target domain images in the same category by minimizing the following loss:

[0155]

[0156] in, and Represents the input image x i The probability of belonging to source domain category k and target domain category k.

[0157] For T l , learn text prompt words and The ultimate goal is as shown in the following formula

[0158]

[0159] Among them, α is a hyperparameter used to control the trade-off between classification loss and domain discrimination loss.

[0160] During this process, keep the visual cue V l constant.

[0161] S207: Train the visual prompt words and fix the text prompt words to maximize the prediction mutual information loss of the target domain image, and maximize the domain discrimination loss of any image at the global level and category level respectively.

[0162] In visual cue learning, by maximizing the domain discrimination loss at the global level and the category level and To perform domain alignment.

[0163] Maximize the mutual information loss predicted by the target classifier to improve its discriminative ability, as shown in the following formula,

[0164]

[0165] in, is the entropy function.

[0166] By optimizing the following formula, I l Visual cues in V l , while keeping the text prompt word and constant,

[0167]

[0168] Among them, β is a balancing hyperparameter.

[0169] The method of this embodiment combines the classic adversarial learning concept with the cue learning technology for unsupervised domain adaptation. Unlike the direct joint optimization of text and visual cues in VLMs, the present invention seamlessly integrates text cue learning and visual cue learning by conducting adversarial training between them. Even without introducing an explicit domain discriminator, global-level and category-level adversarial training can be effectively performed by modeling the joint probability distribution of images in domains and categories, and the domain adaptation effect is significantly improved in this way.

[0170] The following experiment is conducted on the visual language model domain adaptation method based on adversarial dual-prompt learning involved in this embodiment. As shown in Table 1, the average accuracy of the method on the Office-31 dataset is better than other methods, and the highest accuracy is achieved in 4 of the 6 migration directions. In the remaining 2 directions, although the optimal experimental results are not achieved, the accuracy is still maintained at more than 95%. The transferability of CLIP can be greatly improved through prompt learning. The average accuracy of the method of the present invention exceeds CLIP by up to 14.7%. In addition, the method of the present invention is the only method among all methods with an average accuracy of more than 90%. It is 2.8% and 2.6% higher than the accuracy of VPT and MaPLe, respectively, both of which represent the most advanced single-modal and multi-modal prompt learning baselines.

[0171] Table 1 Performance comparison of hint-based learning methods on the Office-31 dataset Unit %

[0172]

[0173] As shown in Table 2, the method of the present invention achieved the best performance in all domain adaptation tasks of the Office-Home dataset, with an average accuracy of 86.7%, which is 2.3% to 4.6% higher than other methods. In particular, when C is used as the target domain, that is, in tasks AC, PC, and RC, the performance of all methods has declined. However, the method of the present invention shows a greater advantage than other methods, with an average improvement of at least 3.2%. This shows that the method of the present invention is better at handling challenging tasks than other methods.

[0174] Table 2 Performance comparison of hint-based learning methods on the Office-Home dataset Unit %

[0175]

[0176] Table 3 shows the experimental results of the variants of this model when different losses are omitted. and )’s performance is significantly lower than the original model.

[0177] On the Office-31 and Office-Home datasets, the average accuracy dropped by 3.3% and 2.7% respectively. or The variants of also lag behind the original model. These results show that adversarial learning plays a crucial role in our approach, and both global and category-level adversarial losses contribute to the performance improvement. In addition, experimental results show that eliminating the loss term This phenomenon emphasizes the importance of regularizing the target classifier in visual cue learning.

[0178] Table 3 Ablation experiment of different loss function contributions Unit %

[0179]

[0180] like Figure 3 As shown in the figure, our method outperforms other models on ResNet50 and ViT-B / 16, and has significantly fewer parameters. Since large models have inherent strong transferability, fixing a large number of training parameters and introducing a small number of trainable parameters can achieve favorable transfer effects with minimal training workload. Our method can achieve the highest accuracy while ensuring a small number of parameters. It performs better than the traditional UDA method that requires training a large number of parameters.

[0181] The visual language model domain adaptation method based on adversarial dual-prompt learning provided by the present invention is a unit and algorithm step of each example described in combination with the embodiments disclosed herein, and can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.

[0182] In a readable storage medium, a program product capable of implementing a visual language model domain adaptation method based on adversarial dual-prompt learning is stored. In some possible implementations, various aspects of the present disclosure may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary implementations of the present disclosure described in the above "Exemplary Method" section of this specification.

[0183] The readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0184] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for domain adaptation of visual language models based on adversarial dual-cue learning, characterized in that the method include: S101: construct visual prompt words, source domain text prompt words, target domain text prompt words and specific text prompt words for each category respectively; The text encoder consists of L Transformer blocks For the lth Transformer block Designed m for the source domain and target domain respectively d The text prompts of domain-specific prompt word units are respectively and express; Define a set of m for each category k c Category-specific cue units The visual encoder contains L Transformer blocks For the lth Transformer block Designed to include m v Visual cues for visual cues, using express; Step S102 includes: By or and Combine,domain information and category information into text prompts; As shown in the following formula, E l and l Input to word embeddings and stop tags; The classification weight of category k in the source domain is synthesized as shown in the following formula, Among them, Proj t (·) is the projection layer of the text encoder; Get the classification weight of category k in the target domain Transformer block in the visual encoder Insert visual cues And process it according to the following formula: Among them, P l and z l Is input to Image patch embedding and category labeling in ; The visual representation of the final image is obtained by dividing z L It is sent to a linear projection layer for processing, as shown in the following formula: f=For v (z L ); S102: inputting the category name, source domain text prompt words and category-specific text prompt words into a text encoder to obtain classification weights corresponding to each category in the source domain; The category name, target domain text prompt words and category-specific text prompt words are input into the text encoder to obtain the classification weights corresponding to each category in the target domain; an image and visual prompt words are input into the visual encoder to obtain the image visual features; S103: for a source domain image, according to the visual features and the classification weights corresponding to each category in the source domain, calculating the probability distribution of the source domain image belonging to each category; For a target domain image, the probability distribution of the target domain image belonging to each category is calculated based on the visual features and the classification weights corresponding to each category in the target domain; Construct an additional classifier to determine the joint probability distribution of domains and categories for any image; based on the joint probability distribution, construct a global domain discriminator by comparing the marginal probabilities of the image in the source domain and the target domain; based on the joint probability distribution, construct a category-level domain discriminator by comparing the probability component of a category in the source domain with the probability component of the category in the target domain; Two parallel classifiers were established for the source domain and the target domain respectively; For images in the source domain The corresponding probability distribution is The kth element represents The probability of being classified as category k is calculated as follows: in represents the classification weights of all K categories in the source domain, Represents the source image Visual features; For the target domain image Its probability distribution in different categories Obtained by the following formula, An additional classifier is also built in this method to determine the joint probability distribution p of the image on the domain and category. st ; For any image Joint probability distribution ps t (xi)∈[0,1] 2K The calculation method is shown in the following formula: in, and Represents the input image x i The probability of belonging to source domain category k and target domain category k; Leverage CLIP’s zero-shot inference capability to generate pseudo labels for target domain samples; use Represents the target image The pseudo-label of The confidence level is defined as S104: Generate pseudo labels for target domain images using CLIP’s zero-shot inference capability; S105: Alternately learn textual cues and visual cues through adversarial training, thereby integrating textual cue learning and visual cue learning into a collaborative framework; S106: training text prompt words, fixing visual prompt words, and minimizing the prediction classification loss of source domain images and target domain images respectively, and minimizing the domain discrimination loss of any image at the global level and category level respectively; Text prompt learning methods include: training source domain classifier p s To minimize the cross entropy loss on the labeled source domain samples, as shown in the following formula, Using the pseudo labels of the target domain samples, train the target classifier p t To minimize the cross entropy loss; during the training process, only pseudo labels with confidence levels exceeding the threshold γ are considered, that is: Among them, 1(·) is an indicator function that returns 1 if the input argument is true, otherwise it returns 0; For all source domain images and target domain images, by training p st We further construct an implicit global-level domain discriminator using the binary cross entropy loss shown in the following formula: and can be expressed as x i As the marginal probability of the source domain image and the target domain image; In this method, a category-level discriminator is constructed for each category; the source domain images and the target domain images are divided into K subsets according to the categories respectively; is a subset of source domain images of category k, is the corresponding target domain image subset; The category-level domain discriminator focuses on distinguishing source and target domain images in the same category by minimizing the following loss: in, and Represents the input image x i The probability of belonging to source domain category k and target domain category k; for Learn text prompt words and The ultimate goal is as shown in the following formula Among them, α is a hyperparameter used to control the trade-off between classification loss and domain discrimination loss; S107: Train the visual cue words and fix the text cue words to maximize the prediction mutual information loss of the target domain image, and maximize the domain discrimination loss of any image at the global level and category level respectively.

2. The method for domain adaptation of visual language model based on adversarial dual-prompt learning according to claim 1, characterized in that: Step S107 also includes: In visual cue learning, by maximizing the domain discrimination loss at the global level and the category level and To perform domain alignment; Maximize the mutual information loss predicted by the target classifier to improve its discriminative ability, as shown in the following formula, in, is the entropy function; Learn by optimizing the following formula Visual cues in V l , while keeping the text prompt word and constant, Among them, β is a balancing hyperparameter.

3. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the visual language model domain adaptation method based on adversarial dual-prompt learning as described in any one of claims 1 to 2 are implemented.

4. A non-transitory computer readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the visual language model domain adaptation method based on adversarial dual-prompt learning as described in any one of claims 1 to 2 are implemented.