Update app.py
Browse files
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 |
-
#
|
319 |
-
|
320 |
-
|
|
|
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๋ฅผ ํตํด ์์ด ํ๋กฌํํธ๋ฅผ ์์ฑํ๊ณ , ๊ทธ ํ๋กฌํํธ๋ก ์ด๋ฏธ์ง๋ฅผ ์์ฑํฉ๋๋ค. ์์ฑ๋ ํ๋กฌํํธ๋ ์ค์ง
|
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)
|