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)# pip install -U transformers accelerate # 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=256) 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 VideoLlama3ForConditionalGeneration
Browse files- config.json +3 -3
config.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
{
|
| 2 |
"architectures": [
|
| 3 |
-
"
|
| 4 |
],
|
| 5 |
"dtype": "bfloat16",
|
| 6 |
"image_token_id": 151655,
|
| 7 |
-
"model_type": "
|
| 8 |
"text_config": {
|
| 9 |
"architectures": [
|
| 10 |
"Qwen2ForCausalLM"
|
|
@@ -73,7 +73,7 @@
|
|
| 73 |
"initializer_range": 0.02,
|
| 74 |
"intermediate_size": 4304,
|
| 75 |
"layer_norm_eps": 1e-06,
|
| 76 |
-
"model_type": "
|
| 77 |
"num_attention_heads": 16,
|
| 78 |
"num_channels": 3,
|
| 79 |
"num_hidden_layers": 27,
|
|
|
|
| 1 |
{
|
| 2 |
"architectures": [
|
| 3 |
+
"VideoLlama3ForConditionalGeneration"
|
| 4 |
],
|
| 5 |
"dtype": "bfloat16",
|
| 6 |
"image_token_id": 151655,
|
| 7 |
+
"model_type": "video_llama_3",
|
| 8 |
"text_config": {
|
| 9 |
"architectures": [
|
| 10 |
"Qwen2ForCausalLM"
|
|
|
|
| 73 |
"initializer_range": 0.02,
|
| 74 |
"intermediate_size": 4304,
|
| 75 |
"layer_norm_eps": 1e-06,
|
| 76 |
+
"model_type": "video_llama_3_vision",
|
| 77 |
"num_attention_heads": 16,
|
| 78 |
"num_channels": 3,
|
| 79 |
"num_hidden_layers": 27,
|