Views
No views yet
1from transformers import AutoProcessor, AutoModelForCausalLM
2from peft import PeftModel
3import torch
4from PIL import Image
5
6# Load the model
7processor = AutoProcessor.from_pretrained("Qwen/Qwen2.5-VL-32B-Instruct")
8base_model = AutoModelForCausalLM.from_pretrained(
9 "Qwen/Qwen2.5-VL-32B-Instruct",
10 torch_dtype=torch.bfloat16,
11 device_map="auto",
12 trust_remote_code=True
13)
14model = PeftModel.from_pretrained(
15 base_model,
16 "srai86825/qwen-vl-tool-assistant-lora"
17)
18
19# Use the model
20image = Image.open("your_image.jpg")
21text = "What is in this image?"
22
23inputs = processor(text=text, images=image, return_tensors="pt").to("cuda")
24outputs = model.generate(**inputs, max_new_tokens=100)
25result = processor.decode(outputs[0], skip_special_tokens=True)
26print(result)