Spaces:
ginipick
/
Running on Zero

ginipick commited on
Commit
12cd271
ยท
verified ยท
1 Parent(s): 235a7ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +209 -212
app.py CHANGED
@@ -347,228 +347,225 @@ def leffa_predict_pt(src_image_path, ref_image_path):
347
  # ์ดˆ๊ธฐ ์„ค์ • ์‹คํ–‰
348
  setup()
349
 
350
- # Gradio ์ธํ„ฐํŽ˜์ด์Šค
351
- with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange") as demo:
352
- gr.Markdown("# ๐ŸŽญ FitGen:Fashion Studio & Virtual Try-on")
353
-
354
- with gr.Tabs():
355
- # ํŒจ์…˜ ์ƒ์„ฑ ํƒญ
356
-
357
- # ํŒจ์…˜ ์ƒ์„ฑ ํƒญ
358
- with gr.Tab("Fashion Generation"):
359
- with gr.Column():
360
- mode = gr.Radio(
361
- choices=["Generate Model", "Generate Clothes"],
362
- label="Generation Mode",
363
- value="Generate Model"
364
- )
365
-
366
- # ์˜ˆ์ œ ํ”„๋กฌํ”„ํŠธ ์„ค์ •
367
- example_model_prompts = [
368
- "professional fashion model, full body shot, standing pose, natural lighting, studio background, high fashion, elegant pose",
369
- "fashion model portrait, upper body, confident pose, fashion photography, neutral background, professional lighting",
370
- "stylish fashion model, three-quarter view, editorial pose, high-end fashion magazine style, minimal background"
371
- ]
372
-
373
- example_clothes_prompts = [
374
- "luxury designer sweater, cashmere material, cream color, cable knit pattern, high-end fashion, product photography",
375
- "elegant business blazer, tailored fit, charcoal grey, premium wool fabric, professional wear",
376
- "modern streetwear hoodie, oversized fit, minimalist design, premium cotton, urban style"
377
- ]
378
-
379
- prompt = gr.TextArea(
380
- label="Fashion Description (ํ•œ๊ธ€ ๋˜๋Š” ์˜์–ด)",
381
- placeholder="ํŒจ์…˜ ๋ชจ๋ธ์ด๋‚˜ ์˜๋ฅ˜๋ฅผ ์„ค๋ช…ํ•˜์„ธ์š”..."
382
- )
383
-
384
- # ์˜ˆ์ œ ์„น์…˜ ์ถ”๊ฐ€
385
- gr.Examples(
386
- examples=example_model_prompts + example_clothes_prompts,
387
- inputs=prompt,
388
- label="Example Prompts"
389
- )
390
-
391
- with gr.Row():
392
- with gr.Column():
393
- result = gr.Image(label="Generated Result")
394
- generate_button = gr.Button("Generate Fashion")
395
 
396
-
397
-
398
- with gr.Accordion("Advanced Options", open=False):
399
- with gr.Group():
400
- with gr.Row():
401
- with gr.Column():
402
- cfg_scale = gr.Slider(
403
- label="CFG Scale",
404
- minimum=1,
405
- maximum=20,
406
- step=0.5,
407
- value=7.0
408
- )
409
- steps = gr.Slider(
410
- label="Steps",
411
- minimum=1,
412
- maximum=50, # ์ตœ๋Œ€๊ฐ’ ๊ฐ์†Œ
413
- step=1,
414
- value=30
415
- )
416
- lora_scale = gr.Slider(
417
- label="LoRA Scale",
418
- minimum=0,
419
- maximum=1,
420
- step=0.01,
421
- value=0.85
422
- )
423
-
424
- with gr.Row():
425
- width = gr.Slider(
426
- label="Width",
427
- minimum=256,
428
- maximum=1024, # ์ตœ๋Œ€๊ฐ’ ๊ฐ์†Œ
429
- step=64,
430
- value=512
431
- )
432
- height = gr.Slider(
433
- label="Height",
434
- minimum=256,
435
- maximum=1024, # ์ตœ๋Œ€๊ฐ’ ๊ฐ์†Œ
436
- step=64,
437
- value=768
438
- )
439
-
440
- with gr.Row():
441
- randomize_seed = gr.Checkbox(
442
- True,
443
- label="Randomize seed"
444
- )
445
- seed = gr.Slider(
446
- label="Seed",
447
- minimum=0,
448
- maximum=MAX_SEED,
449
- step=1,
450
- value=42
451
- )
452
-
453
- # ๊ฐ€์ƒ ํ”ผํŒ… ํƒญ
454
- with gr.Tab("Virtual Try-on"):
455
- with gr.Row():
456
  with gr.Column():
457
- gr.Markdown("#### Person Image")
458
- vt_src_image = gr.Image(
459
- sources=["upload"],
460
- type="filepath",
461
- label="Person Image",
462
- width=512,
463
- height=512,
464
- )
465
- gr.Examples(
466
- inputs=vt_src_image,
467
- examples_per_page=5,
468
- examples=["a1.webp",
469
- "a2.webp",
470
- "a3.webp",
471
- "a4.webp",
472
- "a5.webp"]
473
  )
474
-
475
- with gr.Column():
476
- gr.Markdown("#### Garment Image")
477
- vt_ref_image = gr.Image(
478
- sources=["upload"],
479
- type="filepath",
480
- label="Garment Image",
481
- width=512,
482
- height=512,
 
 
 
 
 
 
 
 
483
  )
 
 
484
  gr.Examples(
485
- inputs=vt_ref_image,
486
- examples_per_page=5,
487
- examples=["b1.webp",
488
- "b2.webp",
489
- "b3.webp",
490
- "b4.webp",
491
- "b5.webp"]
492
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
493
 
494
- with gr.Column():
495
- gr.Markdown("#### Generated Image")
496
- vt_gen_image = gr.Image(
497
- label="Generated Image",
498
- width=512,
499
- height=512,
500
- )
501
- vt_gen_button = gr.Button("Try-on")
 
 
 
 
 
 
 
 
 
 
 
 
 
502
 
503
- # ํฌ์ฆˆ ์ „์†ก ํƒญ
504
- with gr.Tab("Pose Transfer"):
505
- with gr.Row():
506
- with gr.Column():
507
- gr.Markdown("#### Person Image")
508
- pt_ref_image = gr.Image(
509
- sources=["upload"],
510
- type="filepath",
511
- label="Person Image",
512
- width=512,
513
- height=512,
514
- )
515
- gr.Examples(
516
- inputs=pt_ref_image,
517
- examples_per_page=5,
518
- examples=["a1.webp",
519
- "a2.webp",
520
- "a3.webp",
521
- "a4.webp",
522
- "a5.webp"]
523
- )
524
 
525
- with gr.Column():
526
- gr.Markdown("#### Target Pose Person Image")
527
- pt_src_image = gr.Image(
528
- sources=["upload"],
529
- type="filepath",
530
- label="Target Pose Person Image",
531
- width=512,
532
- height=512,
533
- )
534
- gr.Examples(
535
- inputs=pt_src_image,
536
- examples_per_page=5,
537
- examples=["d1.webp",
538
- "d2.webp",
539
- "d3.webp",
540
- "d4.webp",
541
- "d5.webp"]
542
- )
 
 
 
 
 
 
 
 
 
 
 
 
543
 
544
- with gr.Column():
545
- gr.Markdown("#### Generated Image")
546
- pt_gen_image = gr.Image(
547
- label="Generated Image",
548
- width=512,
549
- height=512,
550
- )
551
- pose_transfer_gen_button = gr.Button("Generate")
552
-
553
- # ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ
554
- generate_button.click(
555
- generate_fashion,
556
- inputs=[prompt, mode, cfg_scale, steps, randomize_seed, seed, width, height, lora_scale],
557
- outputs=[result, seed]
558
- )
559
-
560
- vt_gen_button.click(
561
- fn=leffa_predict_vt,
562
- inputs=[vt_src_image, vt_ref_image],
563
- outputs=[vt_gen_image]
564
- )
565
-
566
- pose_transfer_gen_button.click(
567
- fn=leffa_predict_pt,
568
- inputs=[pt_src_image, pt_ref_image],
569
- outputs=[pt_gen_image]
570
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
571
 
 
572
 
573
  if __name__ == "__main__":
574
  # ํ™˜๊ฒฝ ์„ค์ •
@@ -580,4 +577,4 @@ if __name__ == "__main__":
580
  server_name="0.0.0.0",
581
  server_port=7860,
582
  share=False
583
- )
 
347
  # ์ดˆ๊ธฐ ์„ค์ • ์‹คํ–‰
348
  setup()
349
 
350
+ def create_interface():
351
+ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange") as demo:
352
+ gr.Markdown("# ๐ŸŽญ FitGen:Fashion Studio & Virtual Try-on")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
 
354
+ with gr.Tabs():
355
+ # ํŒจ์…˜ ์ƒ์„ฑ ํƒญ
356
+ with gr.Tab("Fashion Generation"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
357
  with gr.Column():
358
+ mode = gr.Radio(
359
+ choices=["Generate Model", "Generate Clothes"],
360
+ label="Generation Mode",
361
+ value="Generate Model"
 
 
 
 
 
 
 
 
 
 
 
 
362
  )
363
+
364
+ # ์˜ˆ์ œ ํ”„๋กฌํ”„ํŠธ ์„ค์ •
365
+ example_model_prompts = [
366
+ "professional fashion model, full body shot, standing pose, natural lighting, studio background, high fashion, elegant pose",
367
+ "fashion model portrait, upper body, confident pose, fashion photography, neutral background, professional lighting",
368
+ "stylish fashion model, three-quarter view, editorial pose, high-end fashion magazine style, minimal background"
369
+ ]
370
+
371
+ example_clothes_prompts = [
372
+ "luxury designer sweater, cashmere material, cream color, cable knit pattern, high-end fashion, product photography",
373
+ "elegant business blazer, tailored fit, charcoal grey, premium wool fabric, professional wear",
374
+ "modern streetwear hoodie, oversized fit, minimalist design, premium cotton, urban style"
375
+ ]
376
+
377
+ prompt = gr.TextArea(
378
+ label="Fashion Description (ํ•œ๊ธ€ ๋˜๋Š” ์˜์–ด)",
379
+ placeholder="ํŒจ์…˜ ๋ชจ๋ธ์ด๋‚˜ ์˜๋ฅ˜๋ฅผ ์„ค๋ช…ํ•˜์„ธ์š”..."
380
  )
381
+
382
+ # ์˜ˆ์ œ ์„น์…˜ ์ถ”๊ฐ€
383
  gr.Examples(
384
+ examples=example_model_prompts + example_clothes_prompts,
385
+ inputs=prompt,
386
+ label="Example Prompts"
 
 
 
 
387
  )
388
+
389
+ with gr.Row():
390
+ with gr.Column():
391
+ result = gr.Image(label="Generated Result")
392
+ generate_button = gr.Button("Generate Fashion")
393
+
394
+ with gr.Accordion("Advanced Options", open=False):
395
+ with gr.Group():
396
+ with gr.Row():
397
+ with gr.Column():
398
+ cfg_scale = gr.Slider(
399
+ label="CFG Scale",
400
+ minimum=1,
401
+ maximum=20,
402
+ step=0.5,
403
+ value=7.0
404
+ )
405
+ steps = gr.Slider(
406
+ label="Steps",
407
+ minimum=1,
408
+ maximum=30,
409
+ step=1,
410
+ value=30
411
+ )
412
+ lora_scale = gr.Slider(
413
+ label="LoRA Scale",
414
+ minimum=0,
415
+ maximum=1,
416
+ step=0.01,
417
+ value=0.85
418
+ )
419
+
420
+ with gr.Row():
421
+ width = gr.Slider(
422
+ label="Width",
423
+ minimum=256,
424
+ maximum=768,
425
+ step=64,
426
+ value=512
427
+ )
428
+ height = gr.Slider(
429
+ label="Height",
430
+ minimum=256,
431
+ maximum=768,
432
+ step=64,
433
+ value=768
434
+ )
435
+
436
+ with gr.Row():
437
+ randomize_seed = gr.Checkbox(
438
+ True,
439
+ label="Randomize seed"
440
+ )
441
+ seed = gr.Slider(
442
+ label="Seed",
443
+ minimum=0,
444
+ maximum=2**32-1,
445
+ step=1,
446
+ value=42
447
+ )
448
 
449
+ # ๊ฐ€์ƒ ํ”ผํŒ… ํƒญ
450
+ with gr.Tab("Virtual Try-on"):
451
+ with gr.Row():
452
+ with gr.Column():
453
+ gr.Markdown("#### Person Image")
454
+ vt_src_image = gr.Image(
455
+ sources=["upload"],
456
+ type="filepath",
457
+ label="Person Image",
458
+ width=512,
459
+ height=512,
460
+ )
461
+ gr.Examples(
462
+ inputs=vt_src_image,
463
+ examples_per_page=5,
464
+ examples=["a1.webp",
465
+ "a2.webp",
466
+ "a3.webp",
467
+ "a4.webp",
468
+ "a5.webp"]
469
+ )
470
 
471
+ with gr.Column():
472
+ gr.Markdown("#### Garment Image")
473
+ vt_ref_image = gr.Image(
474
+ sources=["upload"],
475
+ type="filepath",
476
+ label="Garment Image",
477
+ width=512,
478
+ height=512,
479
+ )
480
+ gr.Examples(
481
+ inputs=vt_ref_image,
482
+ examples_per_page=5,
483
+ examples=["b1.webp",
484
+ "b2.webp",
485
+ "b3.webp",
486
+ "b4.webp",
487
+ "b5.webp"]
488
+ )
 
 
 
489
 
490
+ with gr.Column():
491
+ gr.Markdown("#### Generated Image")
492
+ vt_gen_image = gr.Image(
493
+ label="Generated Image",
494
+ width=512,
495
+ height=512,
496
+ )
497
+ vt_gen_button = gr.Button("Try-on")
498
+
499
+ # ํฌ์ฆˆ ์ „์†ก ํƒญ
500
+ with gr.Tab("Pose Transfer"):
501
+ with gr.Row():
502
+ with gr.Column():
503
+ gr.Markdown("#### Person Image")
504
+ pt_ref_image = gr.Image(
505
+ sources=["upload"],
506
+ type="filepath",
507
+ label="Person Image",
508
+ width=512,
509
+ height=512,
510
+ )
511
+ gr.Examples(
512
+ inputs=pt_ref_image,
513
+ examples_per_page=5,
514
+ examples=["a1.webp",
515
+ "a2.webp",
516
+ "a3.webp",
517
+ "a4.webp",
518
+ "a5.webp"]
519
+ )
520
 
521
+ with gr.Column():
522
+ gr.Markdown("#### Target Pose Person Image")
523
+ pt_src_image = gr.Image(
524
+ sources=["upload"],
525
+ type="filepath",
526
+ label="Target Pose Person Image",
527
+ width=512,
528
+ height=512,
529
+ )
530
+ gr.Examples(
531
+ inputs=pt_src_image,
532
+ examples_per_page=5,
533
+ examples=["d1.webp",
534
+ "d2.webp",
535
+ "d3.webp",
536
+ "d4.webp",
537
+ "d5.webp"]
538
+ )
539
+
540
+ with gr.Column():
541
+ gr.Markdown("#### Generated Image")
542
+ pt_gen_image = gr.Image(
543
+ label="Generated Image",
544
+ width=512,
545
+ height=512,
546
+ )
547
+ pose_transfer_gen_button = gr.Button("Generate")
548
+
549
+ # ์ด๋ฒคํŠธ ํ•ธ๋“ค๋Ÿฌ
550
+ generate_button.click(
551
+ fn=generate_image,
552
+ inputs=[prompt, mode, cfg_scale, steps, seed, width, height, lora_scale],
553
+ outputs=[result, seed]
554
+ )
555
+
556
+ vt_gen_button.click(
557
+ fn=leffa_predict_vt,
558
+ inputs=[vt_src_image, vt_ref_image],
559
+ outputs=[vt_gen_image]
560
+ )
561
+
562
+ pose_transfer_gen_button.click(
563
+ fn=leffa_predict_pt,
564
+ inputs=[pt_src_image, pt_ref_image],
565
+ outputs=[pt_gen_image]
566
+ )
567
 
568
+ return demo
569
 
570
  if __name__ == "__main__":
571
  # ํ™˜๊ฒฝ ์„ค์ •
 
577
  server_name="0.0.0.0",
578
  server_port=7860,
579
  share=False
580
+ )