How to load LLaVA-Med by LlavaForConditionalGeneration?
WenxiongLiao opened this issue · 1 comments
WenxiongLiao commented
How to load LLaVA-Med by LlavaForConditionalGeneration?
from PIL import Image
import requests
from transformers import AutoProcessor, LlavaForConditionalGeneration
model = LlavaForConditionalGeneration.from_pretrained("llava-hf/llava-1.5-7b-hf")
processor = AutoProcessor.from_pretrained("llava-hf/llava-1.5-7b-hf")
prompt = "<image>\nUSER: What's the content of the image?\nASSISTANT:"
url = "https://www.ilankelman.org/stopsigns/australia.jpg"
image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(text=prompt, images=image, return_tensors="pt")
generate_ids = model.generate(**inputs, max_length=30)
processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
Since LLaVA-Med is an extension of LLaVA, How to load LLaVA-Med by LlavaForConditionalGeneration?
bdne commented
The same question.