祛痣挂什么科| 小三阳吃什么药能转阴| 补牙属于口腔什么科| 骨折后吃什么好| 每天一杯蜂蜜水有什么好处| 承五行属什么| 为什么会得面瘫| 吃什么解酒| 申遗是什么意思| picc什么意思| 回声增强什么意思| 咳嗽吃什么好得快| 随访是什么意思| 医院介入科是干什么的| 焦点是什么| 仓鼠是什么科动物| 不可一世是什么意思| 肾疼是因为什么| 生姜放肚脐眼有什么功效| 单纯疱疹吃什么药| 生灵涂炭是什么意思| 97年的属什么生肖| 葳是什么意思| 方寸之地什么意思| 感冒为什么会全身酸痛无力| 金丝雀是什么意思| 黑猫警长为什么只有5集| 欧米茄算什么档次| 鲁迅为什么弃医从文| 鲱鱼罐头为什么这么臭| 六味地黄丸有什么副作用吗| 久坐脚肿是什么原因| 热爱是什么意思| 为什么发际线高| 场景是什么意思| 外聘是什么意思| 什么风什么什么| 为什么生理期不能拔牙| 脚气用什么药膏| 胡子长的快是什么原因| 导滞是什么意思| 腰疼不能弯腰是什么原因引起的| 超声检查是什么| 12月6号是什么星座| 晨尿浑浊是什么原因| 中国的国服是什么服装| 金是什么结构的字| 什么是海啸| 缺铁性贫血吃什么食物| 人流手术前需要注意什么| 喝红糖水有什么好处和坏处| 猪肝有什么功效与作用| 吃什么可以降胆固醇| 人在囧途是什么意思| mu是什么单位| 口腔溃疡喝什么水| 男人吃什么壮阳最快| 化名是什么意思| 汤姆福特属于什么档次| 腋下疼痛是什么原因| 气管疼什么原因引起的| 自卑是什么意思| cp是什么| 十一月是什么月| 维生素b2吃多了有什么副作用| 补充免疫力吃什么好| 后羿射日是什么意思| 生孩子需要准备什么东西| aoa是什么意思| 减肥期间晚上吃什么| 什么是极光| 肝内低密度影是什么意思| 囚徒是什么意思| 布洛芬0.3和0.4g有什么区别| 钱丢了预示着什么| 甲状腺球蛋白抗体高说明什么| 神经紊乱有什么症状| 已所不欲勿施于人是什么意思| blub是什么意思| 301医院院长什么级别| 为什么不建议年轻人做肠镜| 平均分是什么意思| 心脏24小时监测叫什么| 手麻木什么原因| 米面是什么| bell什么意思| 人为什么要吃饭| 慢性病都包括什么病| 什么是结扎| 6代表什么意思| 7月6号是什么星座| 唯小人与女子难养也什么意思| 偏头痛吃什么药最好| 什么动物没尾巴| 养胃吃什么| 练字用什么笔好| 肥胖纹长什么样| 跖疣是什么东西| 尚清是什么意思| 71年属什么生肖| 印第安老斑鸠什么意思| 2026年是什么生肖年| 邓超属什么生肖| 1942年是什么年| 牛肉饺子馅配什么蔬菜好吃| 7月13号是什么星座| 胶原蛋白起什么作用| 唐宝是什么意思| 大林木是什么生肖| 什么是冷暴力| 愚钝是什么意思| 房速是什么意思| 电动轮椅什么牌子质量好| 胆汁反流有什么症状| 牛欢喜是什么| 犹太人是什么意思| 一个点是什么字| 部队指导员是什么级别| 长卿是什么意思| 随波逐流什么意思| 缺乏维生素b12的症状是什么| 冬天怕冷夏天怕热是什么原因| 鸡皮肤用什么药膏最好| 脾虚可以吃什么水果| 中性粒细胞比率偏高是什么意思| 现役是什么意思| 一是什么意思| 坐西向东是什么宅| 锄禾是什么意思| 一个立一个羽念什么| 左脚大拇指麻木是什么原因| 匪气是什么意思| 发烧适合吃什么食物| 以爱之名什么意思| 双鱼座是什么星座| 廉租房和公租房有什么区别| 香港说什么语言| 如家是什么内涵| 口香糖是什么材料做的| 肝功能看什么科室| 男孩子什么时候刮胡子| 什么闻什么睹| minute什么意思| 喉咙痛可以吃什么水果| 美国为什么不敢动朝鲜| 左肩膀疼痛是什么原因| 海子是什么意思| 大脚骨疼是什么原因| 白内障有什么症状| 红色菜叶的菜是什么菜| 秸秆是什么| 溶栓治疗是什么意思| 什么药可以延长性功能| 各类病原体dna测定是检查什么| 口苦口干口臭吃什么药| 2019年属什么生肖| 3月5日是什么星座的| 心血虚吃什么中成药| 幻听一般会听到什么| 什么朝天| 迁坟需要准备什么东西| 咳嗽有痰吃什么好的快| 什么是八爪鱼| 舌吻是什么| 什么补血补气最好最快| 芡实不能和什么一起吃| cnn是什么意思| 肾钙化灶是什么意思| 党的执政理念是什么| 白细胞计数偏低是什么原因| 色戒讲的什么| 打生长激素有什么危害和副作用| 南瓜不能和什么一起吃| 太乙是什么意思| 家蛇是什么蛇| 基质是什么| 茉莉茶叶属于什么茶| 两性关系是什么意思| 血液粘稠会有什么症状| 鼻梁高的男人说明什么| 7月11是什么星座| 痔疮初期症状是什么| 坐飞机需要什么证件| 下眼皮肿是什么原因| 早上睡不醒是什么原因| 防晒隔离什么牌子好| 用什么方法止咳| 什么散步| 眉骨疼是什么原因| 半夜尿多是什么原因| 扁平苔藓有什么症状| 潜血阴性是什么意思| 尿酸过高是什么原因| 知性是什么意思| 痹病是什么意思| 因特网是什么意思| 成因是什么意思| 甲沟炎是什么原因引起的| 马来酸曲美布汀片什么时候吃| ipa是什么意思| 流清鼻涕是什么原因| 为什么出汗有酸臭味| 吃什么促进排便| 血管瘪是什么原因| 妥协是什么意思| 甲功是查什么的| 手脚肿胀是什么原因引起的| 碳素墨水用什么能洗掉| 红楼梦贾家为什么被抄家| 耳后淋巴结肿大挂什么科| 胃溃疡能吃什么水果| 申时五行属什么| 肚脐左边是什么器官| 喜欢趴着睡是什么原因| 肠胃湿热吃什么药| 一什么一笑| 宫颈糜烂用什么药好得快| 阴道炎症是什么症状| 腰眼疼是什么原因引起的| 口腔异味吃什么药| 6.16什么星座| 量贩式ktv是什么意思| 阔腿裤配什么鞋子好看| 加持什么意思| 七月初七是什么生肖| 弯脚杆是什么意思| 孟子是什么时期的人| 苜蓿是什么| 地衣是什么| 七一什么节| 千千结是什么意思| 牙疼吃什么药止痛快| 葡萄球菌用什么抗生素| 平均血小板体积偏高是什么意思| 眼角膜脱落有什么症状| 专科医院是什么意思| 红菜是什么菜| 女性尿急憋不住尿是什么原因| 魅可口红属于什么档次| 免疫力低下吃什么好| 什么的草原| 六月二十三号是什么星座| 长春都有什么大学| 失眠什么意思| 什么时候跳绳减肥效果最好| 蒲公英什么时候采最好| 中央委员是什么级别| 蚊子为什么吸血| 喉咙有痰挂什么科| 意有所指是什么意思| 血小板为0意味着什么| 投喂是什么意思| 窈窕淑女君子好逑是什么意思| 手发热是什么原因| 眉下有痣代表什么| 2014年什么年| 药物流产后需要注意什么| 减肥早餐吃什么| 世界上最大的岛是什么岛| 手汗症挂什么科| 肝风内动是什么原因造成的| 骨结核吃什么药效果好| 女生安全期是什么意思| 希特勒为什么要杀犹太人| 百度
Skip to content

NVlabs/prismer

Repository files navigation

Prismer

arXiv Hugginface Space

This repository contains the source code of Prismer and PrismerZ from the paper, Prismer: A Vision-Language Model with Multi-Task Experts. Check out our official demo at HuggingFace Space and a third-party demo at Replicate.

Update Log

  • Apr. 3, 2023: Improve HF Space demo with half precision inference and md5sum image check.
  • Mar. 22, 2023: Fix tensor mismatch problem for the updated transformers package.
  • Mar. 13, 2023: Add official HF Space demo.

Get Started

The implementation is based on PyTorch 1.13, and highly integrated with Huggingface accelerate toolkit for readable and optimised multi-node multi-gpu training.

First, let's install all package dependencies by running

pip install -r requirements.txt

Prepare Accelerator Config

Then we generate the corresponding accelerate config based on your training server configuration. For both single-node multi-gpu and multi-node multi-gpu training, simply run and follow the instructions with,

accelerate config

Datasets

Pre-training

We pre-train Prismer/PrismerZ with a combination of five widely used image-alt/text datasets, with pre-organised data lists provided below.

  • COCO 2014: the Karpathy training split (which will also be used for fine-tuning).
  • Visual Genome: the official Visual Genome captioning dataset.
  • CC3M + SGU: filtered and re-captioned by BLIP-Large.
  • CC12M: filtered and re-captioned by BLIP-Large.

The web datasets (CC3M, SGU, CC12M) is composed with image urls. It is highly recommended to use img2dataset, a highly optimised toolkit for large-scale web scraping to download these images. An example bash script of using img2dataset to download cc12m dataset is provided below.

img2dataset --url_list filtered_cc12m.json --input_format "json" --url_col "url" --caption_col "caption" --output_folder cc12m --processes_count 16 --thread_count 64 --image_size 256

Note: It is expected that the number of downloaded images is less than the number of images in the json file, because some urls might not be valid or require long loading time.

Image Captioning / VQA

We evaluate image captioning performance on two datasets, COCO 2014 and NoCaps; and VQA performance on VQAv2 dataset. In VQA tasks, we additionally augment the training data with Visual Genome QA, following BLIP. Again, we have prepared and organised the training and evaluation data lists provided below.

Generating Expert Labels

Before starting any experiments with Prismer, we need to first pre-generate the modality expert labels, so we may construct a multi-label dataset. In experts folder, we have included all 6 experts we introduced in our paper. We have organised each expert's codebase with a shared and simple API.

Note: Specifically for segmentation experts, please first install deformable convolution operations by cd experts/segmentation/mask2former/modeling/pixel_decoder/ops and run sh make.sh.

To download pre-trained modality experts, run

python download_checkpoints.py --download_experts=True

To generate the expert labels, simply edit the configs/experts.yaml with the corresponding data paths, and run

export PYTHONPATH=.
accelerate launch experts/generate_{EXPERT_NAME}.py

Note: Expert label generation is only required for Prismer models, not for PrismerZ models.

Experiments

We have provided both Prismer and PrismerZ for pre-trained checkpoints (for zero-shot image captioning), as well as fined-tuned checkpoints on VQAv2 and COCO datasets. With these checkpoints, it should be expected to reproduce the exact performance listed below.

Model Pre-trained [Zero-shot] COCO [Fine-tuned] VQAv2 [Fine-tuned]
PrismerZ-BASE COCO CIDEr [109.6] COCO CIDEr [133.7] test-dev [76.58]
Prismer-BASE COCO CIDEr [122.6] COCO CIDEr [135.1] test-dev [76.84]
PrismerZ-LARGE COCO CIDEr [124.8] COCO CIDEr [135.7] test-dev [77.49]
Prismer-LARGE COCO CIDEr [129.7] COCO CIDEr [136.5] test-dev [78.42]

To download pre-trained/fined-tuned checkpoints, run

# to download all model checkpoints (12 models in total)
python download_checkpoints.py --download_models=True

# to download specific checkpoints (Prismer-Base for fine-tuned VQA) in this example
python download_checkpoints.py --download_models="vqa_prismer_base"

Note: Remember to install java via sudo apt-get install default-jre which is required to run the official COCO caption evaluation scripts.

Evaluation

To evaluate the model checkpoints, please run

# zero-shot image captioning (remember to remove caption prefix in the config files)
accelerate launch train_caption.py --exp_name {MODEL_NAME} --evaluate

# fine-tuned image captioning
accelerate launch train_caption.py --exp_name {MODEL_NAME} --from_checkpoint --evaluate

# fine-tuned VQA
accelerate launch train_vqa.py --exp_name {MODEL_NAME} --from_checkpoint --evaluate

Training / Fine-tuning

To pre-train or fine-tune any model with or without checkpoints, please run

# to train/fine-tuning from scratch
accelerate launch train_{TASK}.py --exp_name {MODEL_NAME}

# to train/fine-tuning from the latest checkpoints (saved every epoch)
accelerate launch train_{TASK}.py --exp_name {MODEL_NAME} --from_checkpoint 

We have also included model sharding in the current training script via PyTorch's official FSDP plugin. With the same training commands, additionally add --shard_grad_op for ZeRO-2 Sharding (Gradients + Optimiser States), or --full_shard for ZeRO-3 Sharding (ZeRO-2 + Network Parameters).

Note: You should expect the error range for VQAv2 Acc. to be less than 0.1; for COCO/NoCAPs CIDEr score to be less than 1.0.

A Minimal Example

Finally, we have offered a minimal example to perform image captioning in a single GPU with our fine-tuned Prismer/PrismerZ checkpoint. Simply put your images under helpers/images (support .jpg, .jpeg, and .png images), and run

python demo.py --exp_name {MODEL_NAME}

You then can see all generated modality expert labels in the helpers/labels folder and the generated captions in the helpers/images folder.

Particularly for the Prismer models, we have also offered a simple script to prettify the generated expert labels. To prettify and visualise the expert labels as well as its predicted captions, run

python demo_vis.py

Note: Remember to set up the corresponding config in the configs/caption.yaml demo section. The default demo model config is for Prismer-Base.

Citation

If you found this code/work to be useful in your own research, please considering citing the following:

@article{liu2024prismer,
    title={Prismer: A Vision-Language Model with Multi-Task Experts},
    author={Liu, Shikun and Fan, Linxi and Johns, Edward and Yu, Zhiding and Xiao, Chaowei and Anandkumar, Anima},
    journal={Transactions on Machine Learning Research},
    year={2024}
}

License

Copyright ? 2023, NVIDIA Corporation. All rights reserved.

This work is made available under the Nvidia Source Code License-NC.

The model checkpoints are shared under CC-BY-NC-SA-4.0. If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.

For business inquiries, please visit our website and submit the form: NVIDIA Research Licensing.

Acknowledgement

We would like to thank all the researchers who open source their works to make this project possible. @bjoernpl for contributing an automated checkpoint download script.

Contact

If you have any questions, please contact sk.lorenmt@gmail.com.

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages

浸洗是什么意思 地中海贫血有什么症状 poppy什么意思 衣原体感染有什么症状 过三关 是什么意思
贫血孕妇吃什么补血最快 发烧吃什么食物 依靠是什么意思 什么是烂桃花 反流性食管炎可以吃什么水果
夏至该吃什么 山茶花是什么颜色 clarks是什么牌子 什么样的刘胡兰 nt什么时候做
女生吃什么补气血 什么像什么又像什么 饮鸩止渴是什么意思 吃鱼油有什么好处 窦骁的父母是干什么的
骨肉相连是什么肉hlguo.com 女人自尊心强说明什么hcv8jop4ns3r.cn 脑电图异常是什么病hcv8jop0ns3r.cn 群像是什么意思xinmaowt.com 膝盖窝疼是什么原因hcv8jop7ns6r.cn
一个鱼一个完读什么hcv7jop9ns7r.cn jio什么意思hcv9jop4ns1r.cn 顶礼是什么意思hcv9jop6ns0r.cn 蜂蜜为什么会结晶hcv7jop9ns9r.cn 蓝海是什么意思hcv7jop5ns6r.cn
448是什么意思hcv9jop4ns4r.cn 琬字五行属什么hcv8jop7ns9r.cn 屎发黑是什么原因hcv8jop0ns9r.cn 有缘无份什么意思xjhesheng.com 6是什么意思hcv8jop2ns0r.cn
书中自有颜如玉是什么意思hcv9jop0ns5r.cn 七月一是什么星座hcv9jop6ns6r.cn 现在有什么好的创业项目beikeqingting.com 什么床不能睡觉hcv8jop4ns3r.cn 艺考是什么hcv7jop9ns4r.cn
百度