import torchfrom PIL import Imagefrom transformers import AutoProcessor, Qwen2_5_VLForConditionalGeneration model_id = "MubitLabs/Mubit-Qwen2.5-VL-7B-DocGuard"processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=False)model = Qwen2_5_VLForConditionalGeneration.from_pretrained( model_id, dtype=torch.bfloat16, device_map="auto", trust_remote_code=False) image = Image.open("receipt.png").convert("RGB")prompt = ( "Inspect this business receipt or invoice image carefully. " "Return ONLY valid JSON matching exactly: " '{"status": "extracted" or "abstain", "vendor": string or null, ' '"total": string or null, "date": string or null}. ' "If ANY target field (vendor, total, or date) is redacted, blacked out, or cropped out, " 'you MUST set that field to null and set "status": "abstain". Never fabricate missing values.') messages = [{"role": "user", "content": [{"type": "image"}, {"type": "text", "text": prompt}]}]text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)inputs = processor(text=[text], images=[image], return_tensors="pt").to(model.device) with torch.no_grad(): out = model.generate(**inputs, max_new_tokens=160, do_sample=False)print(processor.batch_decode(out[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)[0])