Views
No views yet
mudasir13cs/qwen25-vl-3b-floorplan-grpo. In a local training checkout, see floorplan-vlm-grpo/README.md for the same style of usage doc.train_floorplan_vlm.py — MODEL_ID, HUB_MODEL_ID, OUTPUT_DIR, DATA_DIR, epochs, LR, LoRA layout, SYSTEM_PROMPT / USER_PROMPT (use these strings at inference).train_floorplan_vlm.py.pip install torch torchvision transformers peft accelerate pillow1pip install torch torchvision transformers trl peft datasets accelerate shapely Pillow lxml numpy tqdm huggingface_hub
2# optional GPU attention: pip install flash-attn1from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
2from peft import PeftModel
3
4BASE = "Qwen/Qwen2.5-VL-3B-Instruct"
5ADAPTER = "mudasir13cs/qwen25-vl-3b-floorplan-sft"
6
7processor = AutoProcessor.from_pretrained(BASE)
8model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
9 BASE, torch_dtype="auto", device_map="auto"
10)
11model = PeftModel.from_pretrained(model, ADAPTER)
12model.eval()ADAPTER = "./floorplan-vlm-sft" (or an absolute path) instead of the Hub repo id.SYSTEM_PROMPT and USER_PROMPT aligned with train_floorplan_vlm.py constants.train_floorplan_vlm.py):1import json, re, torch
2from PIL import Image
3
4SYSTEM_PROMPT = (
5 "You are a floor plan vectorization expert. Extract wall, door, window geometry "
6 "from floor plan images into structured JSON.\n\n"
7 "Output ONLY valid JSON with this schema:\n"
8 '{"walls":[{"id":"wall_N","start":[x,y],"end":[x,y],"thickness":T,"curvature":0,'
9 '"openings":[{"type":"door"|"window","center":D,"width":W}]}],'
10 '"rooms":[{"label":"room_type","walls":["wall_N",...]}]}\n\n'
11 "Coordinates normalized so longer image edge = 1024."
12)
13USER_PROMPT = "Vectorize this floor plan into structured JSON with all walls, doors, windows, and rooms."
14
15image = Image.open("plan.png").convert("RGB")
16
17messages = [
18 {"role": "system", "content": [{"type": "text", "text": SYSTEM_PROMPT}]},
19 {"role": "user", "content": [{"type": "image"}, {"type": "text", "text": USER_PROMPT}]},
20]
21text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
22inputs = processor(text=[text], images=[image], return_tensors="pt", padding=True)
23inputs = {k: v.to(model.device) if hasattr(v, "to") else v for k, v in inputs.items()}
24
25with torch.no_grad():
26 out = model.generate(**inputs, max_new_tokens=4096, do_sample=False)
27
28raw = processor.batch_decode(out[:, inputs.input_ids.shape[1] :], skip_special_tokens=True)[0]
29m = re.search(r"\{[\s\S]*\}", raw)
30plan = json.loads(m.group()) if m else Nonewalls (with optional openings) and rooms. Example JSON is documented under Output JSON Schema in the Manitocross training README.huggingface-cli login if you push to Hub (PUSH_TO_HUB in script).train_floorplan_vlm.py: first run downloads CubiCasa5K from Zenodo into ./cubicasa_data (~5GB). Tune NUM_EPOCHS, MAX_SAMPLES, LEARNING_RATE, HUB_MODEL_ID, etc. in the configuration block at the top of that file.Qwen/Qwen2.5-VL-3B-InstructSFTTrainer / TRL; see script)walls, rooms, openings)MAX_SAMPLES if applicable.1@article{floorplanvlm2026,
2 title={FloorplanVLM: A Vision-Language Model for Floorplan Vectorization},
3 journal={arXiv preprint arXiv:2602.06507},
4 year={2026}
5}mudasir13cs/qwen25-vl-3b-floorplan-grpo