Official repository of OFA (ICML 2022). Paper: OFA: Unifying Architectures, Tasks, and Modalities Through a Simple Sequence-to-Sequence Learning Framework
Official repository of OFA (ICML 2022). Paper: OFA: Unifying Architectures, Tasks, and Modalities Through a Simple Sequence-to-Sequence Learning Framework
<br>
ModelScope | Checkpoints | Colab | Demo | Paper | Blog
<br>
OFA is a unified sequence-to-sequence pretrained model (support English and Chinese) that unifies modalities (i.e., cross-modality, vision, language) and tasks (finetuning and prompt tuning are supported): image captioning (1st at the MSCOCO Leaderboard), VQA (link), visual grounding, text-to-image generation, text classification, text generation, image classification, etc. We provide step-by-step instructions for pretraining and finetuning and corresponding checkpoints (check official ckpt [EN|CN] or Hugging Face ckpt).
We sincerely welcome contributions to our project. Feel free to contact us or send us issues / PRs!
We provide online demo via Hugging Face Spaces for you to interact with our pretrained and finetuned models. Below are the links to the demos:
Also we provide Colab notebooks for you to better perceive the procedures. Click here to check them out!
We support the inference of OFA in Hugging Face Transformers. Check the README and Colab Notebook for more information. Codes are released in this branch https://github.com/OFA-Sys/OFA/tree/feature/add_transformers
feature/MuE and PR for more information.bpe_dir=../../utils/BERT_CN_dict and bpe=bert and using our provided Chinese checkpoints in checkpoints_cn.md. Temporarily, we only provide base-size and large-size pretrained checkpoints and finetuned checkpoints on MUGE Caption and the Chinese version of RefCOCO(-/+/g) (to release soon). feature/add_transformers. --arch=ofa_huge in the script.
ofa_base.pt and change --arch=ofa_large to --arch=ofa_base in the training scripts.We list the parameters and pretrained checkpoints of OFAs below. For finetuned checkpoints, please refer to checkpoints.md.
| Model | Ckpt | Params | Backbone | Hidden size | Intermediate size | Num. of heads | Enc layers | Dec layers |
|---|---|---|---|---|---|---|---|---|
| OFATiny | Download | 33M | ResNet50 | 256 | 1024 | 4 | 4 | 4 |
| OFAMedium | Download | 93M | ResNet101 | 512 | 2048 | 8 | 4 | 4 |
| OFABase | Download | 180M | ResNet101 | 768 | 3072 | 12 | 6 | 6 |
| OFALarge | Download | 470M | ResNet152 | 1024 | 4096 | 16 | 12 | 12 |
| OFAHuge | Download | 930M | ResNet152 | 1280 | 5120 | 16 | 24 | 12 |
Below we demonstrate the results of OFAs on cross-modal understanding and generation.
| Task | Image Captioning | VQA | Visual Entailment | Referring Expression Comprehension | ||
|---|---|---|---|---|---|---|
| Dataset | COCO | VQA v2 | SNLI-VE | RefCOCO | RefCOCO+ | RefCOCOg |
| Split | Karpathy test (CE/CIDEr) | test-dev/test-std | val/test | val/test-a/test-b | val/test-a/test-b | val-u/test-u |
| Metric | CIDEr | Acc. | Acc. | Acc. | ||
| OFATiny | 119.0 / 128.7 | 70.3 / 70.4 | 85.3 / 85.2 | 80.20 / 84.07 / 75.00 | 68.22 / 75.13 / 57.66 | 72.02 / 69.74 |
| OFAMedium | 130.4 / 140.3 | 75.4 / 75.5 | 86.6 / 87.0 | 85.34 / 87.68 / 77.92 | 76.09 / 83.04 / 66.25 | 78.76 / 78.58 |
| OFABase | 138.2 / 146.7 | 78.0 / 78.1 | 89.3 / 89.2 | 88.48 / 90.67 / 83.30 | 81.39 / 87.15 / 74.29 | 82.29 / 82.31 |
| OFALarge | 142.2 / 150.7 | 80.4 / 80.7 | 90.3 / 90.2 | 90.05 / 92.93 / 85.26 | 85.80 / 89.87 / 79.22 | 85.89 / 86.55 |
| OFAHuge | 145.3 / 154.9 | 82.0 / 82.0 | 91.0 / 91.2 | 92.04 / 94.03 / 88.44 | 87.86 / 91.70 / 80.71 | 88.07 / 88.78 |
git clone https://github.com/OFA-Sys/OFA
pip install -r requirements.txtSee [datasets.md](dat
No open issues yet, or sync has not completed.