import torchfrom transformers import AutoModel, AutoTokenizerfrom peft import PeftModel base = "openbmb/MiniCPM-V-4"tokenizer = AutoTokenizer.from_pretrained(base, trust_remote_code=True)model = AutoModel.from_pretrained(base, trust_remote_code=True, torch_dtype=torch.bfloat16, device_map="cuda")model = PeftModel.from_pretrained(model, "Barath/minicpmv4-floorplan-lora")model = model.merge_and_unload().eval() from PIL import Imageimg = Image.open("floorplan.png").convert("RGB")prompt = ('Detect the architectural elements in this floor plan (walls, doors, ' 'windows, stairs, fixtures, furniture). Return only JSON: ' '{"elements": [{"type": str, "bbox": [x1, y1, x2, y2]}]} with integer ' 'coordinates normalized to [0, 1000].')out = model.chat(msgs=[{"role": "user", "content": [img, prompt]}], tokenizer=tokenizer, sampling=False, max_new_tokens=1500, repetition_penalty=1.1)print(out)