Image-Text-to-Text
Transformers
Safetensors
English
Chinese
llava
vision-language
llm
lmm
conversational
Instructions to use bczhou/tiny-llava-v1-hf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bczhou/tiny-llava-v1-hf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="bczhou/tiny-llava-v1-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("bczhou/tiny-llava-v1-hf") model = AutoModelForMultimodalLM.from_pretrained("bczhou/tiny-llava-v1-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 bczhou/tiny-llava-v1-hf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "bczhou/tiny-llava-v1-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": "bczhou/tiny-llava-v1-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/bczhou/tiny-llava-v1-hf
- SGLang
How to use bczhou/tiny-llava-v1-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 "bczhou/tiny-llava-v1-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": "bczhou/tiny-llava-v1-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 "bczhou/tiny-llava-v1-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": "bczhou/tiny-llava-v1-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 bczhou/tiny-llava-v1-hf with Docker Model Runner:
docker model run hf.co/bczhou/tiny-llava-v1-hf
Commit History
-
Update README.md
Verified signature70f28eb
-
Update README.md
Verified signature1eb14fd
-
Update README.md
Verified signature7c46f5f
-
Update README.md
Verified signaturee5aaeb2
-
Update README.md
Verified signature507d5f6 -
Update README.md
Verified signature6846de5 -
Update README.md
Verified signature543bb42
-
Update README.md
Verified signature41071f3 -
Update README.md
Verified signature69db306 -
Update README.md
Verified signaturefedff3e -
Update README.md
Verified signaturea359739 -
Update README.md
Verified signature8d3105c -
Update README.md
Verified signature3420145 -
Update README.md
Verified signature20abc8b -
Update README.md
Verified signatureb83932c -
Update README.md
Verified signature858c854 -
Update README.md
Verified signature94d6742 -
Update README.md
Verified signature0944aa0
-
Update README.md
Verified signatureb08ccca -
Update README.md
Verified signature282a049 -
Upload processor
Verified signature3ec93eb -
Upload LlavaForConditionalGeneration
Verified signaturedc2dba4 -
create model card
Verified signaturefd01149 -
Create README.md
Verified signature**Model type:** TinyLLaVA, a tiny model (1.4B) trained using the exact recipe of [llava](https://github.com/haotian-liu/LLaVA). We trained our TinyLLaVA using [TinyLlama](https://huggingface.co/PY007/TinyLlama-1.1B-Chat-v0.3) as our LLM backbone, and [clip-vit-large-patch14-336](https://huggingface.co/openai/clip-vit-large-patch14-336) as our vision backbone. **Model use:** The weights have been converted to hf format. ## How to use the model First, make sure to have `transformers >= 4.35.3`. The model supports multi-image and multi-prompt generation. Meaning that you can pass multiple images in your prompt. Make sure also to follow the correct prompt template (`USER: xxx\nASSISTANT:`) and add the token `<image>` to the location where you want to query images: ### Using `pipeline`: Below we used [`"bczhou/tiny-llava-v1-hf"`](https://huggingface.co/bczhou/tiny-llava-v1-hf) checkpoint. ```python from transformers import pipeline from PIL import Image import requests model_id …064e744 -
Upload processor
Verified signature33fb826 -
Upload LlavaForConditionalGeneration
Verified signature48c6894 -
initial commit
Verified signature98d4825