import importlib.utilimport torchfrom huggingface_hub import hf_hub_downloadfrom PIL import Imagefrom peft import PeftModelfrom transformers import AutoProcessor, Qwen3VLForConditionalGeneration base = "Qwen/Qwen3-VL-8B-Instruct"processor = AutoProcessor.from_pretrained(base)model = Qwen3VLForConditionalGeneration.from_pretrained(base, torch_dtype=torch.bfloat16, device_map="cuda")model = PeftModel.from_pretrained(model, "ahd03/masar").eval() # NaviTrace's prompts, the same ones used in trainingspec = importlib.util.spec_from_file_location("prompts", hf_hub_download("ahd03/masar", "prompts.py"))prompts = importlib.util.module_from_spec(spec)spec.loader.exec_module(prompts) image = Image.open("photo.jpg").convert("RGB")image.thumbnail((896, 896))messages = prompts.messages(image, "Go to the bench on the left") text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)inputs = processor(text=[text], images=[image], return_tensors="pt").to("cuda")out = model.generate(**inputs, max_new_tokens=256, do_sample=False)print(processor.batch_decode(out[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)[0])# [[0.500, 0.950], [0.470, 0.880], ..., [0.310, 0.560]] x, y from 0 to 1, origin top-left