Image-Text-to-Text
Transformers
Safetensors
sam2
sa2va_chat
feature-extraction
sa2va
referring-segmentation
referring-video-segmentation
llava
conversational
custom_code
Instructions to use ByteDance/Sa2VA-LLaVA-1.5-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ByteDance/Sa2VA-LLaVA-1.5-7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ByteDance/Sa2VA-LLaVA-1.5-7B", trust_remote_code=True) 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 AutoModel model = AutoModel.from_pretrained("ByteDance/Sa2VA-LLaVA-1.5-7B", trust_remote_code=True, device_map="auto") - sam2
How to use ByteDance/Sa2VA-LLaVA-1.5-7B with sam2:
# Use SAM2 with images import torch from sam2.sam2_image_predictor import SAM2ImagePredictor predictor = SAM2ImagePredictor.from_pretrained(ByteDance/Sa2VA-LLaVA-1.5-7B) with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): predictor.set_image(<your_image>) masks, _, _ = predictor.predict(<input_prompts>)# Use SAM2 with videos import torch from sam2.sam2_video_predictor import SAM2VideoPredictor predictor = SAM2VideoPredictor.from_pretrained(ByteDance/Sa2VA-LLaVA-1.5-7B) with torch.inference_mode(), torch.autocast("cuda", dtype=torch.bfloat16): state = predictor.init_state(<your_video>) # add new prompts and instantly get the output on the same frame frame_idx, object_ids, masks = predictor.add_new_points(state, <your_prompts>): # propagate the prompts to get masklets throughout the video for frame_idx, object_ids, masks in predictor.propagate_in_video(state): ... - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ByteDance/Sa2VA-LLaVA-1.5-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ByteDance/Sa2VA-LLaVA-1.5-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ByteDance/Sa2VA-LLaVA-1.5-7B", "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/ByteDance/Sa2VA-LLaVA-1.5-7B
- SGLang
How to use ByteDance/Sa2VA-LLaVA-1.5-7B 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 "ByteDance/Sa2VA-LLaVA-1.5-7B" \ --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": "ByteDance/Sa2VA-LLaVA-1.5-7B", "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 "ByteDance/Sa2VA-LLaVA-1.5-7B" \ --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": "ByteDance/Sa2VA-LLaVA-1.5-7B", "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 ByteDance/Sa2VA-LLaVA-1.5-7B with Docker Model Runner:
docker model run hf.co/ByteDance/Sa2VA-LLaVA-1.5-7B
| { | |
| "architectures": [ | |
| "Sa2VAChatModelLlava" | |
| ], | |
| "auto_map": { | |
| "AutoConfig": "configuration_sa2va_chat.Sa2VAChatConfigLlava", | |
| "AutoModel": "modeling_sa2va_llava.Sa2VAChatModelLlava", | |
| "AutoModelForCausalLM": "modeling_sa2va_llava.Sa2VAChatModelLlava" | |
| }, | |
| "dtype": "float32", | |
| "ignore_index": -100, | |
| "image_seq_length": 576, | |
| "image_token_index": 32000, | |
| "model_type": "sa2va_chat", | |
| "multimodal_projector_bias": true, | |
| "pad_token_id": 32001, | |
| "projector_hidden_act": "gelu", | |
| "template": "vicuna", | |
| "text_config": { | |
| "_name_or_path": "lmsys/vicuna-7b-v1.5", | |
| "architectures": [ | |
| "LlamaForCausalLM" | |
| ], | |
| "attention_bias": false, | |
| "attention_dropout": 0.0, | |
| "dtype": "float16", | |
| "head_dim": 128, | |
| "hidden_act": "silu", | |
| "hidden_size": 4096, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 11008, | |
| "max_position_embeddings": 4096, | |
| "mlp_bias": false, | |
| "model_type": "llama", | |
| "num_attention_heads": 32, | |
| "num_hidden_layers": 32, | |
| "num_key_value_heads": 32, | |
| "pretraining_tp": 1, | |
| "rms_norm_eps": 1e-05, | |
| "rope_scaling": null, | |
| "rope_theta": 10000.0, | |
| "use_cache": true, | |
| "vocab_size": 32007 | |
| }, | |
| "tie_word_embeddings": false, | |
| "transformers_version": "4.57.1", | |
| "vision_config": { | |
| "attention_dropout": 0.0, | |
| "hidden_act": "quick_gelu", | |
| "hidden_size": 1024, | |
| "image_size": 336, | |
| "initializer_factor": 1.0, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 4096, | |
| "layer_norm_eps": 1e-05, | |
| "model_type": "clip_vision_model", | |
| "num_attention_heads": 16, | |
| "num_channels": 3, | |
| "num_hidden_layers": 24, | |
| "patch_size": 14, | |
| "projection_dim": 768, | |
| "vocab_size": 32000 | |
| }, | |
| "vision_feature_layer": -2, | |
| "vision_feature_select_strategy": "default", | |
| "vocab_size": 32064 | |
| } | |