返回排行榜

KaiyangZhou/CoOp

Python

Prompt Learning for Vision-Language Models (IJCV'22, CVPR'22)

foundation-modelsmultimodal-learningprompt-learning
Star 增长趋势
Star
2.2k
Forks
233
周增长
Issues
64
1k2k
2021年9月2023年4月2024年12月2026年7月
制品库PyPIpip install coop
README

Prompt Learning for Vision-Language Models

This repo contains the codebase of a series of research projects focused on adapting vision-language models like CLIP to downstream datasets via prompt learning:

Updates

  • 07.10.2022: Just added to both CoOp and CoCoOp (in their appendices) the results on the newly proposed DOSCO (DOmain Shift in COntext) benchmark, which focuses on contextual domain shift and covers a diverse set of classification problems. (The paper about DOSCO is here and the code for running CoOp/CoCoOp on DOSCO is here.)

  • 17.09.2022: Call for Papers: IJCV Special Issue on The Promises and Dangers of Large Vision Models.

  • 16.07.2022: CoOp has been accepted to IJCV for publication!

  • 10.06.2022: Our latest work, Neural Prompt Search, has just been released on arxiv. It provides a novel perspective for fine-tuning large vision models like ViT, so please check it out if you're interested in parameter-efficient fine-tuning/transfer learning. The code is also made public here.

  • 08.06.2022: If you're looking for the code to draw the few-shot performance curves (like the ones we show in the CoOp's paper), see draw_curves.py.

  • 09.04.2022: The pre-trained weights of CoOp on ImageNet are released here.

  • 11.03.2022: The code of our CVPR'22 paper, "Conditional Prompt Learning for Vision-Language Models," is released.

  • 15.10.2021: We find that the best_val model and the last_step model achieve similar performance, so we set TEST.FINAL_MODEL = "last_step" for all datasets to save training time. Why we used best_val: the (tiny) validation set was designed for the linear probe approach, which requires extensive tuning for its hyperparameters, so we used the best_val model for CoOp as well for fair comparison (in this way, both approaches have access to the validation set).

  • 09.10.2021: Important changes are made to Dassl's transforms.py. Please pull the latest commits from https://github.com/KaiyangZhou/Dassl.pytorch and this repo to make sure the code works properly. In particular, 1) center_crop now becomes a default transform in testing (applied after resizing the smaller edge to a certain size to keep the image aspect ratio), and 2) for training, Resize(cfg.INPUT.SIZE) is deactivated when random_crop or random_resized_crop is used. Please read this issue on how these changes might affect the performance.

  • 18.09.2021: We have fixed an error in Dassl which could cause a training data loader to have zero length (so no training will be performed) when the dataset size is smaller than the batch size (due to drop_last=True). Please pull the latest commit for Dassl (>= 8eecc3c). This error led to lower results for CoOp in EuroSAT's 1- and 2-shot settings (others are all correct). We will update the paper on arxiv to fix this error.

How to Install

This code is built on top of the awesome toolbox Dassl.pytorch so you need to install the dassl environment first. Simply follow the instructions described here to install dassl as well as PyTorch. After that, run pip install -r requirements.txt under CoOp/ to install a few more packages required by CLIP (this should be done when dassl is activated). Then, you are ready to go.

Follow DATASETS.md to install the datasets.

How to Run

Click a paper below to see the detailed instructions on how to run the code to reproduce the results.

Models and Results

  • The pre-trained weights of CoOp (both M=16 & M=4) on ImageNet based on RN50, RN101, ViT-B/16 and ViT-B/32 can be downloaded altogether via this link. The weights can be used to reproduce the results in Table 1 of CoOp's paper (i.e., the results on ImageNet and its four variants with domain shift). To load the weights and run the evaluation code, you will need to specify --model-dir and --load-epoch (see this script for example).
  • The raw numerical results can be found at this google drive link.

Citation

If you use this code in your research, please kindly cite the following papers

@inproceedings{zhou2022cocoop,
    title={Conditional Prompt Learning for Vision-Language Models},
    author={Zhou, Kaiyang and Yang, Jingkang and Loy, Chen Change and Liu, Ziwei},
    booktitle={IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    year={2022}
}

@article{zhou2022coop,
    title={Learning to Prompt for Vision-Language Models},
    author={Zhou, Kaiyang and Yang, Jingkang and Loy, Chen Change and Liu, Ziwei},
    journal={International Journal of Computer Vision (IJCV)},
    year={2022}
}
相关仓库
hpcaitech/ColossalAI

Making large AI models cheaper, faster and more accessible

PythonPyPIApache License 2.0deep-learninghpc
colossalai.org
41.4k4.5k
haotian-liu/LLaVA

[NeurIPS'23 Oral] Visual Instruction Tuning (LLaVA) built towards GPT-4V level capabilities and beyond.

PythonPyPIApache License 2.0gpt-4chatbot
llava.hliu.cc
24.9k2.8k
microsoft/unilm

Large-scale Self-supervised Pre-training Across Tasks, Languages, and Modalities

PythonPyPIMIT Licensenlppre-trained-model
aka.ms/GeneralAI
22.2k2.7k
deepseek-ai/Janus

Janus-Series: Unified Multimodal Understanding and Generation Models

PythonPyPIMIT Licenseany-to-anyfoundation-models
17.8k2.2k
yzhao062/pyod

A Python library for anomaly detection across tabular, time series, graph, text, image, and audio data. 60+ detectors, benchmark-backed ADEngine orchestration, and an agentic workflow for AI agents.

PythonPyPIBSD 2-Clause "Simplified" Licenseoutlier-detectionanomaly-detection
pyod.readthedocs.io
9.9k1.5k
PriorLabs/TabPFN

⚡ TabPFN: Foundation Model for Tabular Data ⚡

PythonPyPIOtherdata-sciencefoundation-models
priorlabs.ai
7.6k759
datajuicer/data-juicer

Data processing for and with foundation models! 🍎 🍋 🌽 ➡️ ➡️🍸 🍹 🍷

PythonPyPIApache License 2.0data-analysisdata-science
datajuicer.github.io/data-juicer/
6.8k396
multimodal-art-projection/YuE

YuE: Open Full-song Music Generation Foundation Model, something similar to Suno.ai but open

PythonPyPIApache License 2.0foundation-modelsmusic-generation
map-yue.github.io
6.3k750
opensquilla/opensquilla

OpenSquilla — Token-Efficient AI Agent with same budget, higher intelligence density

PythonPyPIApache License 2.0agentai
opensquilla.ai
6.2k464
amazon-science/chronos-forecasting

Chronos: Pretrained Models for Time Series Forecasting

PythonPyPIApache License 2.0forecastinglarge-language-models
arxiv.org/abs/2510.15821
5.6k676
deepseek-ai/DeepSeek-VL

DeepSeek-VL: Towards Real-World Vision-Language Understanding

PythonPyPIMIT Licensevision-language-modelvision-language-pretraining
huggingface.co/spaces/deepseek-ai/DeepSeek-VL-7B
4.1k593
Nixtla/nixtla

TimeGPT-1: production ready pre-trained Time Series Foundation Model for forecasting and anomaly detection. Generative pretrained transformer for time series trained on over 100B data points. It's capable of accurately predicting various domains such as retail, electricity, finance, and IoT with just a few lines of code 🚀.

Jupyter NotebookOthertime-seriestime-series-forecasting
nixtla.io/docs
4k333