File size: 3,580 Bytes
d8997c5
 
f48e15f
 
 
 
 
d8997c5
 
 
1d64201
 
84736b7
1d64201
1666228
1d64201
84736b7
1d64201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bce365b
1d64201
 
 
bce365b
1d64201
 
 
 
 
84736b7
1d64201
84736b7
1d64201
84736b7
1d64201
1666228
 
1d64201
 
84736b7
1d64201
84736b7
 
1d64201
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84736b7
 
 
 
 
 
 
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
---
title: 2D Floorplan Vectorizer
emoji: πŸ–ŒοΈ
colorFrom: blue
colorTo: green
sdk: docker
app_file: Dockerfile
pinned: false
---

# 2D Floorplan Vectorizer

A Gradio web app that allows you to upload 2D floorplan images and automatically vectorize them into COCO-style annotations using a trained Mask R-CNN model. The app runs inside a Docker container and is deployed on HuggingFace Spaces for easy public access. It detects and annotates key elements like rooms, walls, doors, and windows.

---

## How to Run the App in Local

1. **Clone the repository:**

    ```bash
    git clone <this-repo-link>
    cd inovonics-ui-vectorizer
    ```

2. **Install the required Python packages:**

    ```bash
    pip install -r requirements.txt
    ```

3. **Download the pretrained model:**

    - Download `model_final.pth` from [Google Drive here](https://drive.google.com/file/d/1yr64AOgaYZPTcQzG6cxG6lWBENHR9qjW/view?usp=sharing).
    - Place it inside:

      ```plaintext
      floorplan-vectorizer/rcnn_model/output/model_final.pth
      ```

4. **Run the app:**

    ```bash
    python app.py
    ```
    - This is the instruction for running the model in local, this will open up the app in localhost.

5. Open your browser at [http://localhost:xxxx](http://localhost:xxxx) to start using the app!

---

## Project Structure

--- 
```plaintext
floorplan-vectorizer/
β”œβ”€β”€ app.py                     # Gradio frontend app
β”œβ”€β”€ public/
β”‚   └── logo.png                # App logo
β”œβ”€β”€ rcnn_model/
β”‚   β”œβ”€β”€ extraction/             # Extract information from uploaded png image
β”‚   β”‚   └── annotation_builder.py      
β”‚   β”‚   └── floorplan_sampler.py
β”‚   β”‚   └── from_labelme_runner.py
β”‚   β”‚   └── svg_to_json.py   
β”‚   β”œβ”€β”€ output/                 # Empty folder while cloning. Place the pth file here
β”‚   β”œβ”€β”€ preprocessing/          # Preprocess the image before sending to model
β”‚   β”‚   └── cleaning_images.py  
β”‚   β”‚   └── cleaning_single_image.py 
β”‚   β”‚   └── splitting_dataset.py
β”‚   β”‚   └── svg_to_yolo.py    
β”‚   β”œβ”€β”€ results/                # Empty folder while cloning. The resulting image and JSON will be stored here
β”‚   β”œβ”€β”€ sample/                 # Sample images for the model       
β”‚   β”œβ”€β”€ scripts/                # Model training, evaluation and inference. Streamlit runs the rcnn_run.py file from the frontend
β”‚   β”‚   └── rcnn_config.py    
β”‚   β”‚   └── rcnn_eval.py  
β”‚   β”‚   └── rcnn_full_tuner.py 
β”‚   β”‚   └── rcnn_run.py  
β”‚   β”‚   └── rcnn_train.py     
β”‚   β”œβ”€β”€ uploads/                # Temporary folder for streamlit to store the user uploaded image
β”‚   β”œβ”€β”€ utils/                  # Utility functions during model train and preprocessing
β”‚   β”‚   └── coco_to_inovonics_json.py
β”‚   β”‚   └── floorplan_vectorizer_utils.py
β”‚   β”‚   └── inovonics_ann_builder.py
β”œβ”€β”€ README.md                   # (this file)
β”œβ”€β”€ requirements.txt            # Python dependencies
└── .gitignore                  # Files to ignore during Git commits
```
---

## Huggingface Model

The model is currently running in this [HuggingFace Space](https://huggingface.co/spaces/Dharini27/floorplan-vectorizer) 
Upload the floorplan image and click on "Run Vectorizer" button, once the model prediction is completed, the floorplan image with detected rooms and the corresponding json will be displayed and ready for download too.