Gopalag commited on
Commit
9feed13
·
verified ·
1 Parent(s): 5df167a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -31
app.py CHANGED
@@ -239,8 +239,23 @@ HEADER = """
239
  """
240
 
241
  def app_gradio():
242
- with gr.Blocks(title="CatVTON") as demo:
243
- gr.Markdown(HEADER)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, label="Person Image", type="filepath"
 
 
254
  )
255
 
256
  with gr.Row():
257
  with gr.Column(scale=1, min_width=230):
258
  cloth_image = gr.Image(
259
- interactive=True, label="Condition Image", type="filepath"
 
 
260
  )
261
  with gr.Column(scale=1, min_width=120):
262
  gr.Markdown(
263
- '<span style="color: #808080; font-size: small;">Two ways to provide Mask:<br>1. Upload the person image and use the `🖌️` above to draw the Mask (higher priority)<br>2. Select the `Try-On Cloth Type` to generate automatically </span>'
264
  )
265
  cloth_type = gr.Radio(
266
- label="Try-On Cloth Type",
267
  choices=["upper", "lower", "overall"],
268
  value="upper",
269
  )
270
 
271
-
272
- submit = gr.Button("Submit")
273
  gr.Markdown(
274
- '<center><span style="color: #FF0000">!!! Click only Once, Wait for Delay !!!</span></center>'
275
  )
276
 
277
  gr.Markdown(
278
- '<span style="color: #808080; font-size: small;">Advanced options can adjust details:<br>1. `Inference Step` may enhance details;<br>2. `CFG` is highly correlated with saturation;<br>3. `Random seed` may improve pseudo-shadow.</span>'
279
  )
280
- with gr.Accordion("Advanced Options", open=False):
281
  num_inference_steps = gr.Slider(
282
- label="Inference Step", minimum=10, maximum=100, step=5, value=50
 
 
 
 
283
  )
284
- # Guidence Scale
285
  guidance_scale = gr.Slider(
286
- label="CFG Strenth", minimum=0.0, maximum=7.5, step=0.5, value=2.5
 
 
 
 
287
  )
288
- # Random Seed
289
  seed = gr.Slider(
290
- label="Seed", minimum=-1, maximum=10000, step=1, value=42
 
 
 
 
291
  )
292
  show_type = gr.Radio(
293
- label="Show Type",
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(interactive=False, label="Result")
 
 
 
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="Person Examples ",
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="Person Examples ",
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="Condition Upper Examples",
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="Condition Overall Examples",
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="Condition Reference Person Examples",
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, inputs=image_path, outputs=person_image
 
 
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