Kims12 commited on
Commit
dcc09a6
ยท
verified ยท
1 Parent(s): 7b8b65a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -13
app.py CHANGED
@@ -491,6 +491,9 @@ def create_app():
491
  with gr.Row():
492
  with gr.Column(scale=1):
493
  product_name = gr.Textbox(label="์ƒํ’ˆ๋ช… (ํ•œ๊ตญ์–ด ์ž…๋ ฅ)", placeholder="์˜ˆ: ์Šคํ‚จ์ผ€์–ด ํŠœ๋ธŒ, ์Šค๋งˆํŠธ์›Œ์น˜, ํ–ฅ์ˆ˜, ์šด๋™ํ™” ๋“ฑ", interactive=True)
 
 
 
494
  background_type = gr.Radio(
495
  choices=["์‹ฌํ”Œ ๋ฐฐ๊ฒฝ", "์ŠคํŠœ๋””์˜ค ๋ฐฐ๊ฒฝ", "์ž์—ฐ ํ™˜๊ฒฝ", "์‹ค๋‚ด ํ™˜๊ฒฝ", "ํ…Œํฌ๋†€๋กœ์ง€ ๋ฐฐ๊ฒฝ", "์ปฌ๋Ÿฌํ’€ ํŒจํ„ด ๋ฐฐ๊ฒฝ", "์ถ”์ƒ/ํŠน์ˆ˜ ๋ฐฐ๊ฒฝ"],
496
  label="๋ฐฐ๊ฒฝ ์œ ํ˜•",
@@ -566,32 +569,45 @@ def create_app():
566
  inputs=[background_type],
567
  outputs=[simple_dropdown, studio_dropdown, nature_dropdown, indoor_dropdown, tech_dropdown, colorful_dropdown, abstract_dropdown]
568
  )
569
- image_input = gr.Image(label="์ƒํ’ˆ ์ด๋ฏธ์ง€ ์—…๋กœ๋“œ", type="pil")
570
  with gr.Row():
571
  single_btn = gr.Button("ํ”„๋กฌํ”„ํŠธ ๋ฐ ๋‹จ์ผ ์ด๋ฏธ์ง€ ์ƒ์„ฑ", variant="primary")
572
  multi_btn = gr.Button("ํ”„๋กฌํ”„ํŠธ ๋ฐ 4์žฅ ์ด๋ฏธ์ง€ ์ƒ์„ฑ", variant="primary")
 
573
  with gr.Column(scale=1):
574
- # ๋‹จ์ผ ์ด๋ฏธ์ง€ ์ถœ๋ ฅ ์˜์—ญ
575
  prompt_output = gr.Textbox(label="์ƒ์„ฑ๋œ ํ”„๋กฌํ”„ํŠธ (์˜์–ด)", lines=6)
576
- image_output = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€", type="filepath")
 
 
 
 
 
 
 
 
 
577
  status_output = gr.Textbox(label="๊ฒฐ๊ณผ ์ •๋ณด", lines=3)
578
- # 4์žฅ ์ด๋ฏธ์ง€ ์ถœ๋ ฅ ์˜์—ญ
579
- image_output1 = gr.Image(label="์ด๋ฏธ์ง€ #1", type="filepath")
580
- image_output2 = gr.Image(label="์ด๋ฏธ์ง€ #2", type="filepath")
581
- image_output3 = gr.Image(label="์ด๋ฏธ์ง€ #3", type="filepath")
582
- image_output4 = gr.Image(label="์ด๋ฏธ์ง€ #4", type="filepath")
583
- status_output_multi = gr.Textbox(label="4์žฅ ์ƒ์„ฑ ๊ฒฐ๊ณผ ์ •๋ณด", lines=3)
584
- prompt_output_multi = gr.Textbox(label="์ƒ์„ฑ๋œ ํ”„๋กฌํ”„ํŠธ (์˜์–ด)", lines=6)
 
585
  single_btn.click(
586
- fn=generate_product_image,
587
  inputs=[image_input, background_type, simple_dropdown, studio_dropdown, nature_dropdown, indoor_dropdown, tech_dropdown, colorful_dropdown, abstract_dropdown, product_name, additional_info],
588
- outputs=[image_output, status_output, prompt_output]
589
  )
 
590
  multi_btn.click(
591
  fn=generate_product_images,
592
  inputs=[image_input, background_type, simple_dropdown, studio_dropdown, nature_dropdown, indoor_dropdown, tech_dropdown, colorful_dropdown, abstract_dropdown, product_name, additional_info],
593
- outputs=[image_output1, image_output2, image_output3, image_output4, status_output_multi, prompt_output_multi]
594
  )
 
595
  return demo
596
 
597
  # ------------------- ๋ฉ”์ธ ์‹คํ–‰ ํ•จ์ˆ˜ -------------------
 
491
  with gr.Row():
492
  with gr.Column(scale=1):
493
  product_name = gr.Textbox(label="์ƒํ’ˆ๋ช… (ํ•œ๊ตญ์–ด ์ž…๋ ฅ)", placeholder="์˜ˆ: ์Šคํ‚จ์ผ€์–ด ํŠœ๋ธŒ, ์Šค๋งˆํŠธ์›Œ์น˜, ํ–ฅ์ˆ˜, ์šด๋™ํ™” ๋“ฑ", interactive=True)
494
+ # ์ƒํ’ˆ ์ด๋ฏธ์ง€ ์—…๋กœ๋“œ๋ฅผ ์ƒํ’ˆ๋ช… ์•„๋ž˜๋กœ ์ด๋™
495
+ image_input = gr.Image(label="์ƒํ’ˆ ์ด๋ฏธ์ง€ ์—…๋กœ๋“œ", type="pil")
496
+
497
  background_type = gr.Radio(
498
  choices=["์‹ฌํ”Œ ๋ฐฐ๊ฒฝ", "์ŠคํŠœ๋””์˜ค ๋ฐฐ๊ฒฝ", "์ž์—ฐ ํ™˜๊ฒฝ", "์‹ค๋‚ด ํ™˜๊ฒฝ", "ํ…Œํฌ๋†€๋กœ์ง€ ๋ฐฐ๊ฒฝ", "์ปฌ๋Ÿฌํ’€ ํŒจํ„ด ๋ฐฐ๊ฒฝ", "์ถ”์ƒ/ํŠน์ˆ˜ ๋ฐฐ๊ฒฝ"],
499
  label="๋ฐฐ๊ฒฝ ์œ ํ˜•",
 
569
  inputs=[background_type],
570
  outputs=[simple_dropdown, studio_dropdown, nature_dropdown, indoor_dropdown, tech_dropdown, colorful_dropdown, abstract_dropdown]
571
  )
572
+
573
  with gr.Row():
574
  single_btn = gr.Button("ํ”„๋กฌํ”„ํŠธ ๋ฐ ๋‹จ์ผ ์ด๋ฏธ์ง€ ์ƒ์„ฑ", variant="primary")
575
  multi_btn = gr.Button("ํ”„๋กฌํ”„ํŠธ ๋ฐ 4์žฅ ์ด๋ฏธ์ง€ ์ƒ์„ฑ", variant="primary")
576
+
577
  with gr.Column(scale=1):
578
+ # ๊ณตํ†ต ํ”„๋กฌํ”„ํŠธ ์ถœ๋ ฅ ์˜์—ญ
579
  prompt_output = gr.Textbox(label="์ƒ์„ฑ๋œ ํ”„๋กฌํ”„ํŠธ (์˜์–ด)", lines=6)
580
+
581
+ # ์ด๋ฏธ์ง€ ๋ ˆ์ด์•„์›ƒ ๋ณ€๊ฒฝ: 2x2 ๊ทธ๋ฆฌ๋“œ๋กœ ๋ฐฐ์น˜
582
+ with gr.Row():
583
+ image_output1 = gr.Image(label="์ด๋ฏธ์ง€ #1", type="filepath")
584
+ image_output2 = gr.Image(label="์ด๋ฏธ์ง€ #2", type="filepath")
585
+
586
+ with gr.Row():
587
+ image_output3 = gr.Image(label="์ด๋ฏธ์ง€ #3", type="filepath")
588
+ image_output4 = gr.Image(label="์ด๋ฏธ์ง€ #4", type="filepath")
589
+
590
  status_output = gr.Textbox(label="๊ฒฐ๊ณผ ์ •๋ณด", lines=3)
591
+
592
+ # ๋‹จ์ผ ์ด๋ฏธ์ง€ ์ƒ์„ฑ ํ•จ์ˆ˜ ์ˆ˜์ •
593
+ def modified_single_image_gen(*args):
594
+ # ๊ธฐ์กด ํ•จ์ˆ˜ ํ˜ธ์ถœ
595
+ result_img, status, prompt = generate_product_image(*args)
596
+ # ๋‹จ์ผ ์ด๋ฏธ์ง€๋ฅผ ์ฒซ ๋ฒˆ์งธ ์ด๋ฏธ์ง€ ์Šฌ๋กฏ์— ๋ฐฐ์น˜ํ•˜๊ณ  ๋‚˜๋จธ์ง€๋Š” None์œผ๋กœ ์„ค์ •
597
+ return prompt, result_img, None, None, None, status
598
+
599
  single_btn.click(
600
+ fn=modified_single_image_gen,
601
  inputs=[image_input, background_type, simple_dropdown, studio_dropdown, nature_dropdown, indoor_dropdown, tech_dropdown, colorful_dropdown, abstract_dropdown, product_name, additional_info],
602
+ outputs=[prompt_output, image_output1, image_output2, image_output3, image_output4, status_output]
603
  )
604
+
605
  multi_btn.click(
606
  fn=generate_product_images,
607
  inputs=[image_input, background_type, simple_dropdown, studio_dropdown, nature_dropdown, indoor_dropdown, tech_dropdown, colorful_dropdown, abstract_dropdown, product_name, additional_info],
608
+ outputs=[image_output1, image_output2, image_output3, image_output4, status_output, prompt_output]
609
  )
610
+
611
  return demo
612
 
613
  # ------------------- ๋ฉ”์ธ ์‹คํ–‰ ํ•จ์ˆ˜ -------------------