Views
No views yet
You FIRST observe the image in <observe> </observe> tags, then visualise the relevant scene graph in <scene> </scene> tags, followed by thinking about the reasoning process as an internal monologue within <think> </think> tags and then provide the final answer. The final answer MUST BE put within <answer> </answer> tags, and only return the final choice including the correct option and answer within the answer tags, e.g., <answer> (A) cat </answer>.
Image size: {Width} x {Height}1from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
2from PIL import Image
3
4model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
5 "OX-PIXL/SpatialThinker-7B",
6 torch_dtype="auto",
7 device_map="auto"
8)
9processor = AutoProcessor.from_pretrained("OX-PIXL/SpatialThinker-7B")
10
11# Load image
12image = Image.open("your_image.jpg")
13width, height = image.size
14
15# Prepare prompt with template
16template = f"""You FIRST observe the image in <observe> </observe> tags, then visualise the relevant scene graph in <scene> </scene> tags, followed by thinking about the reasoning process as an internal monologue within <think> </think> tags and then provide the final answer. The final answer MUST BE put within <answer> </answer> tags, and only return the final choice including the correct option and answer within the answer tags, e.g., <answer> (A) cat </answer>.
17
18Image size: {width} x {height}"""
19
20question = "Where is the cat relative to the couch? (A) on top of (B) in front of (C) behind (D) beside"
21
22messages = [
23 {
24 "role": "user",
25 "content": [
26 {"type": "image", "image": image},
27 {"type": "text", "text": template + "\n\n" + question},
28 ],
29 }
30]
31
32text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
33inputs = processor(text=[text], images=[image], return_tensors="pt").to(model.device)
34
35generated_ids = model.generate(**inputs, max_new_tokens=1024)
36output = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
37print(output)1@misc{batra2025spatialthinkerreinforcing3dreasoning,
2 title={SpatialThinker: Reinforcing 3D Reasoning in Multimodal LLMs via Spatial Rewards},
3 author={Hunar Batra and Haoqin Tu and Hardy Chen and Yuanze Lin and Cihang Xie and Ronald Clark},
4 year={2025},
5 eprint={2511.07403},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://arxiv.org/abs/2511.07403},
9}