Karthik8nitt commited on
Commit
2eb3eb4
·
verified ·
1 Parent(s): fb95e51

Update README with full schema documentation

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