Image-Text-to-Text
Transformers
Safetensors
English
qwen2_vl
multimodal
conversational
Eval Results
text-generation-inference
Instructions to use Qwen/Qwen2-VL-7B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Qwen/Qwen2-VL-7B-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-7B-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-7B-Instruct") model = AutoModelForImageTextToText.from_pretrained("Qwen/Qwen2-VL-7B-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-7B-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-7B-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-7B-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-7B-Instruct
- SGLang
How to use Qwen/Qwen2-VL-7B-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-7B-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-7B-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-7B-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-7B-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-7B-Instruct with Docker Model Runner:
docker model run hf.co/Qwen/Qwen2-VL-7B-Instruct
Add ScreenSpot-Pro evaluation result (Qwen2-VL-7B)
#87 opened 2 months ago
by
merve
📋 Documentation Enhancement Suggestion
#86 opened 3 months ago
by
CroviaTrust
📋 Documentation Enhancement Suggestion
#85 opened 3 months ago
by
CroviaTrust
git
#84 opened 4 months ago
by
DayDay1234
Model size when loaded with bf16 and nf4
#81 opened about 1 year ago
by
mdmy
model load fails on transformers version 4.52.0
#80 opened about 1 year ago
by
jeffpeng
How are the weights of PatchEmbed initialized?
#79 opened about 1 year ago
by
idruker
按照主页示例输出失败
2
#78 opened about 1 year ago
by
YoloBird
Adding Evaluation Results
#77 opened about 1 year ago
by
Veinnn
[HELP] Slow and inaccurate inference using AWS SageMaker
#76 opened about 1 year ago
by
edwarddamato
[BUG] {'use_reentrant': True} results in "Gradients will be None"
2
#74 opened over 1 year ago
by
RonanMcGovern
Is it possible to get Image Embeddings from the VLM?
➕ 6
1
#73 opened over 1 year ago
by
AkshitPoiro
Model Evaluation
#72 opened over 1 year ago
by
Kartik-angadi
Anyone able to deploy an inference endpoint on sagemaker?
6
#71 opened over 1 year ago
by
TeoGX
Request for Prefixe tuning code
#70 opened over 1 year ago
by
ananthv
Mapping hidden states back to image patches
#68 opened over 1 year ago
by
dbasu
Concern about the performance while using multi image vs single image inference
#66 opened over 1 year ago
by
wiccanmind
GGUF Quants
#65 opened over 1 year ago
by
apepkuss79
GUI on windows for using this VL version?
#64 opened over 1 year ago
by
sebastienbo
怎么让其做目标检测,输出图像中物体的坐标?
1
#63 opened over 1 year ago
by
Wenrui3
Is it possible to only input text in Qwen/Qwen2-VL-7B-Instruct model?
1
#61 opened over 1 year ago
by
ai-bond
Inference api
#60 opened over 1 year ago
by
philip10
RuntimeError: cu_seqlens_q must have dtype int32
1
#59 opened over 1 year ago
by
ginnyyk
Update README.md
#58 opened over 1 year ago
by
mobi
testing for inference endpoints
3
#57 opened over 1 year ago
by
nbroad
transformers requirement
#53 opened over 1 year ago
by
nbroad
如果利用VL模型获取视觉层的Embedding
4
#52 opened over 1 year ago
by
weiminw
Updated README for GPU configuration.
#51 opened over 1 year ago
by
4blacks
Anyone can prompt input to show the exactly of image size?
#50 opened over 1 year ago
by
xJohn
Stable transformer version
1
#49 opened over 1 year ago
by
Jkppp
Is visual grounding possible on multiple images?
1
#48 opened over 1 year ago
by
echo-yi
How many tokens is one image?
2
#47 opened over 1 year ago
by
MoritzLaurer
RuntimeError: CUDA error: operation not permitted when stream is capturing
➕ 2
2
#46 opened over 1 year ago
by
yuyanggo
Adding Evaluation Results
#45 opened over 1 year ago
by
leaderboard-pr-bot
CUDA error: CUBLAS_STATUS_EXECUTION_FAILED
1
#44 opened over 1 year ago
by
yuyanggo
KeyError: 'qwen2_vl' loading from Transformers
1
#42 opened over 1 year ago
by
KevalRx
Batch inference on many images
1
#41 opened over 1 year ago
by
yadavsaakash
Handling multiple images in a pdf to preserve context during processing.
1
#40 opened over 1 year ago
by
ananthv
Questions about Naive Dynamic Resolution and the vision mask
1
#39 opened over 1 year ago
by
YaYaGeGe
it run on cpu
#38 opened over 1 year ago
by
sdyy
Request for Help: Passing an Image in cURL with vLLM
2
#36 opened over 1 year ago
by
ananthv
Ollama api setup for Qwen2
3
#35 opened over 1 year ago
by
RagulMahendran
Neto discussion
#34 opened over 1 year ago
by
Neto1780
An error occurred: shape mismatch
4
#33 opened over 1 year ago
by
VeeP
Finetuning script using HuggingFace (No llama-factory)
👍❤️ 11
39
#32 opened over 1 year ago
by
2U1
Able to successfully deploy as Inference Endpoint?
#31 opened over 1 year ago
by
philglazer
GGUF models
1
#30 opened over 1 year ago
by
mariahelenass
可以用来做多模态检索吗
➕ 5
#29 opened over 1 year ago
by
Lecheal