GithubHelp home page GithubHelp logo

zzscorio / unicl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from microsoft/unicl

1.0 0.0 0.0 377 KB

[CVPR 2022] Official code for "Unified Contrastive Learning in Image-Text-Label Space"

License: MIT License

Python 100.00%

unicl's Introduction

This is the official Pytorch implementation of UniCL:

"Unifiled Contrastive Learning in Image-Text-Label Space. CVPR 2022" by Jianwei Yang*, Chunyuan Li*, Pengchuan Zhang*, Bin Xiao*, Ce Liu, Lu Yuan and Jianfeng Gao.

Introduction

In this paper, we introduce a new perspective on commonly used image-label and image-text data by residing them in an image-text-label space. In this space, a new learning paradigm, called Unified Contrastive Learning (UniCL) with a single learning objective is proposed to seamlessly prompt the synergy of two data types. We demonstrate that UniCL is an effective way of learning semantically rich yet discriminative representations, universally for image recognition in zero-shot, linear-probe, fully finetuning and transfer learning scenarios. When scaled up to billions of data, UniCL can exclusively learn a powerful visual-semantic representation supporting dozens of downstream tasks shown in Florence.

We make the comparisons between UniCL with coventional learning methods below:

Updates

  • ๐Ÿ’ฅ [10/05/2022] How do we use the pretrainied UniCL checkpoints? Beyond the zero-shot classification shown in our paper, we can use them for object detection. Now RegionCLIP supports to use pretrained UniCL transformer models, such as Swin, ViT for open-vocabulary object detection without any finetuning. Check it out!
  • [08/19/2022] Organizing ECCV Workshop Computer Vision in the Wild (CVinW), where two challenges are hosted to evaluate the zero-shot, few-shot and full-shot performance of pre-trained vision models in downstream tasks:

$\qquad$ [Workshop] $\qquad$ [IC Challenge] $\qquad$ [OD Challenge]

  • [06/19/2022] Released the evaluation benchmark used in UniCL, ELEVATER, which contains 20 downstream image classification tasks. More info: [Benchmark] [Toolkit] [Paper]
  • [06/04/2022] Checkout out our Huggingface Gradio demo.
  • [05/21/2022] Released pretrained model and zero-shot evaluation on ImageNet-1k.

Benchmarking

Image-label training augmented by image-text pairs

Model Training Set Top-1 on IN-1K ZS on 14 datasets Download
Swin-T IN-1K 79.9 30.2 ckpt/config
Swin-T IN-1K + GCC-3M 80.2 39.0 ckpt/config
Swin-T IN-1K + GYFCC-14M 81.1 40.0 ckpt/config
Swin-T IN-1K + GCC-15M 81.8 45.1 ckpt/config

Note that all the above models are trained without strong data augmentations like mixup and cutmix.

Image-text learning augmented by image-label data

Model Training Set ZS on IN-1K ZS on 14 datasets Download
Swin-T YFCC-14M 30.1 36.3 ckpt/config
Swin-T IN-21K 28.5 37.8 ckpt/config
Swin-T IN-21K (half) + YFCC-14M (half) 36.4 45.5 ckpt/config
Swin-T IN-21K + YFCC-14M 40.5 49.1 ckpt/config
Swin-B YFCC-14M 37.8 - ckpt/config
Swin-B IN-21K 29.9 42.4 ckpt/config
Swin-B IN-21K (half) + YFCC-14M (half) 41.1 48.5 ckpt/config
Swin-B IN-21K + YFCC-14M 44.3 52.2 ckpt/config
Swin-B IN-21K + YFCC-14M + GCC-15M 57.9 - ckpt/config

Getting Started

Installation

Please follow INSTALL.md for installation.

Data preparation

Please following DATA.md for data preparation.

Evaluation

To evaluate a pre-trained UniCL on ImageNet val, run:

python -m torch.distributed.launch --nproc_per_node <num-of-gpus-to-use> --master_port 12345 main.py --eval \
--cfg <config-file> --resume <checkpoint> --data-path <imagenet-path> 

For example, to evaluate the UniCL-Swin-Tiny trained on YFCC-14M with a single GPU:

python -m torch.distributed.launch --nproc_per_node 1 --master_port 12345 main.py --eval \
--cfg configs/unicl_swin_tiny.yaml --resume yfcc14m.pth --data-path <imagenet-path>

The Image Classification in the Wild Benchmark

Interested in evaluating UniCL for downstream image classification tasks, and comparing performance on the same task suite? We release ELEVATER benchmark, which has 20 downstream image classification tasks. The software toolkit is also released to ease the process to onboad new models. It will be hosted as a challenge at the CV in the Wild Workshop @ ECCV 2022. We hope our benchmark and toolkit can encourage the community to solve the challenge of image classification in the wild!

Please see more instructions: [Benchmark] [Toolkit] [Paper]

Citation

If you find this repo useful to your project, please consider to cite it with following bib:

@misc{yang2022unified,
    title={Unified Contrastive Learning in Image-Text-Label Space}, 
    author={Jianwei Yang and Chunyuan Li and Pengchuan Zhang and Bin Xiao and Ce Liu and Lu Yuan and Jianfeng Gao},
    year={2022},
    eprint={2204.03610},
    archivePrefix={arXiv},
    primaryClass={cs.CV}
}

Acknowledgement

Our codebase is built based on Swin Transformer, Focal Transformer and FocalNet.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

unicl's People

Contributors

jwyang avatar chunyuanli avatar anugunjnaman avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.