Views
No views yet
1git lfs install
2git clone https://huggingface.co/omlab/omchat-v2.0-13B-single-beta_hf1from transformers import AutoModel, AutoProcessor, AutoTokenizer
2from PIL import Image
3import requests
4import torch
5from transformers import TextStreamer
6
7model = AutoModel.from_pretrained("omlab/omchat-v2.0-13B-single-beta_hf",trust_remote_code=True, torch_dtype=torch.float16).cuda().eval()
8processor = AutoProcessor.from_pretrained("omlab/omchat-v2.0-13B-single-beta_hf", trust_remote_code=True)
9
10url = "https://www.ilankelman.org/stopsigns/australia.jpg"
11image = Image.open(requests.get(url, stream=True).raw)
12prompt ="What's the content of the image?"
13inputs = processor(text=prompt, images=image, return_tensors="pt").to("cuda")
14
15with torch.inference_mode():
16 output_ids = model.generate(**inputs, max_new_tokens=1024, do_sample=False, eos_token_id=model.generation_config.eos_token_id, pad_token_id=processor.tokenizer.pad_token_id)
17
18outputs = processor.tokenizer.decode(output_ids[0, inputs.input_ids.shape[1] :]).strip()
19print (outputs)
20# The image features a stop sign in front of a Chinese archway, with a black car driving past. The stop sign is located on the left side of the scene, while the car is on the right side. There are also two statues of lions on either side of the archway, adding to the cultural ambiance of the scene.<|im_end|>
211@article{zhao2024omchat,
2 title={OmChat: A Recipe to Train Multimodal Language Models with Strong Long Context and Video Understanding},
3 author={Zhao, Tiancheng and Zhang, Qianqian and Lee, Kyusong and Liu, Peng and Zhang, Lu and Fang, Chunxin and Liao, Jiajia and Jiang, Kelei and Ma, Yibo and Xu, Ruochen},
4 journal={arXiv preprint arXiv:2407.04923},
5 year={2024}
6}