nami0342 commited on
Commit
9715fba
ยท
1 Parent(s): 1d9a2a9

Restore UI

Browse files
Files changed (1) hide show
  1. app.py +9 -120
app.py CHANGED
@@ -474,138 +474,27 @@ human_ex_list = human_list_path
474
 
475
  image_blocks = gr.Blocks().queue()
476
  with image_blocks as demo:
477
- # ImageEditor์˜ canvas ์‹ค์ œ ํฌ๊ธฐ๋งŒ ๊ณ ์ •ํ•˜์—ฌ ๋ธŒ๋Ÿฌ์‹œ ์œ„์น˜ ์ •ํ™•๋„ ์œ ์ง€ (๊ธฐ๋ณธ ๊ธฐ๋Šฅ ๋ณด์กด)
478
- gr.HTML("""
479
- <style>
480
- /* ์ถœ๋ ฅ ์ด๋ฏธ์ง€ ํฌ๊ธฐ ๊ณ ์ •: Masked image output ๋ฐ Output */
481
- /* PC: ๊ณ ์ • ํฌ๊ธฐ (384x512) */
482
- @media (min-width: 768px) {
483
- #masked-img img,
484
- #output-img img {
485
- width: 384px !important;
486
- height: 512px !important;
487
- max-width: 384px !important;
488
- max-height: 512px !important;
489
- object-fit: contain !important;
490
- }
491
- #masked-img,
492
- #output-img {
493
- max-width: 384px !important;
494
- }
495
- }
496
-
497
- /* ๋ชจ๋ฐ”์ผ: ํ™”๋ฉด ํฌ๊ธฐ์— ๋งž๊ฒŒ ์Šค์ผ€์ผ๋งํ•˜๋˜ ๋น„์œจ ์œ ์ง€ (์ตœ๋Œ€ 384px) */
498
- @media (max-width: 767px) {
499
- #masked-img img,
500
- #output-img img {
501
- width: 100% !important;
502
- max-width: 384px !important;
503
- height: auto !important;
504
- aspect-ratio: 3/4 !important;
505
- object-fit: contain !important;
506
- }
507
- #masked-img,
508
- #output-img {
509
- width: 100% !important;
510
- max-width: 384px !important;
511
- }
512
- }
513
-
514
- /* ImageEditor: ์ด๋ฏธ์ง€๋งŒ ํ”„๋ ˆ์ž„ ์•ˆ์— ๋งž์ถ”๊ธฐ (UI ์š”์†Œ๋Š” ๊ฑด๋“œ๋ฆฌ์ง€ ์•Š์Œ) */
515
- #image-editor-fixed canvas {
516
- object-fit: contain !important;
517
- }
518
- #image-editor-fixed img {
519
- object-fit: contain !important;
520
- max-width: 100% !important;
521
- max-height: 100% !important;
522
- }
523
- </style>
524
- <script>
525
- // ImageEditor์˜ canvas ์‹ค์ œ ํ”ฝ์…€ ํฌ๊ธฐ๋งŒ ๊ณ ์ •ํ•˜์—ฌ ๋ธŒ๋Ÿฌ์‹œ ์œ„์น˜ ์ •ํ™•๋„ ์œ ์ง€
526
- // ํ”„๋ ˆ์ž„๊ณผ UI ์š”์†Œ๋Š” Gradio์˜ ๊ธฐ๋ณธ ๋™์ž‘์— ๋งก๊น€
527
- (function() {
528
- const CANVAS_WIDTH = 384;
529
- const CANVAS_HEIGHT = 512;
530
-
531
- function fixImageEditorCanvas() {
532
- const editor = document.querySelector('#image-editor-fixed');
533
- if (!editor) return;
534
-
535
- // ImageEditor ๋‚ด๋ถ€์˜ ๋ชจ๋“  canvas ์ฐพ๊ธฐ
536
- const canvases = editor.querySelectorAll('canvas');
537
- canvases.forEach(function(canvas) {
538
- // canvas์˜ ์‹ค์ œ ํ”ฝ์…€ ํฌ๊ธฐ๋Š” ํ•ญ์ƒ ๊ณ ์ • (๋ธŒ๋Ÿฌ์‹œ ์œ„์น˜ ์ •ํ™•๋„ ์œ ์ง€)
539
- if (canvas.width !== CANVAS_WIDTH || canvas.height !== CANVAS_HEIGHT) {
540
- canvas.width = CANVAS_WIDTH;
541
- canvas.height = CANVAS_HEIGHT;
542
- }
543
- });
544
- }
545
-
546
- // ์ดˆ๊ธฐ ์‹คํ–‰
547
- function init() {
548
- fixImageEditorCanvas();
549
- }
550
-
551
- if (document.readyState === 'loading') {
552
- document.addEventListener('DOMContentLoaded', init);
553
- } else {
554
- init();
555
- }
556
-
557
- // ์ด๋ฏธ์ง€ ๋กœ๋“œ ํ›„ ์žฌ์ ์šฉ
558
- window.addEventListener('load', function() {
559
- setTimeout(fixImageEditorCanvas, 100);
560
- setTimeout(fixImageEditorCanvas, 500);
561
- setTimeout(fixImageEditorCanvas, 1500);
562
- });
563
-
564
- // ๋ฆฌ์‚ฌ์ด์ฆˆ ์‹œ ์žฌ์ ์šฉ (๋ชจ๋ฐ”์ผ ํšŒ์ „ ๋“ฑ)
565
- let resizeTimeout;
566
- window.addEventListener('resize', function() {
567
- clearTimeout(resizeTimeout);
568
- resizeTimeout = setTimeout(fixImageEditorCanvas, 300);
569
- });
570
-
571
- // MutationObserver๋กœ ๋™์  ๋ณ€๊ฒฝ ๊ฐ์ง€ (ImageEditor๊ฐ€ ๋™์ ์œผ๋กœ ๋กœ๋“œ๋  ๋•Œ)
572
- const observer = new MutationObserver(function(mutations) {
573
- fixImageEditorCanvas();
574
- });
575
-
576
- // ImageEditor๊ฐ€ ๋กœ๋“œ๋œ ํ›„ observer ์‹œ์ž‘
577
- setTimeout(function() {
578
- const editor = document.querySelector('#image-editor-fixed');
579
- if (editor) {
580
- observer.observe(editor, {
581
- childList: true,
582
- subtree: true,
583
- attributes: false
584
- });
585
- }
586
- }, 1000);
587
- })();
588
- </script>
589
- """)
590
  gr.Markdown("## DXCO : GENAI-VTON")
591
  gr.Markdown("์ž„์„ฑ๋‚จ, ์œค์ง€์˜, ์กฐ๋ฏผ์ฃผ based on IDM-VTON")
592
  gr.Markdown("์ด๋ฏธ์ง€๋Š” 3:4๋น„์œจ(384x512 ๋˜๋Š” 768x1024)๋กœ ์˜ฌ๋ ค์ฃผ์„ธ์š”")
593
  with gr.Row():
594
  with gr.Column():
595
- imgs = gr.ImageEditor(sources='upload', type="pil", label='๋Œ€์ƒ ์ด๋ฏธ์ง€', interactive=True, elem_id="image-editor-fixed")
596
- img_url_input = gr.Textbox(label="๋Œ€์ƒ ์ด๋ฏธ์ง€ URL", placeholder="์˜ˆ) https://example.com/human_image.jpg")
597
  with gr.Row():
598
- with gr.Row():
599
- is_checked = gr.Checkbox(label="Yes", info="์ž๋™ ๋งˆ์Šคํ‚น",value=True)
 
600
  example = gr.Examples(
601
  inputs=imgs,
602
- examples_per_page=8,
603
- examples=human_ex_list,
604
  )
605
 
606
  with gr.Column():
607
  garm_img = gr.Image(label="์˜์ƒ ์ด๋ฏธ์ง€", sources='upload', type="pil")
608
- garm_url_input = gr.Textbox(label="์˜์ƒ ์ด๋ฏธ์ง€ URL", placeholder="์˜ˆ) https://example.com/garment.jpg")
 
609
  with gr.Row(elem_id="prompt-container"):
610
  with gr.Row():
611
  prompt = gr.Textbox(placeholder="Description of garment ex) Short Sleeve Round Neck T-shirts", show_label=False, elem_id="prompt")
 
474
 
475
  image_blocks = gr.Blocks().queue()
476
  with image_blocks as demo:
477
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
478
  gr.Markdown("## DXCO : GENAI-VTON")
479
  gr.Markdown("์ž„์„ฑ๋‚จ, ์œค์ง€์˜, ์กฐ๋ฏผ์ฃผ based on IDM-VTON")
480
  gr.Markdown("์ด๋ฏธ์ง€๋Š” 3:4๋น„์œจ(384x512 ๋˜๋Š” 768x1024)๋กœ ์˜ฌ๋ ค์ฃผ์„ธ์š”")
481
  with gr.Row():
482
  with gr.Column():
483
+ imgs = gr.ImageEditor(sources='upload', type="pil", label='๋Œ€์ƒ ์ด๋ฏธ์ง€', interactive=True)
 
484
  with gr.Row():
485
+ img_url_input = gr.Textbox(label="๋Œ€์ƒ ์ด๋ฏธ์ง€ URL", placeholder="์˜ˆ) https://example.com/human_image.jpg")
486
+ with gr.Row():
487
+ is_checked = gr.Checkbox(label="Yes", info="์ž๋™ ๋งˆ์Šคํ‚น",value=True)
488
  example = gr.Examples(
489
  inputs=imgs,
490
+ examples_per_page=10,
491
+ examples=human_ex_list
492
  )
493
 
494
  with gr.Column():
495
  garm_img = gr.Image(label="์˜์ƒ ์ด๋ฏธ์ง€", sources='upload', type="pil")
496
+ with gr.Row():
497
+ garm_url_input = gr.Textbox(label="์˜์ƒ ์ด๋ฏธ์ง€ URL", placeholder="์˜ˆ) https://example.com/garment.jpg")
498
  with gr.Row(elem_id="prompt-container"):
499
  with gr.Row():
500
  prompt = gr.Textbox(placeholder="Description of garment ex) Short Sleeve Round Neck T-shirts", show_label=False, elem_id="prompt")