Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -171,22 +171,15 @@ def style_transfer(content_image, style_image, alpha, beta, conv1_1, conv2_1, co
|
|
171 |
|
172 |
return final_image, intermediate_grid
|
173 |
|
|
|
|
|
174 |
|
175 |
# Example images
|
176 |
|
177 |
examples = [
|
178 |
-
["assets/content_1.jpg",
|
179 |
-
|
180 |
-
["assets/
|
181 |
-
"assets/style_2.jpg"],
|
182 |
-
["assets/content_3.png",
|
183 |
-
"assets/style_3.jpg"],
|
184 |
-
]
|
185 |
-
|
186 |
-
examples_output = [
|
187 |
-
"assets/result_1.png",
|
188 |
-
"assets/result_2.png",
|
189 |
-
"assets/result_3.png"
|
190 |
]
|
191 |
|
192 |
#Load VGG19 model
|
@@ -198,7 +191,7 @@ vgg.to(device)
|
|
198 |
|
199 |
|
200 |
# Resize example images
|
201 |
-
resized_examples = [[resize_image(content), resize_image(style)] for content, style in examples]
|
202 |
|
203 |
# Gradio interface
|
204 |
with gr.Blocks() as demo:
|
@@ -245,8 +238,10 @@ with gr.Blocks() as demo:
|
|
245 |
|
246 |
gr.Examples(
|
247 |
resized_examples,
|
248 |
-
inputs=[content_input, style_input],
|
249 |
-
outputs=
|
|
|
|
|
250 |
)
|
251 |
|
252 |
demo.launch()
|
|
|
171 |
|
172 |
return final_image, intermediate_grid
|
173 |
|
174 |
+
def load_example(content, style, output):
|
175 |
+
return content, style, output
|
176 |
|
177 |
# Example images
|
178 |
|
179 |
examples = [
|
180 |
+
["assets/content_1.jpg", "assets/style_1.jpg", "assets/result_1.png"],
|
181 |
+
["assets/content_2.jpg", "assets/style_2.jpg", "assets/result_2.png"],
|
182 |
+
["assets/content_3.png", "assets/style_3.jpg", "assets/result_3.png"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
]
|
184 |
|
185 |
#Load VGG19 model
|
|
|
191 |
|
192 |
|
193 |
# Resize example images
|
194 |
+
resized_examples = [[resize_image(content), resize_image(style), resize_image(output)] for content, style, output in examples]
|
195 |
|
196 |
# Gradio interface
|
197 |
with gr.Blocks() as demo:
|
|
|
238 |
|
239 |
gr.Examples(
|
240 |
resized_examples,
|
241 |
+
inputs=[content_input, style_input, output_image],
|
242 |
+
outputs=[content_input, style_input, output_image],
|
243 |
+
fn=load_example,
|
244 |
+
cache_examples=True
|
245 |
)
|
246 |
|
247 |
demo.launch()
|