Image-Text-to-Text
Transformers
Safetensors
qwen2_5_vl
qwen2.5-vl
vision-language
conversational
text-generation-inference
Instructions to use patrickamadeus/Qwen2.5-VL-3B-Instruct-ft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use patrickamadeus/Qwen2.5-VL-3B-Instruct-ft with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="patrickamadeus/Qwen2.5-VL-3B-Instruct-ft") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("patrickamadeus/Qwen2.5-VL-3B-Instruct-ft") model = AutoModelForImageTextToText.from_pretrained("patrickamadeus/Qwen2.5-VL-3B-Instruct-ft") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use patrickamadeus/Qwen2.5-VL-3B-Instruct-ft with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "patrickamadeus/Qwen2.5-VL-3B-Instruct-ft" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "patrickamadeus/Qwen2.5-VL-3B-Instruct-ft", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/patrickamadeus/Qwen2.5-VL-3B-Instruct-ft
- SGLang
How to use patrickamadeus/Qwen2.5-VL-3B-Instruct-ft with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "patrickamadeus/Qwen2.5-VL-3B-Instruct-ft" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "patrickamadeus/Qwen2.5-VL-3B-Instruct-ft", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "patrickamadeus/Qwen2.5-VL-3B-Instruct-ft" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "patrickamadeus/Qwen2.5-VL-3B-Instruct-ft", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use patrickamadeus/Qwen2.5-VL-3B-Instruct-ft with Docker Model Runner:
docker model run hf.co/patrickamadeus/Qwen2.5-VL-3B-Instruct-ft
Qwen2.5-VL-3B-Instruct-ft
Native Qwen2.5-VL-format checkpoint converted from patrickamadeus/qwen2_5vl-1000.
This repository is loadable with the standard Qwen2.5-VL / Transformers API. It does not require the training repository's custom Qwen2_5VL, DistillPrefixVLM, or eval wrappers.
Install
pip install -U transformers accelerate qwen-vl-utils
Load
from transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration
model_id = "patrickamadeus/Qwen2.5-VL-3B-Instruct-ft"
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
model_id,
torch_dtype="auto",
device_map="auto",
)
processor = AutoProcessor.from_pretrained(model_id)
Text-only Inference
messages = [
{
"role": "user",
"content": [
{"type": "text", "text": "Explain what this model is useful for in one sentence."},
],
}
]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = processor(text=[text], padding=True, return_tensors="pt").to(model.device)
generated_ids = model.generate(**inputs, max_new_tokens=64)
generated_ids = [
output_ids[len(input_ids):]
for input_ids, output_ids in zip(inputs.input_ids, generated_ids)
]
response = processor.batch_decode(
generated_ids,
skip_special_tokens=True,
clean_up_tokenization_spaces=False,
)[0]
print(response)
Expected output: a short natural-language answer, for example a one-sentence description of the model's use.
Image + Text Inference
from qwen_vl_utils import process_vision_info
messages = [
{
"role": "user",
"content": [
{
"type": "image",
"image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
},
{"type": "text", "text": "Describe this image."},
],
}
]
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
image_inputs, video_inputs = process_vision_info(messages)
inputs = processor(
text=[text],
images=image_inputs,
videos=video_inputs,
padding=True,
return_tensors="pt",
).to(model.device)
generated_ids = model.generate(**inputs, max_new_tokens=128)
generated_ids = [
output_ids[len(input_ids):]
for input_ids, output_ids in zip(inputs.input_ids, generated_ids)
]
response = processor.batch_decode(
generated_ids,
skip_special_tokens=True,
clean_up_tokenization_spaces=False,
)[0]
print(response)
Expected output: a concise image description, typically mentioning the major objects and scene.
Source
- Base model:
Qwen/Qwen2.5-VL-3B-Instruct - Converted checkpoint:
patrickamadeus/qwen2_5vl-1000
- Downloads last month
- -
Model tree for patrickamadeus/Qwen2.5-VL-3B-Instruct-ft
Base model
Qwen/Qwen2.5-VL-3B-Instruct