File size: 5,266 Bytes
2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 56d302d 2eb3eb4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | # Parametric Floorplan Generator for Indian Residential Construction
A fine-tuned LLM that generates 2D construction floor plans from parametric input matching a `ProjectCreate` schema — including plot dimensions, setbacks, road side, number of bedrooms/toilets, optional rooms (pooja, study, balcony, parking, basement, stilt), and Vastu preferences.
## What It Does
Given parameters like:
```
Plot: 15m x 12m rectangular
Setbacks: front=1.5m, rear=1.0m, left=1.0m, right=1.0m
Road side: North
Bedrooms: 3, Toilets: 3
Parking required, Pooja room, Balcony
2 floors (G+1)
City: Delhi
```
The model outputs a complete JSON floorplan with:
- **Plot boundary** polygon (supports rectangular, L-shaped, trapezoid)
- **Buildable boundary** (plot minus setbacks)
- **Rooms** as polygons with dimensions, area, and center position
- **Doors** (main entrance + internal doors between adjacent rooms)
- **Windows** on external walls
- **Area summaries** by floor (GF, FF, SF, stilt, basement)
## Model
| Component | Value |
|-----------|-------|
| Base Model | `Qwen/Qwen2.5-1.5B-Instruct` |
| Fine-tuning | LoRA (r=16, alpha=32, dropout=0.05) |
| Target Modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Epochs | 5 |
| Batch Size | 4 (accumulation=4) |
| Learning Rate | 1e-4 |
| Max Sequence Length | 4096 |
| Precision | bf16 |
## Dataset
The dataset is **synthetically generated** to match your `ProjectCreate` schema.
### Input Schema (ProjectCreate)
```json
{
"name": "MyHouse",
"plot_length": 15.0,
"plot_width": 12.0,
"setback_front": 1.5,
"setback_rear": 1.0,
"setback_left": 1.0,
"setback_right": 1.0,
"road_side": "N",
"north_direction": "N",
"num_bedrooms": 3,
"toilets": 3,
"parking": true,
"city": "Delhi",
"vastu_enabled": false,
"road_width_m": 9.0,
"has_pooja": true,
"has_study": false,
"has_balcony": true,
"plot_shape": "rectangular",
"num_floors": 2,
"has_stilt": false,
"has_basement": false,
"municipality": "MCD",
"custom_room_config": null
}
```
### Output Schema
```json
{
"project_name": "MyHouse",
"plot": {
"shape": "rectangular",
"outer_boundary": [[0,0],[15,0],[15,12],[0,12]],
"setbacks": {"front":1.5,"rear":1.0,"left":1.0,"right":1.0},
"buildable_boundary": [[1.5,1.5],[13.5,1.5],[13.5,11],[1.5,11]],
"road_side": "N",
"north_direction": "N",
"plot_length": 15.0,
"plot_width": 12.0
},
"rooms": [
{
"id": "living_1",
"type": "living",
"name": "Living Room",
"floor": "gf",
"polygon": [[1.5,1.5],[8.5,1.5],[8.5,5.5],[1.5,5.5]],
"area_sqm": 24.0,
"dimensions": {"width":7.0,"depth":4.0},
"position": {"x":5.0,"y":3.5}
},
...
],
"doors": [
{"id":"door_main","type":"main_entrance","width":0.9,"from":"outside","to":"living_1","position":[7.5,11.0],"orientation":"horizontal"},
...
],
"windows": [
{"id":"win_living_1","room":"living_1","width":1.2,"height":1.5,"position":[8.5,3.5],"orientation":"vertical"},
...
],
"dimensions": {
"total_built_up_area_sqm": 145.2,
"total_carpet_area_sqm": 128.0,
"ground_floor_area_sqm": 128.0,
"first_floor_area_sqm": 0.0,
"second_floor_area_sqm": 0.0,
"stilt_area_sqm": 0.0,
"basement_area_sqm": 0.0
},
"meta": {
"num_floors": 2,
"has_stilt": false,
"has_basement": false,
"vastu_enabled": false,
"city": "Delhi",
"municipality": "MCD"
}
}
```
## Repository Structure
| File | Purpose |
|------|---------|
| `train.py` | Fine-tuning script using TRL SFTTrainer + LoRA |
| `generate.py` | Inference script — pass parametric input, get JSON floorplan |
| `generate_synthetic_dataset.py` | Generates the training dataset from the ProjectCreate schema |
| `README.md` | This file |
## Quick Start
### 1. Generate Dataset
```bash
pip install datasets
python generate_synthetic_dataset.py
```
This creates `floorplan_synthetic_dataset/` with 5,000 train, 500 val, 500 test examples.
### 2. Train
```bash
pip install transformers trl torch datasets peft accelerate trackio
export HF_TRAINER_HUB_MODEL_ID="Karthik8nitt/parametric-floorplan-generator"
python train.py
```
Requires ~16GB VRAM (T4, RTX 3090, A10G). Runtime: 2-4 hours.
### 3. Generate Floorplan
```bash
python generate.py \
--plot_length 15 --plot_width 12 \
--setback_front 1.5 --setback_rear 1.0 \
--setback_left 1.0 --setback_right 1.0 \
--road_side N --num_bedrooms 3 --toilets 3 \
--parking --has_pooja --has_balcony \
--num_floors 2 --city Delhi
```
## Advanced: Custom Rooms
Use `custom_room_config` to add non-standard rooms:
```json
[
{"type": "gym", "name": "Home Gym", "min_area_sqm": 15, "floor_preference": "ff", "mandatory": true},
{"type": "home_theater", "name": "Theater", "min_area_sqm": 20, "floor_preference": "basement", "mandatory": true}
]
```
## Supported Plot Shapes
- `rectangular`
- `l_shaped` (with `cutout_corner`, `cutout_width`, `cutout_height`)
- `trapezoid` (with `plot_front_width`, `plot_rear_width`, `plot_side_offset`)
## References
- DStruct2Design paper: [arXiv:2407.15723](https://arxiv.org/abs/2407.15723)
- Base model: [Qwen/Qwen2.5-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct)
|