Views
No views yet
1from PIL import Image
2import requests
3from transformers import AutoProcessor, LlavaForConditionalGeneration
4
5model_path = "zzxslp/som-llava-v1.5-13b-hf"
6
7model = LlavaForConditionalGeneration.from_pretrained(model_path)
8processor = AutoProcessor.from_pretrained(model_path)
9
10prompt = "USER: <image>\nWhat's the content of the image? ASSISTANT:"
11url = "https://www.ilankelman.org/stopsigns/australia.jpg"
12image = Image.open(requests.get(url, stream=True).raw)
13
14inputs = processor(text=prompt, images=image, return_tensors="pt")
15
16# Generate
17generate_ids = model.generate(**inputs, max_new_tokens=20)
18output = processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
19print (output)@article{yan2024list,
title={List Items One by One: A New Data Source and Learning Paradigm for Multimodal LLMs},
author={Yan, An and Yang, Zhengyuan and Wu, Junda and Zhu, Wanrong and Yang, Jianwei and Li, Linjie and Lin, Kevin and Wang, Jianfeng and McAuley, Julian and Gao, Jianfeng and others},
journal={arXiv preprint arXiv:2404.16375},
year={2024}
}