Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,8 +27,7 @@ pipeline.scheduler = UniPCMultistepScheduler.from_config(pipeline.scheduler.conf
|
|
| 27 |
|
| 28 |
pipeline = pipeline.to(device)
|
| 29 |
torch.cuda.empty_cache()
|
| 30 |
-
|
| 31 |
-
generator = torch.Generator(device=device).manual_seed(seed)
|
| 32 |
|
| 33 |
|
| 34 |
|
|
@@ -95,23 +94,31 @@ def floorplan_generation(outline, num_of_rooms):
|
|
| 95 |
validation_prompt = "floor plan, " + num_of_rooms + " rooms"
|
| 96 |
validation_image = n_outline
|
| 97 |
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
|
| 110 |
gradio_interface = gradio.Interface(
|
| 111 |
fn=floorplan_generation,
|
| 112 |
inputs=[gradio.Image(label="Floor Plan Outline, Entrance"),
|
| 113 |
gradio.Textbox(type="text", label="number of rooms", placeholder="number of rooms")],
|
| 114 |
-
outputs=gradio.Image(label="Generated Floor Plan"),
|
| 115 |
title="floorplan generation")
|
| 116 |
|
| 117 |
|
|
|
|
| 27 |
|
| 28 |
pipeline = pipeline.to(device)
|
| 29 |
torch.cuda.empty_cache()
|
| 30 |
+
|
|
|
|
| 31 |
|
| 32 |
|
| 33 |
|
|
|
|
| 94 |
validation_prompt = "floor plan, " + num_of_rooms + " rooms"
|
| 95 |
validation_image = n_outline
|
| 96 |
|
| 97 |
+
image_lst = []
|
| 98 |
+
for i in range(2):
|
| 99 |
+
seed = randrange(500)
|
| 100 |
+
generator = torch.Generator(device=device).manual_seed(seed)
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
image = pipeline(validation_prompt,
|
| 104 |
+
validation_image,
|
| 105 |
+
num_inference_steps=20,
|
| 106 |
+
generator=generator).images[0]
|
| 107 |
+
|
| 108 |
+
image = np.array(image)
|
| 109 |
+
mask = np.array(n_outline)
|
| 110 |
+
mask = cv2.cvtColor(mask, cv2.COLOR_RGB2BGR)
|
| 111 |
+
image = clean_img(image, mask)
|
| 112 |
+
image_lst.append(image)
|
| 113 |
+
|
| 114 |
+
return image_lst[0], image_lst[1]
|
| 115 |
|
| 116 |
|
| 117 |
gradio_interface = gradio.Interface(
|
| 118 |
fn=floorplan_generation,
|
| 119 |
inputs=[gradio.Image(label="Floor Plan Outline, Entrance"),
|
| 120 |
gradio.Textbox(type="text", label="number of rooms", placeholder="number of rooms")],
|
| 121 |
+
outputs=[gradio.Image(label="Generated Floor Plan 1"), gradio.Image(label="Generated Floor Plan 2")],
|
| 122 |
title="floorplan generation")
|
| 123 |
|
| 124 |
|