Views
No views yet


1from modelscope.pipelines import pipeline
2from modelscope.utils.constant import Tasks
3
4model_id = 'damo/mplug_visual-question-answering_coco_large_en'
5input_vqa = {
6 'image': 'https://alice-open.oss-cn-zhangjiakou.aliyuncs.com/mPLUG/image_mplug_vqa.jpg',
7 'question': 'What is the woman doing?',
8}
9
10pipeline_vqa = pipeline(Tasks.visual_question_answering, model=model_id)
11print(pipeline_vqa(input_vqa))
121datadict = MsDataset.load('coco_captions_small_slice')
2self.train_dataset = MsDataset(datadict['train'].to_hf_dataset().map(
3 lambda _: {
4 'question': 'what the picture describes?'
5 }).rename_column('image:FILE',
6 'image').rename_column('answer:Value', 'answer'))
7self.test_dataset = MsDataset(datadict['test'].to_hf_dataset().map(
8 lambda _: {
9 'question': 'what the picture describes?'
10 }).rename_column('image:FILE',
11 'image').rename_column('answer:Value', 'answer'))1kwargs = dict(
2 model='damo/mplug_visual-question-answering_coco_large_en',
3 train_dataset=self.train_dataset,
4 eval_dataset=self.test_dataset,
5 max_epochs=self.max_epochs,
6 work_dir=self.tmp_dir)
7
8trainer: EpochBasedTrainer = build_trainer(
9 name=Trainers.nlp_base_trainer, default_args=kwargs)
10trainer.train()

1@inproceedings{li2022mplug,
2 title={mPLUG: Effective and Efficient Vision-Language Learning by Cross-modal Skip-connections},
3 author={Li, Chenliang and Xu, Haiyang and Tian, Junfeng and Wang, Wei and Yan, Ming and Bi, Bin and Ye, Jiabo and Chen, Hehong and Xu, Guohai and Cao, Zheng and Zhang, Ji and Huang, Songfang and Huang, Fei and Zhou, Jingren and Luo Si},
4 year={2022},
5 journal={arXiv}
6}