Spaces:
Runtime error
Runtime error
add placeholders for gradio
Browse files- app.py +73 -4
- empty.png +0 -0
- legend.png +0 -0
- thumbnail_gradio.PNG +0 -0
app.py
CHANGED
@@ -86,7 +86,7 @@ def prompt_to_layout(user_prompt, fpath=None):
|
|
86 |
|
87 |
_, im = draw_polygons(geom, colors, fpath=fpath)
|
88 |
|
89 |
-
legend = Image.open(
|
90 |
|
91 |
im = np.array(im)
|
92 |
im[:40, :] = np.array(legend)
|
@@ -111,7 +111,7 @@ def mut_txt2layout(mut_output):
|
|
111 |
colors = [housegan_colors[housegan_labels[space]] for space in spaces]
|
112 |
_, im = draw_polygons(geom, colors, fpath=None)
|
113 |
|
114 |
-
legend = Image.open(
|
115 |
|
116 |
im = np.array(im)
|
117 |
im[:40, :] = np.array(legend)
|
@@ -138,13 +138,81 @@ def prompt_with_mutation(user_prompt, fpath=None):
|
|
138 |
|
139 |
# Gradio App
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
def gen_and_mutate(user_prompt, mutate=False):
|
142 |
if(mutate):
|
143 |
im, mut_im = None, None
|
144 |
while (mut_im is None):
|
145 |
im, mut_im, output, mut_output = prompt_with_mutation(user_prompt)
|
146 |
else:
|
147 |
-
mut_im=Image.open(
|
148 |
im, _ = prompt_to_layout(user_prompt)
|
149 |
|
150 |
return im, mut_im
|
@@ -156,7 +224,8 @@ generated = gr.outputs.Image(label='Generated Layout')
|
|
156 |
mutated = gr.outputs.Image(label='Mutated Layout')
|
157 |
|
158 |
iface = gr.Interface(fn=gen_and_mutate, inputs=[textbox, checkbox], outputs=[generated, mutated],
|
159 |
-
|
|
|
160 |
description='Demo of Semantic Generation of Residential Layouts \n',
|
161 |
article='''<div>
|
162 |
<p> This app allows users the use of natural language prompts for appartment layout generation, using a variety of semantic information:</p>
|
|
|
86 |
|
87 |
_, im = draw_polygons(geom, colors, fpath=fpath)
|
88 |
|
89 |
+
legend = Image.open("legend.png")
|
90 |
|
91 |
im = np.array(im)
|
92 |
im[:40, :] = np.array(legend)
|
|
|
111 |
colors = [housegan_colors[housegan_labels[space]] for space in spaces]
|
112 |
_, im = draw_polygons(geom, colors, fpath=None)
|
113 |
|
114 |
+
legend = Image.open("legend.png")
|
115 |
|
116 |
im = np.array(im)
|
117 |
im[:40, :] = np.array(legend)
|
|
|
138 |
|
139 |
# Gradio App
|
140 |
|
141 |
+
custom_css="""
|
142 |
+
@import url("https://use.typekit.net/nid3pfr.css");
|
143 |
+
.gradio_page {
|
144 |
+
display: flex;
|
145 |
+
width: 100vw;
|
146 |
+
height: 100vh;
|
147 |
+
flex-direction: column;
|
148 |
+
justify-content: center;
|
149 |
+
align-items: center;
|
150 |
+
margin: 0px;
|
151 |
+
max-width: 100vw;
|
152 |
+
background: #FFFFFF;
|
153 |
+
}
|
154 |
+
.gradio_interface {
|
155 |
+
width: 100vw;
|
156 |
+
max-width: 1500px;
|
157 |
+
}
|
158 |
+
.gradio_interface[theme=default] .panel_buttons {
|
159 |
+
justify-content: flex-end;
|
160 |
+
}
|
161 |
+
.gradio_interface[theme=default] .panel_button {
|
162 |
+
flex: 0 0 0;
|
163 |
+
min-width: 150px;
|
164 |
+
}
|
165 |
+
.gradio_interface[theme=default] .panel_button.submit {
|
166 |
+
background: #11213A;
|
167 |
+
border-radius: 5px;
|
168 |
+
color: #FFFFFF;
|
169 |
+
text-transform: uppercase;
|
170 |
+
min-width: 150px;
|
171 |
+
height: 4em;
|
172 |
+
letter-spacing: 0.15em;
|
173 |
+
flex: 0 0 0;
|
174 |
+
}
|
175 |
+
.gradio_interface[theme=default] .panel_button.submit:hover {
|
176 |
+
background: #000000;
|
177 |
+
}
|
178 |
+
.input_text {
|
179 |
+
font: 200 50px garamond-premier-pro-display, serif;
|
180 |
+
line-height: 115%;
|
181 |
+
color: #11213A;
|
182 |
+
border-radius: 0px;
|
183 |
+
border: 3px solid #11213A;
|
184 |
+
}
|
185 |
+
.input_text:focus {
|
186 |
+
border-color: #FA7880;
|
187 |
+
}
|
188 |
+
.gradio_interface[theme=default] .input_text input,
|
189 |
+
.gradio_interface[theme=default] .input_text textarea {
|
190 |
+
padding: 30px;
|
191 |
+
}
|
192 |
+
.input_text textarea:focus-visible {
|
193 |
+
outline: none;
|
194 |
+
}
|
195 |
+
.panel:nth-child(1) {
|
196 |
+
margin-left: 50px;
|
197 |
+
margin-right: 50px;
|
198 |
+
margin-top: 80px;
|
199 |
+
margin-bottom: 80px;
|
200 |
+
max-width: 750px;
|
201 |
+
}
|
202 |
+
.panel:nth-child(2) {
|
203 |
+
background: #D3ECF5;
|
204 |
+
}
|
205 |
+
.gradio_interface[theme=default] .component_set {
|
206 |
+
background: transparent;
|
207 |
+
}"""
|
208 |
+
|
209 |
def gen_and_mutate(user_prompt, mutate=False):
|
210 |
if(mutate):
|
211 |
im, mut_im = None, None
|
212 |
while (mut_im is None):
|
213 |
im, mut_im, output, mut_output = prompt_with_mutation(user_prompt)
|
214 |
else:
|
215 |
+
mut_im=Image.open("empty.png")
|
216 |
im, _ = prompt_to_layout(user_prompt)
|
217 |
|
218 |
return im, mut_im
|
|
|
224 |
mutated = gr.outputs.Image(label='Mutated Layout')
|
225 |
|
226 |
iface = gr.Interface(fn=gen_and_mutate, inputs=[textbox, checkbox], outputs=[generated, mutated],
|
227 |
+
css=custom_css,
|
228 |
+
thumbnail="thumbnail_gradio.PNG",
|
229 |
description='Demo of Semantic Generation of Residential Layouts \n',
|
230 |
article='''<div>
|
231 |
<p> This app allows users the use of natural language prompts for appartment layout generation, using a variety of semantic information:</p>
|
empty.png
ADDED
legend.png
ADDED
thumbnail_gradio.PNG
ADDED