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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -20
app.py CHANGED
@@ -293,7 +293,12 @@ def generate_multiple_images(image1, image2, image3, prompt, progress=gr.Progres
293
  return results[0], results[1], results[2], results[3], combined_status, combined_prompts
294
 
295
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค
296
- with gr.Blocks() as demo:
 
 
 
 
 
297
  gr.HTML(
298
  """
299
  <div style="text-align: center; margin-bottom: 1rem;">
@@ -306,33 +311,39 @@ with gr.Blocks() as demo:
306
 
307
  with gr.Row():
308
  with gr.Column():
309
- with gr.Row():
310
- image1_input = gr.Image(type="pil", label="#1", image_mode="RGB", height=256, width=256)
311
- image2_input = gr.Image(type="pil", label="#2", image_mode="RGB", height=256, width=256)
312
- image3_input = gr.Image(type="pil", label="#3", image_mode="RGB", height=256, width=256)
 
 
 
 
313
  prompt_input = gr.Textbox(
314
  lines=3,
315
  placeholder="ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜ ๋น„์›Œ๋‘๋ฉด ์ž๋™ ํ•ฉ์„ฑ๋ฉ๋‹ˆ๋‹ค.",
316
  label="ํ”„๋กฌํ”„ํŠธ (์„ ํƒ ์‚ฌํ•ญ)"
317
  )
318
- with gr.Row():
319
- image_change_btn = gr.Button("์ด๋ฏธ์ง€๋ณ€๊ฒฝ")
320
- text_remove_btn = gr.Button("๊ธ€์ž์ง€์šฐ๊ธฐ")
321
- clothes_change_btn = gr.Button("๊ฐ€์ƒ ์ƒํ’ˆ์ฐฉ์šฉ")
322
- background_change_btn = gr.Button("๋ฐฐ๊ฒฝ๋ฐ”๊พธ๊ธฐ")
323
- composite_product_btn = gr.Button("๋ถ€๋ถ„์ง€์šฐ๊ธฐ")
 
324
  submit_btn = gr.Button("์ด๋ฏธ์ง€ ์ƒ์„ฑ (4์žฅ)", variant="primary")
325
 
326
- with gr.Row():
327
- with gr.Column():
 
328
  output_image1 = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ #1", height=300, width=300)
329
- with gr.Column():
330
  output_image2 = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ #2", height=300, width=300)
331
 
332
- with gr.Row():
333
- with gr.Column():
334
  output_image3 = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ #3", height=300, width=300)
335
- with gr.Column():
336
  output_image4 = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€ #4", height=300, width=300)
337
 
338
  output_text = gr.Textbox(label="์ƒํƒœ ๋ฉ”์‹œ์ง€")
@@ -340,17 +351,17 @@ with gr.Blocks() as demo:
340
 
341
  # ์„ ํƒ ์˜ต์…˜ ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ํ”„๋กฌํ”„ํŠธ ์ž…๋ ฅ๋ž€ ์—…๋ฐ์ดํŠธ (ํ•œ๊ตญ์–ด ๋ฌธ๊ตฌ)
342
  image_change_btn.click(
343
- fn=lambda: "#1 ์ด๋ฏธ์ง€์˜ [๋‹ค๋ฅธ ๋ชจ์Šต]์œผ๋กœ ๋ณ€๊ฒฝํ•˜๋ผ.",
344
  inputs=[],
345
  outputs=prompt_input
346
  )
347
  text_remove_btn.click(
348
- fn=lambda: "#1 ์ด๋ฏธ์ง€์˜ [์ค‘๊ตญ์–ด๋ฅผ ๋ชจ๋‘]๋ฅผ ์ œ๊ฑฐํ•˜๋ผ.",
349
  inputs=[],
350
  outputs=prompt_input
351
  )
352
  clothes_change_btn.click(
353
- fn=lambda: "#1์ด๋ฏธ์ง€์—์„œ [์‹ ์ฒด ๋น„์œจ๊ณผ ํฌ์ฆˆ๋Š” ์œ ์ง€ํ•œ ์ฒด] ์˜์ƒ[์Šคํƒ€์ผ๊ณผ ์ƒ‰์ƒ์„]#2, #3์œผ๋กœ ๋ณ€๊ฒฝํ•ด์ฃผ์„ธ์š”.",
354
  inputs=[],
355
  outputs=prompt_input
356
  )
 
293
  return results[0], results[1], results[2], results[3], combined_status, combined_prompts
294
 
295
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค
296
+ with gr.Blocks(css="""
297
+ .gradio-container {max-width: 650px; margin: 0 auto;}
298
+ .output-image {height: 300px; width: 300px;}
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;">
 
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="์ƒํƒœ ๋ฉ”์‹œ์ง€")
 
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
  )
363
  clothes_change_btn.click(
364
+ fn=lambda: "(#1์˜ ์—ฌ์„ฑ๋ชจ๊ฒ”)์ด ์‹ ์ฒด ๋น„์œก๊ณผ ํฌ์ฆˆ๋Š” ์œ ์น˜ํ•œ ์ฒด (#2์˜ ์„ ๊ธ€๋ผ์Šค)์™€ (#3์˜ ์ฒญ๋ฐ”์ง€)๋ฅผ ์ง์ ‘ ๋ชจ๋ธ์ด ์ฐฉ์šฉํ•œ๊ฒƒ ์ฒ˜๋Ÿผ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•˜๋ผ.",
365
  inputs=[],
366
  outputs=prompt_input
367
  )