Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -239,8 +239,23 @@ HEADER = """
|
|
239 |
"""
|
240 |
|
241 |
def app_gradio():
|
242 |
-
with gr.Blocks(title="
|
243 |
-
gr.Markdown(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
244 |
with gr.Row():
|
245 |
with gr.Column(scale=1, min_width=350):
|
246 |
with gr.Row():
|
@@ -250,55 +265,70 @@ def app_gradio():
|
|
250 |
visible=False,
|
251 |
)
|
252 |
person_image = gr.ImageEditor(
|
253 |
-
interactive=True,
|
|
|
|
|
254 |
)
|
255 |
|
256 |
with gr.Row():
|
257 |
with gr.Column(scale=1, min_width=230):
|
258 |
cloth_image = gr.Image(
|
259 |
-
interactive=True,
|
|
|
|
|
260 |
)
|
261 |
with gr.Column(scale=1, min_width=120):
|
262 |
gr.Markdown(
|
263 |
-
'<
|
264 |
)
|
265 |
cloth_type = gr.Radio(
|
266 |
-
label="
|
267 |
choices=["upper", "lower", "overall"],
|
268 |
value="upper",
|
269 |
)
|
270 |
|
271 |
-
|
272 |
-
submit = gr.Button("Submit")
|
273 |
gr.Markdown(
|
274 |
-
'<
|
275 |
)
|
276 |
|
277 |
gr.Markdown(
|
278 |
-
'<
|
279 |
)
|
280 |
-
with gr.Accordion("Advanced
|
281 |
num_inference_steps = gr.Slider(
|
282 |
-
label="
|
|
|
|
|
|
|
|
|
283 |
)
|
284 |
-
# Guidence Scale
|
285 |
guidance_scale = gr.Slider(
|
286 |
-
label="
|
|
|
|
|
|
|
|
|
287 |
)
|
288 |
-
# Random Seed
|
289 |
seed = gr.Slider(
|
290 |
-
label="Seed",
|
|
|
|
|
|
|
|
|
291 |
)
|
292 |
show_type = gr.Radio(
|
293 |
-
label="
|
294 |
choices=["result only", "input & result", "input & mask & result"],
|
295 |
value="input & mask & result",
|
296 |
)
|
297 |
|
298 |
with gr.Column(scale=2, min_width=500):
|
299 |
-
result_image = gr.Image(
|
|
|
|
|
|
|
300 |
with gr.Row():
|
301 |
-
# Photo Examples
|
302 |
root_path = "resource/demo/example"
|
303 |
with gr.Column():
|
304 |
men_exm = gr.Examples(
|
@@ -308,7 +338,7 @@ def app_gradio():
|
|
308 |
],
|
309 |
examples_per_page=4,
|
310 |
inputs=image_path,
|
311 |
-
label="
|
312 |
)
|
313 |
women_exm = gr.Examples(
|
314 |
examples=[
|
@@ -317,10 +347,7 @@ def app_gradio():
|
|
317 |
],
|
318 |
examples_per_page=4,
|
319 |
inputs=image_path,
|
320 |
-
label="
|
321 |
-
)
|
322 |
-
gr.Markdown(
|
323 |
-
'<span style="color: #808080; font-size: small;">*Person examples come from the demos of <a href="https://huggingface.co/spaces/levihsu/OOTDiffusion">OOTDiffusion</a> and <a href="https://www.outfitanyone.org">OutfitAnyone</a>. </span>'
|
324 |
)
|
325 |
with gr.Column():
|
326 |
condition_upper_exm = gr.Examples(
|
@@ -330,7 +357,7 @@ def app_gradio():
|
|
330 |
],
|
331 |
examples_per_page=4,
|
332 |
inputs=cloth_image,
|
333 |
-
label="
|
334 |
)
|
335 |
condition_overall_exm = gr.Examples(
|
336 |
examples=[
|
@@ -339,7 +366,7 @@ def app_gradio():
|
|
339 |
],
|
340 |
examples_per_page=4,
|
341 |
inputs=cloth_image,
|
342 |
-
label="
|
343 |
)
|
344 |
condition_person_exm = gr.Examples(
|
345 |
examples=[
|
@@ -348,14 +375,13 @@ def app_gradio():
|
|
348 |
],
|
349 |
examples_per_page=4,
|
350 |
inputs=cloth_image,
|
351 |
-
label="
|
352 |
-
)
|
353 |
-
gr.Markdown(
|
354 |
-
'<span style="color: #808080; font-size: small;">*Condition examples come from the Internet. </span>'
|
355 |
)
|
356 |
|
357 |
image_path.change(
|
358 |
-
person_example_fn,
|
|
|
|
|
359 |
)
|
360 |
|
361 |
submit.click(
|
@@ -371,6 +397,7 @@ def app_gradio():
|
|
371 |
],
|
372 |
result_image,
|
373 |
)
|
|
|
374 |
demo.queue().launch(share=True, show_error=True)
|
375 |
|
376 |
|
|
|
239 |
"""
|
240 |
|
241 |
def app_gradio():
|
242 |
+
with gr.Blocks(title="Deradh Virtual Try-On", css="button.primary-btn { background: #1a237e; } .gr-button { background: #1a237e; color: white; } body { background-color: #f8f9fa; }") as demo:
|
243 |
+
gr.Markdown(
|
244 |
+
"""
|
245 |
+
<div style="text-align: center; background-color: #1a237e; padding: 2rem; color: white;">
|
246 |
+
<h1>Deradh Virtual Try-On Experience</h1>
|
247 |
+
<div style="margin: 1rem 0;">
|
248 |
+
<a href="https://deradh.com" style="color: white; text-decoration: underline;">
|
249 |
+
Visit Deradh.com
|
250 |
+
</a>
|
251 |
+
</div>
|
252 |
+
</div>
|
253 |
+
<div style="text-align: center; padding: 1rem; color: #1a237e;">
|
254 |
+
Experience the future of fashion with our AI-powered virtual try-on technology
|
255 |
+
</div>
|
256 |
+
"""
|
257 |
+
)
|
258 |
+
|
259 |
with gr.Row():
|
260 |
with gr.Column(scale=1, min_width=350):
|
261 |
with gr.Row():
|
|
|
265 |
visible=False,
|
266 |
)
|
267 |
person_image = gr.ImageEditor(
|
268 |
+
interactive=True,
|
269 |
+
label="Upload Your Photo",
|
270 |
+
type="filepath"
|
271 |
)
|
272 |
|
273 |
with gr.Row():
|
274 |
with gr.Column(scale=1, min_width=230):
|
275 |
cloth_image = gr.Image(
|
276 |
+
interactive=True,
|
277 |
+
label="Select Garment",
|
278 |
+
type="filepath"
|
279 |
)
|
280 |
with gr.Column(scale=1, min_width=120):
|
281 |
gr.Markdown(
|
282 |
+
'<div style="color: white; background-color: #1a237e; padding: 1rem; border-radius: 4px;">Mask Options:<br>1. Draw mask using the editor above<br>2. Auto-generate based on garment type</div>'
|
283 |
)
|
284 |
cloth_type = gr.Radio(
|
285 |
+
label="Garment Type",
|
286 |
choices=["upper", "lower", "overall"],
|
287 |
value="upper",
|
288 |
)
|
289 |
|
290 |
+
submit = gr.Button("Try On", elem_classes="primary-btn")
|
|
|
291 |
gr.Markdown(
|
292 |
+
'<div style="text-align: center; color: #1a237e; font-weight: bold; margin: 1rem 0;">Please wait after clicking Try On - Processing may take a moment</div>'
|
293 |
)
|
294 |
|
295 |
gr.Markdown(
|
296 |
+
'<div style="background-color: #1a237e; color: white; padding: 1rem; border-radius: 4px; margin-top: 1rem;">Advanced Settings:<br>• Increase Steps for higher quality<br>• Adjust CFG for color intensity<br>• Change Seed for different variations</div>'
|
297 |
)
|
298 |
+
with gr.Accordion("Advanced Settings", open=False):
|
299 |
num_inference_steps = gr.Slider(
|
300 |
+
label="Quality Steps",
|
301 |
+
minimum=10,
|
302 |
+
maximum=100,
|
303 |
+
step=5,
|
304 |
+
value=50
|
305 |
)
|
|
|
306 |
guidance_scale = gr.Slider(
|
307 |
+
label="Style Intensity",
|
308 |
+
minimum=0.0,
|
309 |
+
maximum=7.5,
|
310 |
+
step=0.5,
|
311 |
+
value=2.5
|
312 |
)
|
|
|
313 |
seed = gr.Slider(
|
314 |
+
label="Variation Seed",
|
315 |
+
minimum=-1,
|
316 |
+
maximum=10000,
|
317 |
+
step=1,
|
318 |
+
value=42
|
319 |
)
|
320 |
show_type = gr.Radio(
|
321 |
+
label="Display Options",
|
322 |
choices=["result only", "input & result", "input & mask & result"],
|
323 |
value="input & mask & result",
|
324 |
)
|
325 |
|
326 |
with gr.Column(scale=2, min_width=500):
|
327 |
+
result_image = gr.Image(
|
328 |
+
interactive=False,
|
329 |
+
label="Virtual Try-On Result"
|
330 |
+
)
|
331 |
with gr.Row():
|
|
|
332 |
root_path = "resource/demo/example"
|
333 |
with gr.Column():
|
334 |
men_exm = gr.Examples(
|
|
|
338 |
],
|
339 |
examples_per_page=4,
|
340 |
inputs=image_path,
|
341 |
+
label="Sample Photos - Men",
|
342 |
)
|
343 |
women_exm = gr.Examples(
|
344 |
examples=[
|
|
|
347 |
],
|
348 |
examples_per_page=4,
|
349 |
inputs=image_path,
|
350 |
+
label="Sample Photos - Women",
|
|
|
|
|
|
|
351 |
)
|
352 |
with gr.Column():
|
353 |
condition_upper_exm = gr.Examples(
|
|
|
357 |
],
|
358 |
examples_per_page=4,
|
359 |
inputs=cloth_image,
|
360 |
+
label="Sample Upper Garments",
|
361 |
)
|
362 |
condition_overall_exm = gr.Examples(
|
363 |
examples=[
|
|
|
366 |
],
|
367 |
examples_per_page=4,
|
368 |
inputs=cloth_image,
|
369 |
+
label="Sample Full Outfits",
|
370 |
)
|
371 |
condition_person_exm = gr.Examples(
|
372 |
examples=[
|
|
|
375 |
],
|
376 |
examples_per_page=4,
|
377 |
inputs=cloth_image,
|
378 |
+
label="Style Reference Photos",
|
|
|
|
|
|
|
379 |
)
|
380 |
|
381 |
image_path.change(
|
382 |
+
person_example_fn,
|
383 |
+
inputs=image_path,
|
384 |
+
outputs=person_image
|
385 |
)
|
386 |
|
387 |
submit.click(
|
|
|
397 |
],
|
398 |
result_image,
|
399 |
)
|
400 |
+
|
401 |
demo.queue().launch(share=True, show_error=True)
|
402 |
|
403 |
|