Spaces:
Runtime error
Runtime error
Commit
·
5655f12
1
Parent(s):
726ebdf
add additional info
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import os
|
|
4 |
from model import VirtualStagingToolV2
|
5 |
|
6 |
|
7 |
-
def predict(image, style, backyard_style, color_preference):
|
8 |
init_image = image.convert("RGB").resize((512, 512))
|
9 |
|
10 |
vs_tool = VirtualStagingToolV2(diffusion_version="stabilityai/stable-diffusion-2-inpainting")
|
@@ -12,7 +12,8 @@ def predict(image, style, backyard_style, color_preference):
|
|
12 |
style = backyard_style
|
13 |
|
14 |
output_images, transparent_mask_image = vs_tool.virtual_stage(
|
15 |
-
image=init_image, style=style, color_preference=color_preference,
|
|
|
16 |
|
17 |
return output_images[0], transparent_mask_image
|
18 |
|
@@ -53,16 +54,20 @@ with image_blocks as demo:
|
|
53 |
|
54 |
color_preference = gr.Textbox(placeholder='Enter color preference',
|
55 |
label="Color preference", elem_id="input-color")
|
|
|
|
|
|
|
|
|
56 |
btn = gr.Button("Inpaint!").style(
|
57 |
margin=False,
|
58 |
rounded=(False, True, True, False),
|
59 |
full_width=False,
|
60 |
)
|
61 |
with gr.Column():
|
62 |
-
mask_image = gr.Image(label="Mask image", elem_id="mask-img", type="pil").style(height=
|
63 |
-
image_out = gr.Image(label="Output", elem_id="output-img", type="pil").style(height=
|
64 |
|
65 |
-
btn.click(fn=predict, inputs=[image, style, backyard_style, color_preference], outputs=[image_out, mask_image])
|
66 |
|
67 |
gr.Markdown("## Image Examples")
|
68 |
gr.Examples(
|
|
|
4 |
from model import VirtualStagingToolV2
|
5 |
|
6 |
|
7 |
+
def predict(image, style, backyard_style, color_preference, additional_info):
|
8 |
init_image = image.convert("RGB").resize((512, 512))
|
9 |
|
10 |
vs_tool = VirtualStagingToolV2(diffusion_version="stabilityai/stable-diffusion-2-inpainting")
|
|
|
12 |
style = backyard_style
|
13 |
|
14 |
output_images, transparent_mask_image = vs_tool.virtual_stage(
|
15 |
+
image=init_image, style=style, color_preference=color_preference,
|
16 |
+
additional_info=additional_info, number_images=1)
|
17 |
|
18 |
return output_images[0], transparent_mask_image
|
19 |
|
|
|
54 |
|
55 |
color_preference = gr.Textbox(placeholder='Enter color preference',
|
56 |
label="Color preference", elem_id="input-color")
|
57 |
+
|
58 |
+
additional_info = gr.Textbox(placeholder='Enter additional information',
|
59 |
+
label="Additional information", elem_id="input-add-info")
|
60 |
+
|
61 |
btn = gr.Button("Inpaint!").style(
|
62 |
margin=False,
|
63 |
rounded=(False, True, True, False),
|
64 |
full_width=False,
|
65 |
)
|
66 |
with gr.Column():
|
67 |
+
mask_image = gr.Image(label="Mask image", elem_id="mask-img", type="pil").style(height=500)
|
68 |
+
image_out = gr.Image(label="Output", elem_id="output-img", type="pil").style(height=500)
|
69 |
|
70 |
+
btn.click(fn=predict, inputs=[image, style, backyard_style, color_preference, additional_info], outputs=[image_out, mask_image])
|
71 |
|
72 |
gr.Markdown("## Image Examples")
|
73 |
gr.Examples(
|
model.py
CHANGED
@@ -96,7 +96,8 @@ class VirtualStagingToolV2():
|
|
96 |
room = 'living room'
|
97 |
elif 15 in label_ids and 19 in label_ids:
|
98 |
room = 'dining room'
|
99 |
-
|
|
|
100 |
label_ids_without_mask = [i for i in label_ids if i not in mask_items]
|
101 |
|
102 |
items = [self.segmentation_model.config.id2label[i] for i in label_ids_without_mask]
|
|
|
96 |
room = 'living room'
|
97 |
elif 15 in label_ids and 19 in label_ids:
|
98 |
room = 'dining room'
|
99 |
+
else:
|
100 |
+
room ='room'
|
101 |
label_ids_without_mask = [i for i in label_ids if i not in mask_items]
|
102 |
|
103 |
items = [self.segmentation_model.config.id2label[i] for i in label_ids_without_mask]
|