Image-Text-to-Text
Transformers
TensorBoard
Safetensors
llavaonevision1_5
text-generation
conversational
Instructions to use Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted") 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 AutoModelForSeq2SeqLM model = AutoModelForSeq2SeqLM.from_pretrained("Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted", "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/Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted
- SGLang
How to use Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted 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 "Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted" \ --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": "Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted", "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 "Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted" \ --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": "Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted", "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 Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted with Docker Model Runner:
docker model run hf.co/Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted
Download inference.py from Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted: direct link, hf CLI and curl.
- Browser
- Download file 1.47 kB
-
https://huggingface.co/Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted/resolve/main/inference.py
- Command line
-
hf download hf://Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted/inference.py
-
curl -L -o inference.py https://huggingface.co/Jinghao-Guo/LLaVA-OneVision-1.5-8B-Instruct-converted/resolve/main/inference.py
1.47 kB
| from transformers import AutoTokenizer, AutoProcessor, AutoModelForCausalLM | |
| from qwen_vl_utils import process_vision_info | |
| model_path = "lmms-lab/LLaVA-One-Vision-1.5-8B-Instruct" | |
| # default: Load the model on the available device(s) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| model_path, torch_dtype="auto", device_map="auto", trust_remote_code=True | |
| ) | |
| # default processer | |
| processor = AutoProcessor.from_pretrained(model_path, trust_remote_code=True) | |
| messages = [ | |
| { | |
| "role": "user", | |
| "content": [ | |
| { | |
| "type": "image", | |
| "image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg", | |
| }, | |
| {"type": "text", "text": "Describe this image."}, | |
| ], | |
| } | |
| ] | |
| # Preparation for inference | |
| text = processor.apply_chat_template( | |
| messages, tokenize=False, add_generation_prompt=True | |
| ) | |
| image_inputs, video_inputs = process_vision_info(messages) | |
| inputs = processor( | |
| text=[text], | |
| images=image_inputs, | |
| videos=video_inputs, | |
| padding=True, | |
| return_tensors="pt", | |
| ) | |
| inputs = inputs.to("cuda") | |
| # Inference: Generation of the output | |
| generated_ids = model.generate(**inputs, max_new_tokens=1024) | |
| generated_ids_trimmed = [ | |
| out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids) | |
| ] | |
| output_text = processor.batch_decode( | |
| generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False | |
| ) | |
| print(output_text) | |