Kims12 commited on
Commit
4557eb9
ยท
verified ยท
1 Parent(s): e52aef4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -313,11 +313,12 @@ def get_selected_background_info(bg_type, simple, studio, nature, indoor, abstra
313
  "english": "white background"
314
  }
315
 
316
- # --- ํ”„๋กฌํ”„ํŠธ์—์„œ ์›ํ•˜๋Š” ๋ถ€๋ถ„(ํ”„๋กฌํ”„ํŠธ ํ…์ŠคํŠธ ๋ธ”๋ก)๋งŒ ์ถ”์ถœํ•˜๋Š” ํ•จ์ˆ˜ ---
317
  def filter_prompt_only(prompt):
318
- # ์˜ˆ์‹œ๋กœ, ์„ค๋ช… ๋ถ€๋ถ„("Explanation of Key Elements:")์ด ์žˆ๋‹ค๋ฉด ๊ทธ ์•ž๋ถ€๋ถ„๋งŒ ์‚ฌ์šฉ
319
- if "Explanation of Key Elements:" in prompt:
320
- return prompt.split("Explanation of Key Elements:")[0].strip()
 
321
  return prompt.strip()
322
 
323
  # ------------------- ํ†ตํ•ฉ ๊ธฐ๋Šฅ: ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ ํ›„ ์ด๋ฏธ์ง€ ์ƒ์„ฑ -------------------
@@ -337,7 +338,7 @@ def generate_product_image(image, bg_type, simple, studio, nature, indoor, abstr
337
  "ํ‚ค ๋ฐœ๊ธ‰: https://makersuite.google.com/"
338
  )
339
  return None, warning_msg, warning_msg
340
- # ์ƒ์„ฑ๋œ ํ”„๋กฌํ”„ํŠธ์—์„œ ์˜ค์ง ํ”„๋กฌํ”„ํŠธ ํ…์ŠคํŠธ ๋ธ”๋ก๋งŒ ์ถ”์ถœ
341
  final_prompt = filter_prompt_only(generated_prompt)
342
  # ์ถ”์ถœ๋œ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์‚ฌ์šฉํ•ด ์ด๋ฏธ์ง€ ์ƒ์„ฑ
343
  result_image, status = process_images_with_prompt(image, final_prompt, 0)[:2]
@@ -347,7 +348,7 @@ def generate_product_image(image, bg_type, simple, studio, nature, indoor, abstr
347
  def create_app():
348
  with gr.Blocks(title="๊ณ ๊ธ‰ ์ƒํ’ˆ ์ด๋ฏธ์ง€ ๋ฐฐ๊ฒฝ ํ”„๋กฌํ”„ํŠธ ๋ฐ ์ด๋ฏธ์ง€ ์ƒ์„ฑ") as demo:
349
  gr.Markdown("# ๊ณ ๊ธ‰ ์ƒํ’ˆ ์ด๋ฏธ์ง€ ๋ฐฐ๊ฒฝ ํ”„๋กฌํ”„ํŠธ ๋ฐ ์ด๋ฏธ์ง€ ์ƒ์„ฑ")
350
- gr.Markdown("์ƒํ’ˆ ์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•˜๊ณ , ์ œํ’ˆ๋ช…, ๋ฐฐ๊ฒฝ ์˜ต์…˜, ์ถ”๊ฐ€ ์š”์ฒญ์‚ฌํ•ญ์„ ์ž…๋ ฅํ•˜๋ฉด Gemini API๋ฅผ ํ†ตํ•ด ์˜์–ด ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ƒ์„ฑํ•˜๊ณ , ๊ทธ ํ”„๋กฌํ”„ํŠธ๋กœ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. ์ƒ์„ฑ๋œ ํ”„๋กฌํ”„ํŠธ๋Š” ์˜ค์ง ์•„๋ž˜์˜ Midjourney ํ”„๋กฌํ”„ํŠธ ํ…์ŠคํŠธ๋งŒ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.")
351
  with gr.Row():
352
  with gr.Column(scale=1):
353
  product_name = gr.Textbox(label="์ƒํ’ˆ๋ช… (ํ•œ๊ตญ์–ด ์ž…๋ ฅ)", placeholder="์˜ˆ: ์Šคํ‚จ์ผ€์–ด ํŠœ๋ธŒ, ํ…€๋ธ”๋Ÿฌ ๋“ฑ", interactive=True)
 
313
  "english": "white background"
314
  }
315
 
316
+ # --- ํ”„๋กฌํ”„ํŠธ์—์„œ ์˜ค์ง Midjourney ํ”„๋กฌํ”„ํŠธ ํ…์ŠคํŠธ๋งŒ ์ถ”์ถœํ•˜๋Š” ํ•จ์ˆ˜ ---
317
  def filter_prompt_only(prompt):
318
+ # "Highly detailed commercial photography" ๋ฌธ์ž์—ด๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋Š” ๋ถ€๋ถ„์„ ๋ฐ˜ํ™˜
319
+ idx = prompt.find("Highly detailed commercial photography")
320
+ if idx != -1:
321
+ return prompt[idx:].strip()
322
  return prompt.strip()
323
 
324
  # ------------------- ํ†ตํ•ฉ ๊ธฐ๋Šฅ: ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ ํ›„ ์ด๋ฏธ์ง€ ์ƒ์„ฑ -------------------
 
338
  "ํ‚ค ๋ฐœ๊ธ‰: https://makersuite.google.com/"
339
  )
340
  return None, warning_msg, warning_msg
341
+ # ์ƒ์„ฑ๋œ ํ”„๋กฌํ”„ํŠธ์—์„œ ์˜ค์ง Midjourney ํ”„๋กฌํ”„ํŠธ ํ…์ŠคํŠธ ๋ธ”๋ก๋งŒ ์ถ”์ถœ
342
  final_prompt = filter_prompt_only(generated_prompt)
343
  # ์ถ”์ถœ๋œ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์‚ฌ์šฉํ•ด ์ด๋ฏธ์ง€ ์ƒ์„ฑ
344
  result_image, status = process_images_with_prompt(image, final_prompt, 0)[:2]
 
348
  def create_app():
349
  with gr.Blocks(title="๊ณ ๊ธ‰ ์ƒํ’ˆ ์ด๋ฏธ์ง€ ๋ฐฐ๊ฒฝ ํ”„๋กฌํ”„ํŠธ ๋ฐ ์ด๋ฏธ์ง€ ์ƒ์„ฑ") as demo:
350
  gr.Markdown("# ๊ณ ๊ธ‰ ์ƒํ’ˆ ์ด๋ฏธ์ง€ ๋ฐฐ๊ฒฝ ํ”„๋กฌํ”„ํŠธ ๋ฐ ์ด๋ฏธ์ง€ ์ƒ์„ฑ")
351
+ gr.Markdown("์ƒํ’ˆ ์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•˜๊ณ , ์ œํ’ˆ๋ช…, ๋ฐฐ๊ฒฝ ์˜ต์…˜, ์ถ”๊ฐ€ ์š”์ฒญ์‚ฌํ•ญ์„ ์ž…๋ ฅํ•˜๋ฉด Gemini API๋ฅผ ํ†ตํ•ด ์˜์–ด ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ƒ์„ฑํ•˜๊ณ , ๊ทธ ํ”„๋กฌํ”„ํŠธ๋กœ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. ์ƒ์„ฑ๋œ ํ”„๋กฌํ”„ํŠธ๋Š” ์˜ค์ง Midjourney ํ”„๋กฌํ”„ํŠธ ํ…์ŠคํŠธ๋งŒ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.")
352
  with gr.Row():
353
  with gr.Column(scale=1):
354
  product_name = gr.Textbox(label="์ƒํ’ˆ๋ช… (ํ•œ๊ตญ์–ด ์ž…๋ ฅ)", placeholder="์˜ˆ: ์Šคํ‚จ์ผ€์–ด ํŠœ๋ธŒ, ํ…€๋ธ”๋Ÿฌ ๋“ฑ", interactive=True)