Views
No views yet
Qwen2.5-VL-3B-Instruct).1vllm serve ilia-dybal/Qwen-2.5-VL-3b-Instruct-4bit-LoRA-culinary \
2 --trust-remote-code \
3 --max-model-len 4096 \
4 --limit-mm-per-prompt '{"image": 1}'1import base64
2from openai import OpenAI
3
4client = OpenAI(base_url="http://localhost:8000/v1", api_key="EMPTY")
5
6def encode_image(image_path):
7 with open(image_path, "rb") as f:
8 return f"data:image/jpeg;base64,{base64.b64encode(f.read()).decode('utf-8')}"
9
10response = client.chat.completions.create(
11 model="ilia-dybal/Qwen-2.5-VL-3b-Instruct-4bit-LoRA-culinary",
12 messages=[
13 {
14 "role": "user",
15 "content": [
16 {"type": "text", "text": "Analyze this dish and provide the recipe."},
17 {"type": "image_url", "image_url": {"url": encode_image("dish.jpg")}}
18 ]
19 }
20 ],
21 max_tokens=512
22)
23
24print(response.choices[0].message.content)1import torch
2from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration
3
4model_id = "ilia-dybal/Qwen-2.5-VL-3b-Instruct-4bit-LoRA-culinary"
5
6processor = AutoProcessor.from_pretrained(model_id)
7model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
8 model_id,
9 torch_dtype=torch.bfloat16,
10 device_map="auto"
11)
12
13# Prepare multimodal input
14messages = [
15 {
16 "role": "user",
17 "content": [
18 {"type": "image", "image": "[https://example.com/dish.jpg](https://example.com/dish.jpg)"},
19 {"type": "text", "text": "List the key ingredients in this photo."}
20 ]
21 }
22]
23
24text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
25inputs = processor(text=[text], images=None, return_tensors="pt").to("cuda")
26
27output_ids = model.generate(**inputs, max_new_tokens=512)
28print(processor.decode(output_ids[0], skip_special_tokens=True))