Instructions to use lkhl/VideoLLaMA3-2B-Image-HF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lkhl/VideoLLaMA3-2B-Image-HF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="lkhl/VideoLLaMA3-2B-Image-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("lkhl/VideoLLaMA3-2B-Image-HF") model = AutoModelForMultimodalLM.from_pretrained("lkhl/VideoLLaMA3-2B-Image-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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use lkhl/VideoLLaMA3-2B-Image-HF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lkhl/VideoLLaMA3-2B-Image-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": "lkhl/VideoLLaMA3-2B-Image-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/lkhl/VideoLLaMA3-2B-Image-HF
- SGLang
How to use lkhl/VideoLLaMA3-2B-Image-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 "lkhl/VideoLLaMA3-2B-Image-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": "lkhl/VideoLLaMA3-2B-Image-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 "lkhl/VideoLLaMA3-2B-Image-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": "lkhl/VideoLLaMA3-2B-Image-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 lkhl/VideoLLaMA3-2B-Image-HF with Docker Model Runner:
docker model run hf.co/lkhl/VideoLLaMA3-2B-Image-HF
Upload processor
Browse files- chat_template.jinja +5 -7
- preprocessor_config.json +8 -2
- video_preprocessor_config.json +10 -6
chat_template.jinja
CHANGED
|
@@ -17,15 +17,13 @@ You are VideoLLaMA3 created by Alibaba DAMO Academy, a helpful assistant to help
|
|
| 17 |
{{- message['content'] -}}
|
| 18 |
{% else %}
|
| 19 |
{% for content in message['content'] %}
|
| 20 |
-
{% if content
|
| 21 |
-
{{- content -}}
|
| 22 |
-
{% elif content['type'] == 'text' or 'text' in content %}
|
| 23 |
{{- content['text'] -}}
|
| 24 |
-
{% elif content['type'] == 'image'
|
| 25 |
-
{{-
|
| 26 |
' -}}
|
| 27 |
-
{% elif content['type'] == 'video'
|
| 28 |
-
{{-
|
| 29 |
' -}}
|
| 30 |
{% endif %}
|
| 31 |
{% endfor %}
|
|
|
|
| 17 |
{{- message['content'] -}}
|
| 18 |
{% else %}
|
| 19 |
{% for content in message['content'] %}
|
| 20 |
+
{% if content['type'] == 'text' %}
|
|
|
|
|
|
|
| 21 |
{{- content['text'] -}}
|
| 22 |
+
{% elif content['type'] == 'image' %}
|
| 23 |
+
{{- '<|image_pad|>' + '
|
| 24 |
' -}}
|
| 25 |
+
{% elif content['type'] == 'video' %}
|
| 26 |
+
{{- '<|video_pad|>' + '
|
| 27 |
' -}}
|
| 28 |
{% endif %}
|
| 29 |
{% endfor %}
|
preprocessor_config.json
CHANGED
|
@@ -8,18 +8,24 @@
|
|
| 8 |
0.5,
|
| 9 |
0.5
|
| 10 |
],
|
| 11 |
-
"image_merge_size": 1,
|
| 12 |
"image_processor_type": "Videollama3ImageProcessor",
|
| 13 |
"image_std": [
|
| 14 |
0.5,
|
| 15 |
0.5,
|
| 16 |
0.5
|
| 17 |
],
|
|
|
|
| 18 |
"max_tokens": 16384,
|
|
|
|
|
|
|
| 19 |
"min_tokens": 16,
|
| 20 |
"patch_size": 14,
|
| 21 |
"processor_class": "Videollama3Processor",
|
| 22 |
"resample": 3,
|
| 23 |
"rescale_factor": 0.00392156862745098,
|
| 24 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
|
|
|
| 8 |
0.5,
|
| 9 |
0.5
|
| 10 |
],
|
|
|
|
| 11 |
"image_processor_type": "Videollama3ImageProcessor",
|
| 12 |
"image_std": [
|
| 13 |
0.5,
|
| 14 |
0.5,
|
| 15 |
0.5
|
| 16 |
],
|
| 17 |
+
"max_pixels": 3211264,
|
| 18 |
"max_tokens": 16384,
|
| 19 |
+
"merge_size": 1,
|
| 20 |
+
"min_pixels": 3136,
|
| 21 |
"min_tokens": 16,
|
| 22 |
"patch_size": 14,
|
| 23 |
"processor_class": "Videollama3Processor",
|
| 24 |
"resample": 3,
|
| 25 |
"rescale_factor": 0.00392156862745098,
|
| 26 |
+
"size": {
|
| 27 |
+
"longest_edge": 1003520,
|
| 28 |
+
"shortest_edge": 3136
|
| 29 |
+
},
|
| 30 |
+
"temporal_patch_size": 1
|
| 31 |
}
|
video_preprocessor_config.json
CHANGED
|
@@ -9,14 +9,13 @@
|
|
| 9 |
"do_pad": null,
|
| 10 |
"do_rescale": true,
|
| 11 |
"do_resize": true,
|
| 12 |
-
"do_sample_frames":
|
| 13 |
"fps": null,
|
| 14 |
"image_mean": [
|
| 15 |
0.5,
|
| 16 |
0.5,
|
| 17 |
0.5
|
| 18 |
],
|
| 19 |
-
"image_merge_size": null,
|
| 20 |
"image_std": [
|
| 21 |
0.5,
|
| 22 |
0.5,
|
|
@@ -24,16 +23,21 @@
|
|
| 24 |
],
|
| 25 |
"input_data_format": null,
|
| 26 |
"max_frames": 180,
|
| 27 |
-
"
|
| 28 |
-
"
|
|
|
|
|
|
|
| 29 |
"num_frames": null,
|
| 30 |
"patch_size": 14,
|
| 31 |
"processor_class": "Videollama3Processor",
|
| 32 |
"resample": 3,
|
| 33 |
"rescale_factor": 0.00392156862745098,
|
| 34 |
-
"size":
|
|
|
|
|
|
|
|
|
|
| 35 |
"size_divisor": null,
|
| 36 |
-
"
|
| 37 |
"video_metadata": null,
|
| 38 |
"video_processor_type": "Videollama3VideoProcessor"
|
| 39 |
}
|
|
|
|
| 9 |
"do_pad": null,
|
| 10 |
"do_rescale": true,
|
| 11 |
"do_resize": true,
|
| 12 |
+
"do_sample_frames": false,
|
| 13 |
"fps": null,
|
| 14 |
"image_mean": [
|
| 15 |
0.5,
|
| 16 |
0.5,
|
| 17 |
0.5
|
| 18 |
],
|
|
|
|
| 19 |
"image_std": [
|
| 20 |
0.5,
|
| 21 |
0.5,
|
|
|
|
| 23 |
],
|
| 24 |
"input_data_format": null,
|
| 25 |
"max_frames": 180,
|
| 26 |
+
"max_pixels": 12845056,
|
| 27 |
+
"merge_size": 2,
|
| 28 |
+
"min_frames": 4,
|
| 29 |
+
"min_pixels": 12544,
|
| 30 |
"num_frames": null,
|
| 31 |
"patch_size": 14,
|
| 32 |
"processor_class": "Videollama3Processor",
|
| 33 |
"resample": 3,
|
| 34 |
"rescale_factor": 0.00392156862745098,
|
| 35 |
+
"size": {
|
| 36 |
+
"longest_edge": 12845056,
|
| 37 |
+
"shortest_edge": 12544
|
| 38 |
+
},
|
| 39 |
"size_divisor": null,
|
| 40 |
+
"temporal_patch_size": 1,
|
| 41 |
"video_metadata": null,
|
| 42 |
"video_processor_type": "Videollama3VideoProcessor"
|
| 43 |
}
|