Update app.py
Browse files
app.py
CHANGED
@@ -347,228 +347,225 @@ def leffa_predict_pt(src_image_path, ref_image_path):
|
|
347 |
# ์ด๊ธฐ ์ค์ ์คํ
|
348 |
setup()
|
349 |
|
350 |
-
|
351 |
-
with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange") as demo:
|
352 |
-
|
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 |
-
|
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.
|
458 |
-
|
459 |
-
|
460 |
-
|
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 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
483 |
)
|
|
|
|
|
484 |
gr.Examples(
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
"b2.webp",
|
489 |
-
"b3.webp",
|
490 |
-
"b4.webp",
|
491 |
-
"b5.webp"]
|
492 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
493 |
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
502 |
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
"a4.webp",
|
522 |
-
"a5.webp"]
|
523 |
-
)
|
524 |
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
543 |
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
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 |
+
)
|