Kims12 commited on
Commit
33bb4a3
ยท
verified ยท
1 Parent(s): 14cd815

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -50
app.py CHANGED
@@ -299,64 +299,78 @@ with gr.Blocks(css="""
299
  .input-image {height: 200px; width: 200px;}
300
  .image-row {display: flex; justify-content: center;}
301
  """) as demo:
302
- gr.HTML(
303
- """
304
- <div style="text-align: center; margin-bottom: 1rem;">
305
- <h1>4์žฅ ์ด๋ฏธ์ง€ ์ƒ์„ฑ๊ธฐ (์˜ˆ์ œ ํฌํ•จ)</h1>
306
- <p>์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•˜๊ณ  "์ด๋ฏธ์ง€ ์ƒ์„ฑ" ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด ์ฐจ๋ก€๋กœ 4์žฅ์˜ ์ด๋ฏธ์ง€๊ฐ€ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.</p>
307
- <p>๋ชจ๋“  ์ด๋ฏธ์ง€๋Š” ๊ณ ์ •๋œ ํฌ๊ธฐ๋กœ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.</p>
308
- </div>
309
- """
310
- )
311
-
312
- with gr.Row():
 
 
 
 
 
313
  with gr.Column():
314
- # ์ž…๋ ฅ ์ด๋ฏธ์ง€ UI๋ฅผ ๊ท ํ˜•์žˆ๊ฒŒ ์ •๋ ฌ
315
- with gr.Row(equal_height=True):
316
- with gr.Column(scale=1, min_width=256):
317
- image1_input = gr.Image(type="pil", label="#1", image_mode="RGB", height=256, width=256)
318
- with gr.Column(scale=1, min_width=256):
319
- image2_input = gr.Image(type="pil", label="#2", image_mode="RGB", height=256, width=256)
320
- with gr.Column(scale=1, min_width=256):
321
- image3_input = gr.Image(type="pil", label="#3", image_mode="RGB", height=256, width=256)
322
- prompt_input = gr.Textbox(
323
- lines=3,
324
- placeholder="ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜ ๋น„์›Œ๋‘๋ฉด ์ž๋™ ํ•ฉ์„ฑ๋ฉ๋‹ˆ๋‹ค.",
325
- label="ํ”„๋กฌํ”„ํŠธ (์„ ํƒ ์‚ฌํ•ญ)"
326
- )
327
- # ๋ฒ„ํŠผ ๊ท ๋“ฑ ๋ฐฐ์น˜
328
- with gr.Row(equal_height=True, variant="panel"):
329
- image_change_btn = gr.Button("์ด๋ฏธ์ง€๋ณ€๊ฒฝ", min_width=100, scale=1)
330
- text_remove_btn = gr.Button("๊ธ€์ž์ง€์šฐ๊ธฐ", min_width=100, scale=1)
331
- clothes_change_btn = gr.Button("๊ฐ€์ƒ ์ƒํ’ˆ์ฐฉ์šฉ", min_width=100, scale=1)
332
- background_change_btn = gr.Button("๋ฐฐ๊ฒฝ๋ฐ”๊พธ๊ธฐ", min_width=100, scale=1)
333
- composite_product_btn = gr.Button("๋ถ€๋ถ„์ง€์šฐ๊ธฐ", min_width=100, scale=1)
334
- submit_btn = gr.Button("์ด๋ฏธ์ง€ ์ƒ์„ฑ (4์žฅ)", variant="primary")
335
-
336
- # ์ถœ๋ ฅ ์ด๋ฏธ์ง€ UI๋ฅผ 2x2 ๊ท ํ˜• ๊ทธ๋ฆฌ๋“œ๋กœ ์žฌ๊ตฌ์„ฑ
337
- with gr.Row(equal_height=True):
338
- with gr.Column(scale=1, min_width=300):
339
- output_image1 = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ #1", height=300, width=300)
340
- with gr.Column(scale=1, min_width=300):
341
- output_image2 = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ #2", height=300, width=300)
342
-
343
- with gr.Row(equal_height=True):
344
- with gr.Column(scale=1, min_width=300):
345
- output_image3 = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ #3", height=300, width=300)
346
- with gr.Column(scale=1, min_width=300):
347
- output_image4 = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ #4", height=300, width=300)
348
-
349
- output_text = gr.Textbox(label="์ƒํƒœ ๋ฉ”์‹œ์ง€")
350
- prompt_display = gr.Textbox(label="์‚ฌ์šฉ๋œ ํ”„๋กฌํ”„ํŠธ (์˜์–ด)", visible=True)
 
 
 
 
 
 
 
 
 
351
 
352
  # ์„ ํƒ ์˜ต์…˜ ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ํ”„๋กฌํ”„ํŠธ ์ž…๋ ฅ๋ž€ ์—…๋ฐ์ดํŠธ (ํ•œ๊ตญ์–ด ๋ฌธ๊ตฌ)
353
  image_change_btn.click(
354
- fn=lambda: "(#1์˜ ์—ฌ์„ฑ)์˜ ์ด๋ฏธ์ง€๋ฅผ ์‚ด์ง ๋’ค๋กœ ๋Œ์•„๋ณด๋Š” ๋ชจ์Šต์œผ๋กœ ์ตœ๋Œ€ํ•œ ์ด์ „ seed๋ฅผ ์œ ์ง€ํ•œํ…Œ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋ณ€๊ฒฝํ•˜๋ผ",
355
  inputs=[],
356
  outputs=prompt_input
357
  )
358
  text_remove_btn.click(
359
- fn=lambda: "(#1 ์ด๋ฏธ์ง€)์— ์žˆ๋Š” ์ค‘๊ตญ์–ด๋ฅผ ๋ชจ๋‘ ์ œ๊ฑฐํ•˜๋ผ.",
360
  inputs=[],
361
  outputs=prompt_input
362
  )
 
299
  .input-image {height: 200px; width: 200px;}
300
  .image-row {display: flex; justify-content: center;}
301
  """) as demo:
302
+ # ๋ฉ”์ธ ์ปจํ…Œ์ด๋„ˆ ์‹œ์ž‘
303
+ with gr.Column():
304
+ gr.HTML(
305
+ """
306
+ <div style="text-align: center; margin-bottom: 1rem;">
307
+ <h1 style="margin-bottom: 0.5rem;">4์žฅ ์ด๋ฏธ์ง€ ์ƒ์„ฑ๊ธฐ</h1>
308
+ <p style="margin-bottom: 0.2rem;">์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•˜๊ณ  "์ด๋ฏธ์ง€ ์ƒ์„ฑ" ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด</p>
309
+ <p>์ฐจ๋ก€๋กœ 4์žฅ์˜ ์ด๋ฏธ์ง€๊ฐ€ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.</p>
310
+ </div>
311
+ """
312
+ )
313
+
314
+ # ์ž…๋ ฅ ์„น์…˜
315
+ gr.HTML("<h3 style='text-align: center; margin-top: 1rem; margin-bottom: 0.5rem;'>์ž…๋ ฅ ์ด๋ฏธ์ง€</h3>")
316
+
317
+ # ์ž…๋ ฅ ์ด๋ฏธ์ง€ UI๋ฅผ ์ ์ ˆํ•œ ๊ฐ„๊ฒฉ์œผ๋กœ ์„ธ๋กœ ๋ฐฐ์น˜
318
  with gr.Column():
319
+ with gr.Box():
320
+ image1_input = gr.Image(type="pil", label="#1", image_mode="RGB", height=200, width=200)
321
+ with gr.Box():
322
+ image2_input = gr.Image(type="pil", label="#2", image_mode="RGB", height=200, width=200)
323
+ with gr.Box():
324
+ image3_input = gr.Image(type="pil", label="#3", image_mode="RGB", height=200, width=200)
325
+
326
+ # ํ”„๋กฌํ”„ํŠธ ์ž…๋ ฅ
327
+ prompt_input = gr.Textbox(
328
+ lines=3,
329
+ placeholder="ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜ ๋น„์›Œ๋‘๋ฉด ์ž๋™ ํ•ฉ์„ฑ๋ฉ๋‹ˆ๋‹ค.",
330
+ label="ํ”„๋กฌํ”„ํŠธ (์„ ํƒ ์‚ฌํ•ญ)"
331
+ )
332
+
333
+ # ๋ฒ„ํŠผ ์Šคํƒ€์ผ ๊ฐœ์„ 
334
+ with gr.Column(variant="panel"):
335
+ with gr.Row():
336
+ gr.HTML("<h4 style='margin-bottom: 0.5rem; text-align: center; width: 100%;'>์ž‘์—… ์„ ํƒ</h4>")
337
+ with gr.Column():
338
+ image_change_btn = gr.Button("์ด๋ฏธ์ง€๋ณ€๊ฒฝ", scale=1, size="sm")
339
+ text_remove_btn = gr.Button("๊ธ€์ž์ง€์šฐ๊ธฐ", scale=1, size="sm")
340
+ clothes_change_btn = gr.Button("๊ฐ€์ƒ ์ƒํ’ˆ์ฐฉ์šฉ", scale=1, size="sm")
341
+ background_change_btn = gr.Button("๋ฐฐ๊ฒฝ๋ฐ”๊พธ๊ธฐ", scale=1, size="sm")
342
+ composite_product_btn = gr.Button("๋ถ€๋ถ„์ง€์šฐ๊ธฐ", scale=1, size="sm")
343
+
344
+ # ์ƒ์„ฑ ๋ฒ„ํŠผ์„ ๋” ๋ˆˆ์— ๋„๊ฒŒ ๋งŒ๋“ค๊ธฐ
345
+ with gr.Row(visible=True):
346
+ submit_btn = gr.Button("์ด๋ฏธ์ง€ ์ƒ์„ฑ (4์žฅ)", variant="primary", scale=1, size="lg")
347
+
348
+ # ์ถœ๋ ฅ ์„น์…˜
349
+ gr.HTML("<h3 style='text-align: center; margin-top: 1.5rem; margin-bottom: 0.5rem;'>์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€</h3>")
350
+
351
+ # ์ถœ๋ ฅ ์ด๋ฏธ์ง€ UI๋ฅผ ์„ธ๋กœ๋กœ ๋ฐฐ์น˜
352
+ with gr.Column():
353
+ with gr.Box():
354
+ output_image1 = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ #1", height=300, width=300)
355
+ with gr.Box():
356
+ output_image2 = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ #2", height=300, width=300)
357
+ with gr.Box():
358
+ output_image3 = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ #3", height=300, width=300)
359
+ with gr.Box():
360
+ output_image4 = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ #4", height=300, width=300)
361
+
362
+ # ์ƒํƒœ ๋ฐ ํ”„๋กฌํ”„ํŠธ ์ •๋ณด
363
+ output_text = gr.Textbox(label="์ƒํƒœ ๋ฉ”์‹œ์ง€")
364
+ prompt_display = gr.Textbox(label="์‚ฌ์šฉ๋œ ํ”„๋กฌํ”„ํŠธ (์˜์–ด)", visible=True)
365
 
366
  # ์„ ํƒ ์˜ต์…˜ ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ํ”„๋กฌํ”„ํŠธ ์ž…๋ ฅ๋ž€ ์—…๋ฐ์ดํŠธ (ํ•œ๊ตญ์–ด ๋ฌธ๊ตฌ)
367
  image_change_btn.click(
368
+ fn=lambda: "(#1์˜ ์—ฌ์„ฑ)์˜ ์ด๋ฏธ์ง€๋ฅผ ์‚ด์ง ๋’ค๋กœ ๋Œ์•„๋ณด๋Š” ๋ชจ์Šต์œผ๋กœ ์ตœ๋Œ€ํ•œ ์ด์ „ seed๋ฅผ ์œ ์ง€ํ•œํ…Œ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋ณ€๊ฒฝํ•˜๋ผ.",
369
  inputs=[],
370
  outputs=prompt_input
371
  )
372
  text_remove_btn.click(
373
+ fn=lambda: "(#1 ์ด๋ฏธ์ง€)์— ์žˆ๋Š” ์ค‘๊ตญ์–ด๋ฅผ ๋ชจ๋‘ ์ œ๊ฑฐํ•˜๋ผ.,
374
  inputs=[],
375
  outputs=prompt_input
376
  )