Views
No views yet
1import torch
2from utils.utils import *
3from transformers import AutoProcessor
4from models.qwen3vl_geo import Qwen3VLForConditionalGeneration
5
6device = 'cuda:0'
7model_id = "WHB139426/GeoVR-VGGT-Qwen3-VL-2B"
8
9model = Qwen3VLForConditionalGeneration.from_pretrained(
10 model_id,
11 geometry_encoder_path=None,
12 metric_model_path=None,
13 dtype=torch.bfloat16,
14 attn_implementation="flash_attention_2",
15 add_camera=False,
16 add_scale=False,
17 add_depth=False,
18 distill_geometry_feature=False,
19)
20model.load_geometric_weights(model_id)
21model.to(device)
22
23num_frames = 32
24processor = AutoProcessor.from_pretrained(model_id)
25processor.video_processor.size = {"longest_edge": 384*num_frames*32*32, "shortest_edge": 4*num_frames*32*32}
26
27messages = [
28 {
29 "role": "user",
30 "content": [
31 {"type": "video", "video": './assets/scene0111_02.mp4',},
32 {"type": "text", "text": "Measuring distance from the nearest points, select the closest object (trash bin, door, table, refrigerator) to the tv. If multiple exist, use the nearest instance.
33Options:
34A. trash bin
35B. door
36C. table
37D. refrigerator
38Answer with the option's letter from the given choices directly."},
39 ],
40 }
41]
42
43generation_kwargs = {
44 'do_sample': True,
45 'top_p': 0.8,
46 'top_k': 20,
47 'temperature': 0.7,
48 'repetition_penalty': 1.0,
49 'max_new_tokens': 32*1024,
50}
51
52inputs = processor.apply_chat_template(
53 messages,
54 tokenize=True,
55 add_generation_prompt=True,
56 return_dict=True,
57 return_tensors="pt",
58 num_frames=num_frames,
59 fps=None,
60 enable_thinking=False,
61).to(model.device)
62
63with torch.cuda.amp.autocast(enabled=True, dtype=torch.bfloat16):
64 with torch.inference_mode():
65 generated_ids = model.generate(**inputs, **generation_kwargs)
66 output_text = processor.batch_decode(generated_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0].strip()
67print(output_text)1@article{wang2026learning,
2 title={Learning Geometric Representations from Videos for Spatial Intelligent Multimodal Large Language Models},
3 author={Wang, Haibo and Huang, Lifu},
4 journal={arXiv preprint arXiv:2606.05833},
5 year={2026}
6}