Image-Text-to-Text
Transformers
Safetensors
English
multimodal
spatial
sptial understanding
self-supervised learning
conversational
Instructions to use internlm/Spatial-SSRL-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use internlm/Spatial-SSRL-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="internlm/Spatial-SSRL-3B") 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("internlm/Spatial-SSRL-3B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use internlm/Spatial-SSRL-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "internlm/Spatial-SSRL-3B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "internlm/Spatial-SSRL-3B", "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/internlm/Spatial-SSRL-3B
- SGLang
How to use internlm/Spatial-SSRL-3B 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 "internlm/Spatial-SSRL-3B" \ --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": "internlm/Spatial-SSRL-3B", "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 "internlm/Spatial-SSRL-3B" \ --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": "internlm/Spatial-SSRL-3B", "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 internlm/Spatial-SSRL-3B with Docker Model Runner:
docker model run hf.co/internlm/Spatial-SSRL-3B
Update README.md
Browse files
README.md
CHANGED
|
@@ -62,16 +62,15 @@ We train Qwen2.5-VL-3B and Qwen2.5-VL-7B with our Spatial-SSRL paradigm and the
|
|
| 62 |
</p>
|
| 63 |
|
| 64 |
## 🛠️ Usage
|
| 65 |
-
To directly experience <strong>Spatial-SSRL-7B</strong>, you can try it out on [🤗Spatial-SSRL Space](https://huggingface.co/spaces/yuhangzang/Spatial-SSRL)!
|
| 66 |
|
| 67 |
-
Here we provide a code snippet for you to start a simple trial of <strong>Spatial-SSRL-
|
| 68 |
</p>
|
| 69 |
|
| 70 |
```python
|
| 71 |
from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
|
| 72 |
from qwen_vl_utils import process_vision_info
|
| 73 |
|
| 74 |
-
model_path = "internlm/Spatial-SSRL-
|
| 75 |
img_path = "examples/eg1.jpg"
|
| 76 |
question = "Consider the real-world 3D locations of the objects. Which object has a higher location? A. yellow bear kite B. building"
|
| 77 |
#We recommend using the format prompt to make the inference consistent with training
|
|
|
|
| 62 |
</p>
|
| 63 |
|
| 64 |
## 🛠️ Usage
|
|
|
|
| 65 |
|
| 66 |
+
Here we provide a code snippet for you to start a simple trial of <strong>Spatial-SSRL-3B</strong> on your own device. You can download the model from 🤗<a href="https://huggingface.co/internlm/Spatial-SSRL-3B">Spatial-SSRL-3B Model</a > before your trial!
|
| 67 |
</p>
|
| 68 |
|
| 69 |
```python
|
| 70 |
from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
|
| 71 |
from qwen_vl_utils import process_vision_info
|
| 72 |
|
| 73 |
+
model_path = "internlm/Spatial-SSRL-3B" #You can change it to your own local path if deployed already
|
| 74 |
img_path = "examples/eg1.jpg"
|
| 75 |
question = "Consider the real-world 3D locations of the objects. Which object has a higher location? A. yellow bear kite B. building"
|
| 76 |
#We recommend using the format prompt to make the inference consistent with training
|