Hugging Face's logo Hugging Face
  • Models
  • Datasets
  • Spaces
  • Buckets new
  • Docs
  • Enterprise
  • Pricing
    • Website
      • Tasks
      • HuggingChat
      • Collections
      • Languages
      • Organizations
    • Community
      • Blog
      • Posts
      • Daily Papers
      • Hardware
      • Learn
      • Discord
      • Forum
      • GitHub
    • Solutions
      • Team & Enterprise
      • Hugging Face PRO
      • Enterprise Support
      • Inference Providers
      • Inference Endpoints
      • Storage Buckets

  • Log In
  • Sign Up

llava-hf
/
llava-onevision-qwen2-0.5b-ov-hf

Image-Text-to-Text
Transformers
ONNX
Safetensors
Transformers.js
English
Chinese
llava_onevision
vision
conversational
Model card Files Files and versions
xet
Community
11

Instructions to use llava-hf/llava-onevision-qwen2-0.5b-ov-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.

  • Libraries
  • Transformers

    How to use llava-hf/llava-onevision-qwen2-0.5b-ov-hf with Transformers:

    # Use a pipeline as a high-level helper
    from transformers import pipeline
    
    pipe = pipeline("image-text-to-text", model="llava-hf/llava-onevision-qwen2-0.5b-ov-hf")
    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, AutoModelForMultimodalLM
    
    processor = AutoProcessor.from_pretrained("llava-hf/llava-onevision-qwen2-0.5b-ov-hf")
    model = AutoModelForMultimodalLM.from_pretrained("llava-hf/llava-onevision-qwen2-0.5b-ov-hf", device_map="auto")
    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]:]))
  • Transformers.js

    How to use llava-hf/llava-onevision-qwen2-0.5b-ov-hf with Transformers.js:

    // npm i @huggingface/transformers
    import { pipeline } from '@huggingface/transformers';
    
    // Allocate pipeline
    const pipe = await pipeline('image-text-to-text', 'llava-hf/llava-onevision-qwen2-0.5b-ov-hf');
  • Notebooks
  • Google Colab
  • Kaggle
  • Local Apps Settings
  • vLLM

    How to use llava-hf/llava-onevision-qwen2-0.5b-ov-hf with vLLM:

    Install from pip and serve model
    # Install vLLM from pip:
    pip install vllm
    # Start the vLLM server:
    vllm serve "llava-hf/llava-onevision-qwen2-0.5b-ov-hf"
    # Call the server using curl (OpenAI-compatible API):
    curl -X POST "http://localhost:8000/v1/chat/completions" \
    	-H "Content-Type: application/json" \
    	--data '{
    		"model": "llava-hf/llava-onevision-qwen2-0.5b-ov-hf",
    		"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/llava-hf/llava-onevision-qwen2-0.5b-ov-hf
  • SGLang

    How to use llava-hf/llava-onevision-qwen2-0.5b-ov-hf 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 "llava-hf/llava-onevision-qwen2-0.5b-ov-hf" \
        --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": "llava-hf/llava-onevision-qwen2-0.5b-ov-hf",
    		"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 "llava-hf/llava-onevision-qwen2-0.5b-ov-hf" \
            --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": "llava-hf/llava-onevision-qwen2-0.5b-ov-hf",
    		"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 llava-hf/llava-onevision-qwen2-0.5b-ov-hf with Docker Model Runner:

    docker model run hf.co/llava-hf/llava-onevision-qwen2-0.5b-ov-hf
New discussion
Resources
  • PR & discussions documentation
  • Code of Conduct
  • Hub documentation

Number of tokens and features do not match: tokens: 1, features 729

πŸ˜”βž• 2
1
#11 opened about 1 year ago by
a826327700

What am I doing wrong?

#10 opened about 1 year ago by
TharriqTarjin

what's the difference between "ov" and "si" ?

πŸ‘βž• 2
#9 opened over 1 year ago by
cos0sin0

Can't reproduce given example (no meaningful output)

1
#8 opened over 1 year ago by
pzarzycki

Error for fine tuning model when using FSDP: auto wrap: Could not find the transformer layer class LlavaOnevisionVisionAttention in the model.

1
#6 opened almost 2 years ago by
liuzijing2014

Error when attempting to run either model... ValueError: embed_dim must be divisible by num_heads (got `embed_dim`: 1152 and `num_heads`: 14).

3
#4 opened almost 2 years ago by
jdc4429

Download transformers for LlavaOnevisionForConditionalGeneration

2
#1 opened about 2 years ago by
mjbooo
Company
TOS Privacy About Careers
Website
Models Datasets Spaces Pricing Docs