Image-Text-to-Text
Transformers
Safetensors
English
qwen2_vl
multimodal
conversational
text-generation-inference
Instructions to use Qwen/Qwen2-VL-2B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qwen/Qwen2-VL-2B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Qwen/Qwen2-VL-2B-Instruct") 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("Qwen/Qwen2-VL-2B-Instruct") model = AutoModelForImageTextToText.from_pretrained("Qwen/Qwen2-VL-2B-Instruct") 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 Qwen/Qwen2-VL-2B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Qwen/Qwen2-VL-2B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Qwen/Qwen2-VL-2B-Instruct", "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/Qwen/Qwen2-VL-2B-Instruct
- SGLang
How to use Qwen/Qwen2-VL-2B-Instruct 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 "Qwen/Qwen2-VL-2B-Instruct" \ --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": "Qwen/Qwen2-VL-2B-Instruct", "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 "Qwen/Qwen2-VL-2B-Instruct" \ --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": "Qwen/Qwen2-VL-2B-Instruct", "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 Qwen/Qwen2-VL-2B-Instruct with Docker Model Runner:
docker model run hf.co/Qwen/Qwen2-VL-2B-Instruct
📋 Documentation Enhancement Suggestion
#35 opened 3 months ago
by
CroviaTrust
📋 Documentation Enhancement Suggestion
#34 opened 3 months ago
by
CroviaTrust
📋 Documentation Enhancement Suggestion
#33 opened 3 months ago
by
CroviaTrust
📋 Documentation Enhancement Suggestion
#32 opened 3 months ago
by
CroviaTrust
📋 Documentation Enhancement Suggestion
#31 opened 3 months ago
by
CroviaTrust
Qwen/Qwen2-VL-2B-Instruct
#30 opened 6 months ago
by
zzwtx
qwen2-vl-2B-instruct
#29 opened 6 months ago
by
zzwtx
Org chart Json Hierarchy
#28 opened 11 months ago
by
okayatul
How to use this model to get description of the video in javascript?
#27 opened about 1 year ago
by
zlelik
How to change the temperature of output generation??
#26 opened about 1 year ago
by
IronmanSnap
Whats the input syntax for SageMaker endpoint?
#25 opened about 1 year ago
by
Pelmenchik
RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cuda:0)
#24 opened over 1 year ago
by
zkkz17
尝试了一下Qwen2-VL-2B-Instruct
#23 opened over 1 year ago
by
jiuzhan
qwen2-vl-2b Image features and image tokens do not match
8
#22 opened over 1 year ago
by
novicetyro
IndexError: index 0 is out of bounds for dimension 0 with size 0
2
#21 opened over 1 year ago
by
saika1997
How to do batch inference on Qwen2-VL-2B-Instruct?
2
#20 opened over 1 year ago
by
dutta18
Can't spin this up in SageMaker
2
#19 opened over 1 year ago
by
Pelmenchik
inference time and memory usage of quantized version
👍 2
3
#18 opened over 1 year ago
by
DILLIP-KUMAR
ImportError: cannot import name 'Qwen2VLForConditionalGeneration' from 'transformers'
1
#17 opened over 1 year ago
by
MM-11
it run on cpu
8
#15 opened over 1 year ago
by
sdyy
How to use on multiple gpus?
#12 opened over 1 year ago
by
Chan-Y
How to use this for thousands of image with a good speed?
2
#11 opened over 1 year ago
by
the-sanyam
Hardware requirements
🔥 7
6
#10 opened over 1 year ago
by
ZahirHamroune
Update README.md
#9 opened over 1 year ago
by
Chan-Y
Failed to load Qwen2-VL using transformers built version(60226fd)
5
#7 opened over 1 year ago
by
Zoey1024
Update generation_config.json
#6 opened over 1 year ago
by
apanasenko
is the Custom handler.py File something i create myself? because looks like the qwen models dont come with it?
2
#5 opened over 1 year ago
by
whosii
gguf
👀➕ 14
2
#4 opened over 1 year ago
by
goodasdgood
mistakes
7
#3 opened over 1 year ago
by
goodasdgood