A deep learning-based system to parse architectural floorplans, extract structural layouts, and prepare them for simulation and analysis.
- UNet-based floorplan segmentation
- Patch-based inference for large images
- Overlapping tile stitching (edge-aware)
- Accurate wall extraction from floorplans
- Handles large-scale layouts efficiently
-
Adaptive stride tuning
- Found optimal stride (~100) instead of fixed 128
- Improves sampling diversity and reduces stitching artifacts
-
Edge-aware padding (NEW)
- Added ~5% reflective padding before inference
- Eliminates boundary artifacts and improves corner predictions
-
Improved stitching stability
- Better overlap distribution across patches
- Reduces repetition and seam artifacts
-
Debug visualization
- Raw probability maps (
debug_raw_mask.png) added - Helps analyze model confidence before thresholding
- Raw probability maps (
When running segmentation on large floorplans:
- Model performed poorly on full-size images
- Edges were broken or missing
- Large layouts were not parsed correctly
- Context loss at boundaries
To fix this, we implemented a sliding window inference system with overlap and blending.
- Split large image into smaller patches (e.g., 256×256)
- Allows model to focus on local features
-
Use stride < patch size
-
Example: Patch Size = 256
Stride = 128 -
Each region is predicted multiple times
- Center of patch = high confidence
- Edges = low confidence
Weight map concept:
Center → Strong
Edges → Weak
This removes:
- seams
- edge artifacts
- broken walls
We combine all patch predictions using:
- weighted accumulation
- normalization
Final formula:
final_mask = sum(predictions * weights) / sum(weights)
Input Image
V
Add reflective padding (~5%)
V
Split into overlapping patches
V
UNet Prediction
V
Weighted blending
V
Remove padding
V
Final stitched mask
parser-model/
├── model.py
├── train.py
├── predict.py
├── predict_tiled.py
├── diagram_stitch.py
├── assets/
│ ├── original.png
│ ├── prediction.png
│ ├── stitched.png
│ ├── stitching_diagram.png
│ └── stitching.gif
├── README.md
├── LICENSE
└── .gitignore
python version used: 3.10.x
This project was trained using the CubiCasa5K dataset.
CubiCasa5K is a large-scale annotated floorplan dataset containing detailed architectural layouts with semantic labels.
Due to size and licensing constraints, the dataset is not included in this repository.
You can access the dataset here:
https://github.com/CubiCasa/CubiCasa5k
If you use this dataset in your work, please consider citing the original authors.
pip install torch torchvision opencv-python numpy imageio
pip install -r requirements.txt
python predict_tiled.py
- Architecture: UNet
- Training data: ~1000 floorplan images
- Training epochs: 15
- Input resolution: 256 × 256
- Model is trained on limited data and may not generalize to all architectural styles
- Fine details such as doors and furniture are not explicitly modeled
- Performance depends on preprocessing consistency
Large floorplans are processed using a sliding window approach with overlap.
- The image is split into overlapping patches
- Each patch is passed through the model
- Predictions are combined using a weighted map
- Overlapping regions are averaged to remove seams

Overlapping patch concept for stitching

Sliding window stitching in action
The diagram explains how overlapping patches work, while the GIF shows the sliding window processing across the image in real time.
Without overlap:
- Broken edges
- Missing walls
With overlap:
- Smooth transitions
- Accurate structure
- Full-image inference is unreliable for large layouts
- Always use tiled inference for best results
- Preprocessing must match training pipeline
- Normalization is critical for correct predictions
- Significantly improved large-scale floorplan segmentation
- Reduced edge artifacts using overlap + padding + blending
- Stabilized patch-based inference across different stride settings
- Achieved more consistent wall reconstruction on large layouts
- Multi-scale inference
- Test-time augmentation
- Vectorization of wall structures
- Integration with evacuation simulation systems
- Detection of semantic elements (doors, exits)
This project is licensed under the MIT License.
Sankhyapriyo Dey



