Image-Text-to-Text
Transformers
Safetensors
English
spatialvla
feature-extraction
VLA
Foundation Vision-language-action Model
Generalist Robot Policy
robotics
custom_code
Instructions to use IPEC-COMMUNITY/spatialvla-4b-224-pt with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use IPEC-COMMUNITY/spatialvla-4b-224-pt with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="IPEC-COMMUNITY/spatialvla-4b-224-pt", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("IPEC-COMMUNITY/spatialvla-4b-224-pt", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use IPEC-COMMUNITY/spatialvla-4b-224-pt with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "IPEC-COMMUNITY/spatialvla-4b-224-pt" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "IPEC-COMMUNITY/spatialvla-4b-224-pt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/IPEC-COMMUNITY/spatialvla-4b-224-pt
- SGLang
How to use IPEC-COMMUNITY/spatialvla-4b-224-pt 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 "IPEC-COMMUNITY/spatialvla-4b-224-pt" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "IPEC-COMMUNITY/spatialvla-4b-224-pt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "IPEC-COMMUNITY/spatialvla-4b-224-pt" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "IPEC-COMMUNITY/spatialvla-4b-224-pt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use IPEC-COMMUNITY/spatialvla-4b-224-pt with Docker Model Runner:
docker model run hf.co/IPEC-COMMUNITY/spatialvla-4b-224-pt
| import os | |
| import argparse | |
| from pathlib import Path | |
| import torch | |
| from PIL import Image | |
| from transformers import AutoModel, AutoProcessor | |
| parser = argparse.ArgumentParser("Huggingface AutoModel Tesing") | |
| parser.add_argument("--model_name_or_path", default=".", help="pretrained model name or path.") | |
| parser.add_argument("--num_images", type=int, default=1, help="num_images for testing.") | |
| args = parser.parse_args() | |
| if __name__ == "__main__": | |
| model_name_or_path = Path(args.model_name_or_path) | |
| processor = AutoProcessor.from_pretrained(args.model_name_or_path, trust_remote_code=True) | |
| print(processor.statistics) | |
| model = AutoModel.from_pretrained(args.model_name_or_path, trust_remote_code=True, torch_dtype=torch.bfloat16).eval().cuda() | |
| image = Image.open("example.png").convert("RGB") | |
| images = [image] * args.num_images | |
| prompt = "What action should the robot take to pick the cup?" | |
| inputs = processor(images=images, text=prompt, unnorm_key="bridge_orig/1.0.0", return_tensors="pt") | |
| print(inputs) | |
| generation_outputs = model.predict_action(inputs) | |
| print(generation_outputs, processor.batch_decode(generation_outputs)) | |
| actions = processor.decode_actions(generation_outputs, unnorm_key="bridge_orig/1.0.0") | |
| print(actions) | |