rawanessam commited on
Commit
bfed2f7
·
verified ·
1 Parent(s): 5fdff1b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -24
app.py CHANGED
@@ -1,25 +1,25 @@
1
- import gradio as gr
2
- import numpy as np
3
- from PIL import Image
4
- from deepfloorplan_inference import DeepFloorPlanModel
5
-
6
- # Load model once at startup
7
- model = DeepFloorPlanModel(model_dir='pretrained')
8
-
9
- def predict_floorplan(image):
10
- # image: PIL Image from Gradio
11
- result = model.predict(image)
12
- # Convert numpy array to PIL Image for Gradio output
13
- return Image.fromarray(result.astype(np.uint8))
14
-
15
- iface = gr.Interface(
16
- fn=predict_floorplan,
17
- inputs=gr.Image(type="pil", label="Upload Floorplan Image"),
18
- outputs=gr.Image(type="pil", label="Predicted Segmentation"),
19
- title="Deep Floor Plan Segmentation",
20
- description="Upload a floorplan image to get the predicted segmentation using the Deep Floor Plan model.",
21
- allow_flagging="never"
22
- )
23
-
24
- if __name__ == "__main__":
25
  iface.launch()
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from PIL import Image
4
+ from deepfloorplan_inference import DeepFloorPlanModel
5
+
6
+ # Load model once at startup
7
+ model = DeepFloorPlanModel(model_dir='pretrained')
8
+
9
+ def predict_floorplan(image):
10
+ # image: PIL Image from Gradio
11
+ result = model.predict(image)
12
+ # Convert numpy array to PIL Image for Gradio output
13
+ return Image.fromarray(result.astype(np.uint8))
14
+
15
+ iface = gr.Interface(
16
+ fn=predict_floorplan,
17
+ inputs=gr.Image(type="pil", label="Upload Floorplan Image"),
18
+ outputs=gr.Image(type="pil", label="Predicted Segmentation"),
19
+ title="Deep Floor Plan Segmentation",
20
+ description="Upload a floorplan image to get the predicted segmentation using the Deep Floor Plan model.",
21
+ allow_flagging="never"
22
+ )
23
+
24
+ if __name__ == "__main__":
25
  iface.launch()