Image-Text-to-Text
Transformers
Safetensors
English
qwen2_5_vl
text-generation-inference
trl
spatial-reasoning
vision-understanding
conversational
Instructions to use prithivMLmods/Spatial-VU with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use prithivMLmods/Spatial-VU with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="prithivMLmods/Spatial-VU") 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("prithivMLmods/Spatial-VU") model = AutoModelForMultimodalLM.from_pretrained("prithivMLmods/Spatial-VU", 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 prithivMLmods/Spatial-VU with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "prithivMLmods/Spatial-VU" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "prithivMLmods/Spatial-VU", "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/prithivMLmods/Spatial-VU
- SGLang
How to use prithivMLmods/Spatial-VU 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 "prithivMLmods/Spatial-VU" \ --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": "prithivMLmods/Spatial-VU", "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 "prithivMLmods/Spatial-VU" \ --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": "prithivMLmods/Spatial-VU", "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 prithivMLmods/Spatial-VU with Docker Model Runner:
docker model run hf.co/prithivMLmods/Spatial-VU
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,79 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
|
| 5 |
+
# **Spatial-VU**
|
| 6 |
+
|
| 7 |
+
> The **Spatial-VU** model is a fine-tuned variant of **Qwen2.5-VL-7B-Instruct**, developed for **Spatial Reasoning** and **Vision Understanding**. It is designed to deliver detailed, context-aware visual descriptions and reasoning outputs across a wide range of image types, resolutions, and aspect ratios.
|
| 8 |
+
|
| 9 |
+
## Key Highlights
|
| 10 |
+
|
| 11 |
+
* **Spatial Reasoning and Visual Comprehension**: Optimized for interpreting spatial layouts, object relationships, and scene understanding within images.
|
| 12 |
+
* **High-Precision Descriptions**: Generates detailed, context-rich captions for general, technical, and abstract imagery.
|
| 13 |
+
* **Adaptive Across Aspect Ratios**: Performs effectively with images of varying formats—wide, tall, square, and irregular.
|
| 14 |
+
* **Multi-Level Detail Control**: Supports both concise summaries and fine-grained analytical outputs, depending on the prompt.
|
| 15 |
+
* **Built on Qwen2.5-VL Architecture**: Utilizes the visual-linguistic reasoning power of Qwen2.5-VL-7B for structured and accurate comprehension tasks.
|
| 16 |
+
* **Multilingual Support**: Outputs in English by default, with the ability to generate multilingual responses through prompt conditioning.
|
| 17 |
+
|
| 18 |
+
## Quick Start with Transformers
|
| 19 |
+
|
| 20 |
+
```python
|
| 21 |
+
from transformers import Qwen2_5_VLForConditionalGeneration, AutoTokenizer, AutoProcessor
|
| 22 |
+
from qwen_vl_utils import process_vision_info
|
| 23 |
+
|
| 24 |
+
model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
| 25 |
+
"prithivMLmods/Spatial-VU", torch_dtype="auto", device_map="auto"
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
processor = AutoProcessor.from_pretrained("prithivMLmods/Spatial-VU")
|
| 29 |
+
|
| 30 |
+
messages = [
|
| 31 |
+
{
|
| 32 |
+
"role": "user",
|
| 33 |
+
"content": [
|
| 34 |
+
{
|
| 35 |
+
"type": "image",
|
| 36 |
+
"image": "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg",
|
| 37 |
+
},
|
| 38 |
+
{"type": "text", "text": "Analyze the spatial layout and describe the scene."},
|
| 39 |
+
],
|
| 40 |
+
}
|
| 41 |
+
]
|
| 42 |
+
|
| 43 |
+
text = processor.apply_chat_template(
|
| 44 |
+
messages, tokenize=False, add_generation_prompt=True
|
| 45 |
+
)
|
| 46 |
+
image_inputs, video_inputs = process_vision_info(messages)
|
| 47 |
+
inputs = processor(
|
| 48 |
+
text=[text],
|
| 49 |
+
images=image_inputs,
|
| 50 |
+
videos=video_inputs,
|
| 51 |
+
padding=True,
|
| 52 |
+
return_tensors="pt",
|
| 53 |
+
)
|
| 54 |
+
inputs = inputs.to("cuda")
|
| 55 |
+
|
| 56 |
+
generated_ids = model.generate(**inputs, max_new_tokens=128)
|
| 57 |
+
generated_ids_trimmed = [
|
| 58 |
+
out_ids[len(in_ids):] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
|
| 59 |
+
]
|
| 60 |
+
output_text = processor.batch_decode(
|
| 61 |
+
generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
|
| 62 |
+
)
|
| 63 |
+
print(output_text)
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
## Intended Use
|
| 67 |
+
|
| 68 |
+
* Spatial reasoning, visual understanding, and scene analysis tasks.
|
| 69 |
+
* Descriptive and interpretive caption generation for research or vision-language evaluation.
|
| 70 |
+
* Structured visual comprehension in creative and analytical applications.
|
| 71 |
+
* Data annotation and reasoning augmentation in multimodal AI pipelines.
|
| 72 |
+
* Spatial layout and context interpretation across diverse visual domains.
|
| 73 |
+
|
| 74 |
+
## Limitations
|
| 75 |
+
|
| 76 |
+
* May generate variable outputs depending on the phrasing of prompts.
|
| 77 |
+
* Not recommended for production use cases requiring strong moderation or controlled tone.
|
| 78 |
+
* Performance may vary on abstract, heavily stylized, or low-context visual inputs.
|
| 79 |
+
* Lacks fine-tuned control over subjective or ambiguous visual content interpretations.
|