nvn04 commited on
Commit
be78530
·
verified ·
1 Parent(s): 699e2a3

Simplify the UI

Browse files
Files changed (1) hide show
  1. app.py +143 -138
app.py CHANGED
@@ -316,7 +316,7 @@ HEADER = ""
316
  def app_gradio():
317
  with gr.Blocks(title="CatVTON") as demo:
318
  gr.Markdown(HEADER)
319
- with gr.Tab("Mask-based & SD1.5"):
320
  with gr.Row():
321
  with gr.Column(scale=1, min_width=350):
322
  with gr.Row():
@@ -332,7 +332,7 @@ def app_gradio():
332
  with gr.Row():
333
  with gr.Column(scale=1, min_width=230):
334
  cloth_image = gr.Image(
335
- interactive=True, label="Condition Image", type="filepath"
336
  )
337
  with gr.Column(scale=1, min_width=120):
338
  gr.Markdown(
@@ -350,27 +350,32 @@ def app_gradio():
350
  '<center><span style="color: #FF0000">!!! Click only Once, Wait for Delay !!!</span></center>'
351
  )
352
 
353
- gr.Markdown(
354
- '<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>'
355
- )
356
- with gr.Accordion("Advanced Options", open=False):
357
- num_inference_steps = gr.Slider(
358
- label="Inference Step", minimum=10, maximum=100, step=5, value=50
359
- )
360
- # Guidence Scale
361
- guidance_scale = gr.Slider(
362
- label="CFG Strenth", minimum=0.0, maximum=7.5, step=0.5, value=2.5
363
- )
364
- # Random Seed
365
- seed = gr.Slider(
366
- label="Seed", minimum=-1, maximum=10000, step=1, value=42
367
- )
368
- show_type = gr.Radio(
369
- label="Show Type",
370
- choices=["result only", "input & result", "input & mask & result"],
371
- value="input & mask & result",
372
- )
373
-
 
 
 
 
 
374
  with gr.Column(scale=2, min_width=500):
375
  result_image = gr.Image(interactive=False, label="Result")
376
  with gr.Row():
@@ -448,126 +453,126 @@ def app_gradio():
448
  result_image,
449
  )
450
 
451
- with gr.Tab("Mask-based & Flux.1 Fill Dev"):
452
- with gr.Row():
453
- with gr.Column(scale=1, min_width=350):
454
- with gr.Row():
455
- image_path_flux = gr.Image(
456
- type="filepath",
457
- interactive=True,
458
- visible=False,
459
- )
460
- person_image_flux = gr.ImageEditor(
461
- interactive=True, label="Person Image", type="filepath"
462
- )
463
 
464
- with gr.Row():
465
- with gr.Column(scale=1, min_width=230):
466
- cloth_image_flux = gr.Image(
467
- interactive=True, label="Condition Image", type="filepath"
468
- )
469
- with gr.Column(scale=1, min_width=120):
470
- gr.Markdown(
471
- '<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>'
472
- )
473
- cloth_type = gr.Radio(
474
- label="Try-On Cloth Type",
475
- choices=["upper", "lower", "overall"],
476
- value="upper",
477
- )
478
-
479
- submit_flux = gr.Button("Submit")
480
- gr.Markdown(
481
- '<center><span style="color: #FF0000">!!! Click only Once, Wait for Delay !!!</span></center>'
482
- )
483
 
484
- with gr.Accordion("Advanced Options", open=False):
485
- num_inference_steps_flux = gr.Slider(
486
- label="Inference Step", minimum=10, maximum=100, step=5, value=50
487
- )
488
- # Guidence Scale
489
- guidance_scale_flux = gr.Slider(
490
- label="CFG Strenth", minimum=0.0, maximum=50, step=0.5, value=30
491
- )
492
- # Random Seed
493
- seed_flux = gr.Slider(
494
- label="Seed", minimum=-1, maximum=10000, step=1, value=42
495
- )
496
- show_type = gr.Radio(
497
- label="Show Type",
498
- choices=["result only", "input & result", "input & mask & result"],
499
- value="input & mask & result",
500
- )
501
 
502
- with gr.Column(scale=2, min_width=500):
503
- result_image_flux = gr.Image(interactive=False, label="Result")
504
- with gr.Row():
505
- # Photo Examples
506
- root_path = "resource/demo/example"
507
- with gr.Column():
508
- gr.Examples(
509
- examples=[
510
- os.path.join(root_path, "person", "men", _)
511
- for _ in os.listdir(os.path.join(root_path, "person", "men"))
512
- ],
513
- examples_per_page=4,
514
- inputs=image_path_flux,
515
- label="Person Examples ①",
516
- )
517
- gr.Examples(
518
- examples=[
519
- os.path.join(root_path, "person", "women", _)
520
- for _ in os.listdir(os.path.join(root_path, "person", "women"))
521
- ],
522
- examples_per_page=4,
523
- inputs=image_path_flux,
524
- label="Person Examples ②",
525
- )
526
- gr.Markdown(
527
- '<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>'
528
- )
529
- with gr.Column():
530
- gr.Examples(
531
- examples=[
532
- os.path.join(root_path, "condition", "upper", _)
533
- for _ in os.listdir(os.path.join(root_path, "condition", "upper"))
534
- ],
535
- examples_per_page=4,
536
- inputs=cloth_image_flux,
537
- label="Condition Upper Examples",
538
- )
539
- gr.Examples(
540
- examples=[
541
- os.path.join(root_path, "condition", "overall", _)
542
- for _ in os.listdir(os.path.join(root_path, "condition", "overall"))
543
- ],
544
- examples_per_page=4,
545
- inputs=cloth_image_flux,
546
- label="Condition Overall Examples",
547
- )
548
- condition_person_exm = gr.Examples(
549
- examples=[
550
- os.path.join(root_path, "condition", "person", _)
551
- for _ in os.listdir(os.path.join(root_path, "condition", "person"))
552
- ],
553
- examples_per_page=4,
554
- inputs=cloth_image_flux,
555
- label="Condition Reference Person Examples",
556
- )
557
- gr.Markdown(
558
- '<span style="color: #808080; font-size: small;">*Condition examples come from the Internet. </span>'
559
- )
560
 
561
 
562
- image_path_flux.change(
563
- person_example_fn, inputs=image_path_flux, outputs=person_image_flux
564
- )
565
-
566
- submit_flux.click(
567
- submit_function_flux,
568
- [person_image_flux, cloth_image_flux, cloth_type, num_inference_steps_flux, guidance_scale_flux, seed_flux, show_type],
569
- result_image_flux,
570
- )
571
 
572
 
573
 
 
316
  def app_gradio():
317
  with gr.Blocks(title="CatVTON") as demo:
318
  gr.Markdown(HEADER)
319
+ with gr.Tab("Virtual Try on"):
320
  with gr.Row():
321
  with gr.Column(scale=1, min_width=350):
322
  with gr.Row():
 
332
  with gr.Row():
333
  with gr.Column(scale=1, min_width=230):
334
  cloth_image = gr.Image(
335
+ interactive=True, label="Clothes Image", type="filepath"
336
  )
337
  with gr.Column(scale=1, min_width=120):
338
  gr.Markdown(
 
350
  '<center><span style="color: #FF0000">!!! Click only Once, Wait for Delay !!!</span></center>'
351
  )
352
 
353
+ # gr.Markdown(
354
+ # '<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>'
355
+ # )
356
+ # with gr.Accordion("Advanced Options", open=False):
357
+ # num_inference_steps = gr.Slider(
358
+ # label="Inference Step", minimum=10, maximum=100, step=5, value=50
359
+ # )
360
+ # # Guidence Scale
361
+ # guidance_scale = gr.Slider(
362
+ # label="CFG Strenth", minimum=0.0, maximum=7.5, step=0.5, value=2.5
363
+ # )
364
+ # # Random Seed
365
+ # seed = gr.Slider(
366
+ # label="Seed", minimum=-1, maximum=10000, step=1, value=42
367
+ # )
368
+ # show_type = gr.Radio(
369
+ # label="Show Type",
370
+ # choices=["result only", "input & result", "input & mask & result"],
371
+ # value="input & mask & result",
372
+ # )
373
+
374
+ num_inference_steps = 50
375
+ guidance_scale = 2.5
376
+ seed = 42
377
+ show_type = "result only"
378
+
379
  with gr.Column(scale=2, min_width=500):
380
  result_image = gr.Image(interactive=False, label="Result")
381
  with gr.Row():
 
453
  result_image,
454
  )
455
 
456
+ # with gr.Tab("Mask-based & Flux.1 Fill Dev"):
457
+ # with gr.Row():
458
+ # with gr.Column(scale=1, min_width=350):
459
+ # with gr.Row():
460
+ # image_path_flux = gr.Image(
461
+ # type="filepath",
462
+ # interactive=True,
463
+ # visible=False,
464
+ # )
465
+ # person_image_flux = gr.ImageEditor(
466
+ # interactive=True, label="Person Image", type="filepath"
467
+ # )
468
 
469
+ # with gr.Row():
470
+ # with gr.Column(scale=1, min_width=230):
471
+ # cloth_image_flux = gr.Image(
472
+ # interactive=True, label="Condition Image", type="filepath"
473
+ # )
474
+ # with gr.Column(scale=1, min_width=120):
475
+ # gr.Markdown(
476
+ # '<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>'
477
+ # )
478
+ # cloth_type = gr.Radio(
479
+ # label="Try-On Cloth Type",
480
+ # choices=["upper", "lower", "overall"],
481
+ # value="upper",
482
+ # )
483
+
484
+ # submit_flux = gr.Button("Submit")
485
+ # gr.Markdown(
486
+ # '<center><span style="color: #FF0000">!!! Click only Once, Wait for Delay !!!</span></center>'
487
+ # )
488
 
489
+ # with gr.Accordion("Advanced Options", open=False):
490
+ # num_inference_steps_flux = gr.Slider(
491
+ # label="Inference Step", minimum=10, maximum=100, step=5, value=50
492
+ # )
493
+ # # Guidence Scale
494
+ # guidance_scale_flux = gr.Slider(
495
+ # label="CFG Strenth", minimum=0.0, maximum=50, step=0.5, value=30
496
+ # )
497
+ # # Random Seed
498
+ # seed_flux = gr.Slider(
499
+ # label="Seed", minimum=-1, maximum=10000, step=1, value=42
500
+ # )
501
+ # show_type = gr.Radio(
502
+ # label="Show Type",
503
+ # choices=["result only", "input & result", "input & mask & result"],
504
+ # value="input & mask & result",
505
+ # )
506
 
507
+ # with gr.Column(scale=2, min_width=500):
508
+ # result_image_flux = gr.Image(interactive=False, label="Result")
509
+ # with gr.Row():
510
+ # # Photo Examples
511
+ # root_path = "resource/demo/example"
512
+ # with gr.Column():
513
+ # gr.Examples(
514
+ # examples=[
515
+ # os.path.join(root_path, "person", "men", _)
516
+ # for _ in os.listdir(os.path.join(root_path, "person", "men"))
517
+ # ],
518
+ # examples_per_page=4,
519
+ # inputs=image_path_flux,
520
+ # label="Person Examples ①",
521
+ # )
522
+ # gr.Examples(
523
+ # examples=[
524
+ # os.path.join(root_path, "person", "women", _)
525
+ # for _ in os.listdir(os.path.join(root_path, "person", "women"))
526
+ # ],
527
+ # examples_per_page=4,
528
+ # inputs=image_path_flux,
529
+ # label="Person Examples ②",
530
+ # )
531
+ # gr.Markdown(
532
+ # '<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>'
533
+ # )
534
+ # with gr.Column():
535
+ # gr.Examples(
536
+ # examples=[
537
+ # os.path.join(root_path, "condition", "upper", _)
538
+ # for _ in os.listdir(os.path.join(root_path, "condition", "upper"))
539
+ # ],
540
+ # examples_per_page=4,
541
+ # inputs=cloth_image_flux,
542
+ # label="Condition Upper Examples",
543
+ # )
544
+ # gr.Examples(
545
+ # examples=[
546
+ # os.path.join(root_path, "condition", "overall", _)
547
+ # for _ in os.listdir(os.path.join(root_path, "condition", "overall"))
548
+ # ],
549
+ # examples_per_page=4,
550
+ # inputs=cloth_image_flux,
551
+ # label="Condition Overall Examples",
552
+ # )
553
+ # condition_person_exm = gr.Examples(
554
+ # examples=[
555
+ # os.path.join(root_path, "condition", "person", _)
556
+ # for _ in os.listdir(os.path.join(root_path, "condition", "person"))
557
+ # ],
558
+ # examples_per_page=4,
559
+ # inputs=cloth_image_flux,
560
+ # label="Condition Reference Person Examples",
561
+ # )
562
+ # gr.Markdown(
563
+ # '<span style="color: #808080; font-size: small;">*Condition examples come from the Internet. </span>'
564
+ # )
565
 
566
 
567
+ # image_path_flux.change(
568
+ # person_example_fn, inputs=image_path_flux, outputs=person_image_flux
569
+ # )
570
+
571
+ # submit_flux.click(
572
+ # submit_function_flux,
573
+ # [person_image_flux, cloth_image_flux, cloth_type, num_inference_steps_flux, guidance_scale_flux, seed_flux, show_type],
574
+ # result_image_flux,
575
+ # )
576
 
577
 
578