Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

Conditional Prompt Learning for Vision-Language Models

About

With the rise of powerful pre-trained vision-language models like CLIP, it becomes essential to investigate ways to adapt these models to downstream datasets. A recently proposed method named Context Optimization (CoOp) introduces the concept of prompt learning -- a recent trend in NLP -- to the vision domain for adapting pre-trained vision-language models. Specifically, CoOp turns context words in a prompt into a set of learnable vectors and, with only a few labeled images for learning, can achieve huge improvements over intensively-tuned manual prompts. In our study we identify a critical problem of CoOp: the learned context is not generalizable to wider unseen classes within the same dataset, suggesting that CoOp overfits base classes observed during training. To address the problem, we propose Conditional Context Optimization (CoCoOp), which extends CoOp by further learning a lightweight neural network to generate for each image an input-conditional token (vector). Compared to CoOp's static prompts, our dynamic prompts adapt to each instance and are thus less sensitive to class shift. Extensive experiments show that CoCoOp generalizes much better than CoOp to unseen classes, even showing promising transferability beyond a single dataset; and yields stronger domain generalization performance as well. Code is available at https://github.com/KaiyangZhou/CoOp.

Kaiyang Zhou, Jingkang Yang, Chen Change Loy, Ziwei Liu• 2022

Related benchmarks

TaskDatasetResultRank
Image ClassificationImageNet-1k (val)--
1498
Person Re-IdentificationDuke MTMC-reID (test)
Rank-144.5
1023
Image ClassificationImageNet 1k (test)
Top-1 Accuracy71.02
880
Image ClassificationImageNet V2
Top-1 Acc64.2
749
Image ClassificationImageNet A
Top-1 Acc50.63
698
Image ClassificationStanford Cars
Accuracy71.88
660
Image ClassificationImageNet-1K
Top-1 Acc71.02
600
Image ClassificationDTD
Accuracy63.04
599
Image ClassificationImageNet-R
Top-1 Acc76.69
581
Image ClassificationFood-101
Accuracy90.7
570
Showing 10 of 662 rows
...

Other info

Code

Follow for update