Update app.py
Browse files
app.py
CHANGED
@@ -224,104 +224,129 @@ def process_images_with_prompt(image1, image2, image3, prompt, bg_options=None):
|
|
224 |
logger.exception("์ด๋ฏธ์ง ์ฒ๋ฆฌ ์ค ์ค๋ฅ ๋ฐ์:")
|
225 |
return None, f"์ค๋ฅ ๋ฐ์: {str(e)}", prompt
|
226 |
|
227 |
-
def
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
|
249 |
# LLM ์คํ์ผ ํ๋กฌํํธ ์์ฑ ํจ์
|
250 |
def generate_llm_prompt(product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood):
|
251 |
# ๊ธฐ๋ณธ ํ๋กฌํํธ ํ
ํ๋ฆฟ
|
252 |
-
prompt = f"{product_name}
|
253 |
|
254 |
# ๋ฐฐ๊ฒฝ ์ ํ ๋ฐ ์คํ์ผ ์ถ๊ฐ
|
255 |
if background_type == "์์ฐ ๋ฐฐ๊ฒฝ":
|
256 |
if background_style == "์ฒ":
|
257 |
-
prompt += "์ธ์ฐฝํ ์ฒ์์ ์์ฐ
|
258 |
elif background_style == "ํด๋ณ":
|
259 |
-
prompt += "์ฒญ๋ํ ํด๋ณ๊ฐ์ ๋ชจ๋
|
260 |
elif background_style == "์ฐ":
|
261 |
-
prompt += "์
์ฅํ ์ฐ์ ์ ์์์ ๋ง์ ํ๋์ ๋ฐฐ๊ฒฝ์ผ๋ก "
|
262 |
elif background_style == "๋คํ":
|
263 |
-
prompt += "๋๊ฒ ํผ์ณ์ง ์ด์
|
264 |
elif background_style == "๊ณ๊ณก":
|
265 |
-
prompt += "์์ํ ๊ณ๊ณก๋ฌผ์ด ํ๋ฅด๋ ๋ฐ์
|
266 |
elif background_style == "์ด๋ ์ ์":
|
267 |
-
prompt += "์๋๊ฐ ๋์น๋ ์ด๋ ์๋ฌผ๋ก ๋๋ฌ์ธ์ธ
|
268 |
elif background_style == "์ฌ๋ง":
|
269 |
-
prompt += "๋์์ด ํผ์ณ์ง ํฉ๊ธ๋น ์ฌ๋ง
|
270 |
elif background_style == "๋ ํ๊ฒฝ":
|
271 |
-
prompt += "ํ์ ๋์ผ๋ก ๋ฎ์ธ ์๋ฐฑ์ ํ๊ฒฝ
|
272 |
else:
|
273 |
-
prompt += f"{background_style} ์์ฐ
|
274 |
elif background_type == "์ค๋ด ๋ฐฐ๊ฒฝ":
|
275 |
if background_style == "๊ฑฐ์ค":
|
276 |
-
prompt += "๋ชจ๋ํ๊ณ ์ธ๋ จ๋ ๊ฑฐ์ค ๊ณต๊ฐ์ ํ
์ด๋ธ
|
277 |
elif background_style == "์ฃผ๋ฐฉ":
|
278 |
-
prompt += "๊น๋ํ ์ฃผ๋ฐฉ ์นด์ดํฐ
|
279 |
elif background_style == "์์ฌ":
|
280 |
-
prompt += "์ง์ ์ธ ๋ถ์๊ธฐ์ ์์ฌ ์ฑ
์
|
281 |
elif background_style == "ํ์ฅ๋":
|
282 |
-
prompt += "์ธ๋ จ๋ ํ์ฅ๋
|
283 |
elif background_style == "ํธํ
๋ก๋น":
|
284 |
-
prompt += "๊ณ ๊ธ์ค๋ฌ์ด ํธํ
๋ก๋น์ ๋๋ฆฌ์ ํ
์ด๋ธ
|
285 |
elif background_style == "์นดํ":
|
286 |
-
prompt += "๊ฐ์ฑ์ ์ธ ์นดํ ํ
์ด๋ธ
|
287 |
elif background_style == "๋ฏธ๋๋ฉ ๊ณต๊ฐ":
|
288 |
-
prompt += "๋ฏธ๋๋ฉํ ๋์์ธ์ ๊น๋ํ
|
289 |
else:
|
290 |
-
prompt += f"{background_style} ์ค๋ด
|
291 |
elif background_type == "ํน์ ๋ฐฐ๊ฒฝ":
|
292 |
if background_style == "๋์ ํ๊ฒฝ":
|
293 |
-
prompt += "ํ๋์ ์ธ ๋์ ์ค์นด์ด๋ผ์ธ์ ๋ฐฐ๊ฒฝ์ผ๋ก "
|
294 |
elif background_style == "๋ฃจํํ":
|
295 |
-
prompt += "๋์ ์ ๊ฒฝ์ด ๋ณด์ด๋ ๋ฃจํํ ํ
์ด๋ธ
|
296 |
elif background_style == "ํด์๊ฐ":
|
297 |
-
prompt += "์๋ฆ๋ค์ด ํด์๊ฐ์ ์ ๋ฒฝ
|
298 |
elif background_style == "๋ชจ๋ ์คํ๋์ค":
|
299 |
-
prompt += "ํ๋กํ์
๋ํ ๋ชจ๋ ์คํ๋์ค
|
300 |
elif background_style == "๋นํฐ์ง ๊ณต๊ฐ":
|
301 |
-
prompt += "ํด๋์ํ ๋ถ์๊ธฐ์ ๋นํฐ์ง
|
302 |
elif background_style == "๋ฏธ๋์ด์ฒ ๊ณต๊ฐ":
|
303 |
-
prompt += "์ ๊ตํ๊ฒ ๊พธ๋ฉฐ์ง ๋ฏธ๋์ด์ฒ ์ธํธ
|
304 |
else:
|
305 |
-
prompt += f"{background_style} ํน์
|
306 |
|
307 |
# ์กฐ๋ช
, ์ง๊ฐ, ์๊ฐ, ๋ถ์๊ธฐ ์ถ๊ฐ
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
if lighting_text:
|
319 |
-
prompt += lighting_text + " "
|
320 |
|
321 |
# ์ง๊ฐ ์ถ๊ฐ
|
322 |
if texture and texture != "์ ํ ์ํจ":
|
323 |
if texture == "ํฐ ๋ฒฝ":
|
324 |
-
prompt += "๊น๋ํ ํฐ ๋ฒฝ์ ๋ฐฐ๊ฒฝ์ผ๋ก "
|
325 |
elif texture == "๋๋ฆฌ์":
|
326 |
prompt += "๊ณ ๊ธ์ค๋ฌ์ด ๋๋ฆฌ์ ์ง๊ฐ ์์ "
|
327 |
elif texture == "๋๋ฌด":
|
@@ -383,64 +408,30 @@ def generate_llm_prompt(product_name, product_category, background_type, backgro
|
|
383 |
|
384 |
return prompt
|
385 |
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
options_summary = f"์ํ๋ช
: {product_name if product_name else '์ง์ ๋์ง ์์'}\n"
|
411 |
-
options_summary += f"์ ํ๊ตฐ: {product_category}\n"
|
412 |
-
options_summary += f"๋ฐฐ๊ฒฝ ์ ํ: {background_type}\n"
|
413 |
-
options_summary += f"์ธ๋ถ ์คํ์ผ: {background_style}\n"
|
414 |
-
|
415 |
-
if lighting:
|
416 |
-
options_summary += f"์กฐ๋ช
: {lighting}\n"
|
417 |
-
if texture and texture != "์ ํ ์ํจ":
|
418 |
-
options_summary += f"๋ฐฐ๊ฒฝ ์ง๊ฐ: {texture}\n"
|
419 |
-
if color_tone and color_tone != "์ ํ ์ํจ":
|
420 |
-
options_summary += f"์๊ฐ: {color_tone}\n"
|
421 |
-
if mood and mood != "์ ํ ์ํจ":
|
422 |
-
options_summary += f"๋ถ์๊ธฐ: {mood}\n"
|
423 |
-
|
424 |
-
# ํ๊ตญ์ด์ ์์ด ํ๋กฌํํธ ๋น๊ต๋ฅผ ์ํด ์๋ณธ ํ๋กฌํํธ ํ์ธ
|
425 |
-
kr_prompt = preprocess_prompt(prompt, image1, image2, image3, bg_options)
|
426 |
-
|
427 |
-
return result_img, status, final_prompt, options_summary, kr_prompt
|
428 |
-
except Exception as e:
|
429 |
-
logger.exception("์ฒ๋ฆฌ ์ค ์ค๋ฅ ๋ฐ์:")
|
430 |
-
return None, f"์ค๋ฅ ๋ฐ์: {str(e)}", prompt, "", ""
|
431 |
-
|
432 |
-
# ์ ํ ์ต์
ํ์/์จ๊น ์ฒ๋ฆฌ ํจ์
|
433 |
-
def toggle_background_options(selection):
|
434 |
-
if selection == "๋ฐฐ๊ฒฝ๋ฐ๊พธ๊ธฐ":
|
435 |
-
return (gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
|
436 |
-
gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
|
437 |
-
gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
|
438 |
-
gr.update(visible=True))
|
439 |
-
else:
|
440 |
-
return (gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
|
441 |
-
gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
|
442 |
-
gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
|
443 |
-
gr.update(visible=False))
|
444 |
|
445 |
# ๋ฐฐ๊ฒฝ ์ ํ์ ๋ฐ๋ฅธ ์ธ๋ถ ์คํ์ผ ์ต์
์
๋ฐ์ดํธ
|
446 |
def update_background_style_options(background_type):
|
@@ -453,7 +444,6 @@ def update_background_style_options(background_type):
|
|
453 |
else:
|
454 |
return gr.update(choices=["์ ํํ์ธ์"], value="์ ํํ์ธ์")
|
455 |
|
456 |
-
|
457 |
# Gradio ์ธํฐํ์ด์ค
|
458 |
with gr.Blocks() as demo:
|
459 |
gr.HTML(
|
@@ -565,20 +555,18 @@ with gr.Blocks() as demo:
|
|
565 |
visible=False
|
566 |
)
|
567 |
|
568 |
-
#
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
|
575 |
-
submit_btn = gr.Button("์ด๋ฏธ์ง ์์ฑ", variant="primary")
|
576 |
-
|
577 |
with gr.Column(scale=1):
|
578 |
output_image = gr.Image(label="์์ฑ๋ ์ด๋ฏธ์ง")
|
579 |
output_text = gr.Textbox(label="์ํ ๋ฉ์์ง")
|
580 |
-
|
581 |
-
|
582 |
options_summary = gr.Textbox(label="์ ํ๋ ์ต์
์์ฝ", lines=8, visible=True)
|
583 |
|
584 |
# ๋ฐฐ๊ฒฝ ๋ณ๊ฒฝ ๋ฒํผ ํด๋ฆญ ์ด๋ฒคํธ๋ฅผ ๋ ๊ฐ๋จํ๊ฒ ์์
|
@@ -587,14 +575,14 @@ with gr.Blocks() as demo:
|
|
587 |
gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
|
588 |
gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
|
589 |
gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
|
590 |
-
gr.update(visible=True), "",
|
591 |
|
592 |
background_change_btn.click(
|
593 |
fn=show_background_options,
|
594 |
inputs=[],
|
595 |
outputs=[prompt_input, current_selection, background_header, product_name, product_category,
|
596 |
background_type, background_style, additional_header, lighting, texture,
|
597 |
-
color_tone, mood, selection_preview,
|
598 |
)
|
599 |
|
600 |
# ๋ค๋ฅธ ๊ธฐ๋ฅ ๋ฒํผ๋ค๋ ๊ฐ๋จํ ๋ฐฉ์์ผ๋ก ์์
|
@@ -603,14 +591,14 @@ with gr.Blocks() as demo:
|
|
603 |
gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
|
604 |
gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
|
605 |
gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
|
606 |
-
gr.update(visible=False), "",
|
607 |
|
608 |
image_change_btn.click(
|
609 |
fn=lambda: hide_background_options("#1 ์ด๋ฏธ์ง์ [๋ค๋ฅธ ๋ชจ์ต]์ผ๋ก ๋ณ๊ฒฝํ๋ผ."),
|
610 |
inputs=[],
|
611 |
outputs=[prompt_input, current_selection, background_header, product_name, product_category,
|
612 |
background_type, background_style, additional_header, lighting, texture,
|
613 |
-
color_tone, mood, selection_preview,
|
614 |
)
|
615 |
|
616 |
text_remove_btn.click(
|
@@ -618,7 +606,7 @@ with gr.Blocks() as demo:
|
|
618 |
inputs=[],
|
619 |
outputs=[prompt_input, current_selection, background_header, product_name, product_category,
|
620 |
background_type, background_style, additional_header, lighting, texture,
|
621 |
-
color_tone, mood, selection_preview,
|
622 |
)
|
623 |
|
624 |
clothes_change_btn.click(
|
@@ -626,7 +614,7 @@ with gr.Blocks() as demo:
|
|
626 |
inputs=[],
|
627 |
outputs=[prompt_input, current_selection, background_header, product_name, product_category,
|
628 |
background_type, background_style, additional_header, lighting, texture,
|
629 |
-
color_tone, mood, selection_preview,
|
630 |
)
|
631 |
|
632 |
composite_product_btn.click(
|
@@ -634,13 +622,30 @@ with gr.Blocks() as demo:
|
|
634 |
inputs=[],
|
635 |
outputs=[prompt_input, current_selection, background_header, product_name, product_category,
|
636 |
background_type, background_style, additional_header, lighting, texture,
|
637 |
-
color_tone, mood, selection_preview,
|
638 |
)
|
639 |
|
640 |
# ์ ํ ์ต์
๋ณ๊ฒฝ ์ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์ LLM ํ๋กฌํํธ ์
๋ฐ์ดํธ
|
641 |
def update_all_previews(product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood):
|
642 |
-
|
643 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
644 |
|
645 |
# ๋ฐฐ๊ฒฝ ์ ํ์ ๋ฐ๋ผ ์ธ๋ถ ์คํ์ผ ์ต์
์
๋ฐ์ดํธ (๋จผ์ ์ํ)
|
646 |
background_type.change(
|
@@ -650,53 +655,65 @@ with gr.Blocks() as demo:
|
|
650 |
).then(
|
651 |
fn=update_all_previews,
|
652 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
653 |
-
outputs=[selection_preview
|
654 |
)
|
655 |
|
656 |
# ๋ชจ๋ ์ ํ ์ปดํฌ๋ํธ์ ๋ณ๊ฒฝ ์ด๋ฒคํธ์ ์ฐ๊ฒฐ
|
657 |
product_name.change(
|
658 |
fn=update_all_previews,
|
659 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
660 |
-
outputs=[selection_preview
|
661 |
)
|
|
|
662 |
product_category.change(
|
663 |
fn=update_all_previews,
|
664 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
665 |
-
outputs=[selection_preview
|
666 |
)
|
|
|
667 |
background_style.change(
|
668 |
fn=update_all_previews,
|
669 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
670 |
-
outputs=[selection_preview
|
671 |
)
|
|
|
672 |
lighting.change(
|
673 |
fn=update_all_previews,
|
674 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
675 |
-
outputs=[selection_preview
|
676 |
)
|
|
|
677 |
texture.change(
|
678 |
fn=update_all_previews,
|
679 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
680 |
-
outputs=[selection_preview
|
681 |
)
|
|
|
682 |
color_tone.change(
|
683 |
fn=update_all_previews,
|
684 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
685 |
-
outputs=[selection_preview
|
686 |
)
|
|
|
687 |
mood.change(
|
688 |
fn=update_all_previews,
|
689 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
690 |
-
outputs=[selection_preview
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
691 |
)
|
692 |
|
693 |
-
# ์ด๋ฏธ์ง ์์ฑ ๋ฒํผ ํด๋ฆญ ์ด๋ฒคํธ
|
694 |
submit_btn.click(
|
695 |
-
fn=
|
696 |
-
inputs=[image1_input, image2_input, image3_input, prompt_input,
|
697 |
-
|
698 |
-
lighting, texture, color_tone, mood, llm_prompt_input],
|
699 |
-
outputs=[output_image, output_text, prompt_display, options_summary, kr_prompt_display],
|
700 |
)
|
701 |
|
702 |
gr.Markdown(
|
@@ -707,10 +724,11 @@ with gr.Blocks() as demo:
|
|
707 |
2. "๋ฐฐ๊ฒฝ๋ฐ๊พธ๊ธฐ" ๋ฒํผ์ ํด๋ฆญํ๋ฉด ๋ฐฐ๊ฒฝ ๋ณ๊ฒฝ ์ต์
์ด ๋ํ๋ฉ๋๋ค.
|
708 |
3. ์ํ๋ช
์ ์
๋ ฅํ๊ณ ์ ํ๊ตฐ, ๋ฐฐ๊ฒฝ ์ ํ, ๋ฐฐ๊ฒฝ ์ธ๋ถ ์คํ์ผ์ ์ ํํ์ธ์.
|
709 |
4. ์ถ๊ฐ ์ต์
(์กฐ๋ช
, ์ง๊ฐ, ์๊ฐ, ๋ถ์๊ธฐ)์ ์ ํํ๋ฉด ๋ ์ธ๋ฐํ ๋ฐฐ๊ฒฝ์ ์์ฑํ ์ ์์ต๋๋ค.
|
710 |
-
5. "
|
711 |
-
6.
|
|
|
712 |
|
713 |
-
> **ํ**: ์ ํ ๋ด์ฉ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์์
|
714 |
"""
|
715 |
)
|
716 |
|
|
|
224 |
logger.exception("์ด๋ฏธ์ง ์ฒ๋ฆฌ ์ค ์ค๋ฅ ๋ฐ์:")
|
225 |
return None, f"์ค๋ฅ ๋ฐ์: {str(e)}", prompt
|
226 |
|
227 |
+
def ask_llm_for_final_prompt(kr_prompt):
|
228 |
+
"""
|
229 |
+
LLM์ 2์ฐจ ์ง๋ฌธํ์ฌ ๋ ์์ฐ์ค๋ฌ์ด ์ด๋ฏธ์ง ์์ฑ ํ๋กฌํํธ๋ฅผ ์ป๋ ํจ์
|
230 |
+
์ค์ ๊ตฌํ์์๋ LLM API๋ฅผ ํธ์ถํด์ผ ํจ
|
231 |
+
"""
|
232 |
+
try:
|
233 |
+
api_key = os.environ.get("GEMINI_API_KEY")
|
234 |
+
if not api_key:
|
235 |
+
logger.error("Gemini API ํค๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค.")
|
236 |
+
return f"AI ์ด๋ฏธ์ง ์์ฑ ํ๋กฌํํธ: {kr_prompt}"
|
237 |
+
|
238 |
+
client = genai.Client(api_key=api_key)
|
239 |
+
|
240 |
+
llm_prompt = f"""
|
241 |
+
๋ค์์ ์ด์ปค๋จธ์ค ์ํ ์ด๋ฏธ์ง ๋ฐฐ๊ฒฝ ๋ณ๊ฒฝ์ ์ํ ํ๋กฌํํธ์
๋๋ค. ์ด ํ๋กฌํํธ๋ฅผ ๋ ์์ฐ์ค๋ฝ๊ณ ๋งค๋ ฅ์ ์ธ ์ด๋ฏธ์ง ์์ฑ ํ๋กฌํํธ๋ก
|
242 |
+
๋ค์ ์์ฑํด์ฃผ์ธ์. ๋จ, ์๋ณธ ์ด๋ฏธ์ง์ ์ ํ ํน์ฑ์ ์ ์งํด์ผ ํ๋ค๋ ์ ๊ณผ ๋ฐฐ๊ฒฝ๋ง ๋ณ๊ฒฝํด์ผ ํ๋ค๋ ์ ์ ๋ฐ๋์ ํฌํจํด์ผ ํฉ๋๋ค.
|
243 |
+
|
244 |
+
์๋ณธ ํ๋กฌํํธ:
|
245 |
+
{kr_prompt}
|
246 |
+
|
247 |
+
๊ฒฐ๊ณผ๋ฌผ์ AI ์ด๋ฏธ์ง ์์ฑ์ ์ต์ ํ๋ ํ๋กฌํํธ์ฌ์ผ ํฉ๋๋ค. ๊ฒฐ๊ณผ๋ฌผ๋ง ์ ๊ณตํ๊ณ ์ค๋ช
์ด๋ ์ถ๊ฐ ํ
์คํธ ์์ด ํ๋กฌํํธ ์์ฒด๋ง ์ถ๋ ฅํด์ฃผ์ธ์.
|
248 |
+
"""
|
249 |
+
|
250 |
+
response = client.models.generate_content(
|
251 |
+
model="gemini-2.0-flash",
|
252 |
+
contents=[llm_prompt],
|
253 |
+
config=types.GenerateContentConfig(
|
254 |
+
response_modalities=['Text'],
|
255 |
+
temperature=0.7,
|
256 |
+
top_p=0.95,
|
257 |
+
top_k=40,
|
258 |
+
max_output_tokens=512
|
259 |
+
)
|
260 |
+
)
|
261 |
+
|
262 |
+
final_prompt = ""
|
263 |
+
for part in response.candidates[0].content.parts:
|
264 |
+
if hasattr(part, 'text') and part.text:
|
265 |
+
final_prompt += part.text
|
266 |
+
|
267 |
+
if final_prompt.strip():
|
268 |
+
logger.info(f"LLM 2์ฐจ ํ๋กฌํํธ ์์ฑ ๊ฒฐ๊ณผ: {final_prompt.strip()}")
|
269 |
+
return final_prompt.strip()
|
270 |
+
else:
|
271 |
+
logger.warning("LLM 2์ฐจ ํ๋กฌํํธ ์์ฑ ๊ฒฐ๊ณผ๊ฐ ์์ต๋๋ค. ์๋ณธ ํ๋กฌํํธ ์ฌ์ฉ")
|
272 |
+
return f"AI ์ด๋ฏธ์ง ์์ฑ ํ๋กฌํํธ: {kr_prompt}"
|
273 |
+
except Exception as e:
|
274 |
+
logger.exception("LLM 2์ฐจ ํ๋กฌํํธ ์์ฑ ์ค ์ค๋ฅ ๋ฐ์:")
|
275 |
+
return f"AI ์ด๋ฏธ์ง ์์ฑ ํ๋กฌํํธ: {kr_prompt}"
|
276 |
|
277 |
# LLM ์คํ์ผ ํ๋กฌํํธ ์์ฑ ํจ์
|
278 |
def generate_llm_prompt(product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood):
|
279 |
# ๊ธฐ๋ณธ ํ๋กฌํํธ ํ
ํ๋ฆฟ
|
280 |
+
prompt = f"#1 ์๋ณธ ์ด๋ฏธ์ง์ {product_name} ์ ํ์ 100% ๋์ผํ๊ฒ ์ ์งํ๋ฉด์ ๋ฐฐ๊ฒฝ๋ง "
|
281 |
|
282 |
# ๋ฐฐ๊ฒฝ ์ ํ ๋ฐ ์คํ์ผ ์ถ๊ฐ
|
283 |
if background_type == "์์ฐ ๋ฐฐ๊ฒฝ":
|
284 |
if background_style == "์ฒ":
|
285 |
+
prompt += "์ธ์ฐฝํ ์ฒ์์ ์์ฐ ํ๊ฒฝ์ผ๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
286 |
elif background_style == "ํด๋ณ":
|
287 |
+
prompt += "์ฒญ๋ํ ํด๋ณ๊ฐ์ ๋ชจ๋ ์๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
288 |
elif background_style == "์ฐ":
|
289 |
+
prompt += "์
์ฅํ ์ฐ์ ์ ์์์ ๋ง์ ํ๋์ ๋ฐฐ๊ฒฝ์ผ๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
290 |
elif background_style == "๋คํ":
|
291 |
+
prompt += "๋๊ฒ ํผ์ณ์ง ์ด์ ์๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
292 |
elif background_style == "๊ณ๊ณก":
|
293 |
+
prompt += "์์ํ ๊ณ๊ณก๋ฌผ์ด ํ๋ฅด๋ ๋ฐ์ ์๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
294 |
elif background_style == "์ด๋ ์ ์":
|
295 |
+
prompt += "์๋๊ฐ ๋์น๋ ์ด๋ ์๋ฌผ๋ก ๋๋ฌ์ธ์ธ ๊ณต๊ฐ์ผ๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
296 |
elif background_style == "์ฌ๋ง":
|
297 |
+
prompt += "๋์์ด ํผ์ณ์ง ํฉ๊ธ๋น ์ฌ๋ง ์๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
298 |
elif background_style == "๋ ํ๊ฒฝ":
|
299 |
+
prompt += "ํ์ ๋์ผ๋ก ๋ฎ์ธ ์๋ฐฑ์ ํ๊ฒฝ ์๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
300 |
else:
|
301 |
+
prompt += f"{background_style} ์์ฐ ํ๊ฒฝ์ผ๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
302 |
elif background_type == "์ค๋ด ๋ฐฐ๊ฒฝ":
|
303 |
if background_style == "๊ฑฐ์ค":
|
304 |
+
prompt += "๋ชจ๋ํ๊ณ ์ธ๋ จ๋ ๊ฑฐ์ค ๊ณต๊ฐ์ ํ
์ด๋ธ ์๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
305 |
elif background_style == "์ฃผ๋ฐฉ":
|
306 |
+
prompt += "๊น๋ํ ์ฃผ๋ฐฉ ์นด์ดํฐ ์๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
307 |
elif background_style == "์์ฌ":
|
308 |
+
prompt += "์ง์ ์ธ ๋ถ์๊ธฐ์ ์์ฌ ์ฑ
์ ์๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
309 |
elif background_style == "ํ์ฅ๋":
|
310 |
+
prompt += "์ธ๋ จ๋ ํ์ฅ๋ ์๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
311 |
elif background_style == "ํธํ
๋ก๋น":
|
312 |
+
prompt += "๊ณ ๊ธ์ค๋ฌ์ด ํธํ
๋ก๋น์ ๋๋ฆฌ์ ํ
์ด๋ธ ์๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
313 |
elif background_style == "์นดํ":
|
314 |
+
prompt += "๊ฐ์ฑ์ ์ธ ์นดํ ํ
์ด๋ธ ์๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
315 |
elif background_style == "๋ฏธ๋๋ฉ ๊ณต๊ฐ":
|
316 |
+
prompt += "๋ฏธ๋๋ฉํ ๋์์ธ์ ๊น๋ํ ๊ณต๊ฐ์ผ๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
317 |
else:
|
318 |
+
prompt += f"{background_style} ์ค๋ด ๊ณต๊ฐ์ผ๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
319 |
elif background_type == "ํน์ ๋ฐฐ๊ฒฝ":
|
320 |
if background_style == "๋์ ํ๊ฒฝ":
|
321 |
+
prompt += "ํ๋์ ์ธ ๋์ ์ค์นด์ด๋ผ์ธ์ ๋ฐฐ๊ฒฝ์ผ๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
322 |
elif background_style == "๋ฃจํํ":
|
323 |
+
prompt += "๋์ ์ ๊ฒฝ์ด ๋ณด์ด๋ ๋ฃจํํ ํ
์ด๋ธ ์๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
324 |
elif background_style == "ํด์๊ฐ":
|
325 |
+
prompt += "์๋ฆ๋ค์ด ํด์๊ฐ์ ์ ๋ฒฝ ์๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
326 |
elif background_style == "๋ชจ๋ ์คํ๋์ค":
|
327 |
+
prompt += "ํ๋กํ์
๋ํ ๋ชจ๋ ์คํ๋์ค ์ธํธ๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
328 |
elif background_style == "๋นํฐ์ง ๊ณต๊ฐ":
|
329 |
+
prompt += "ํด๋์ํ ๋ถ์๊ธฐ์ ๋นํฐ์ง ๊ณต๊ฐ์ผ๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
330 |
elif background_style == "๋ฏธ๋์ด์ฒ ๊ณต๊ฐ":
|
331 |
+
prompt += "์ ๊ตํ๊ฒ ๊พธ๋ฉฐ์ง ๋ฏธ๋์ด์ฒ ์ธํธ ์๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
332 |
else:
|
333 |
+
prompt += f"{background_style} ํน์ ํ๊ฒฝ์ผ๋ก ์์ฐ์ค๋ฝ๊ฒ ๋ณ๊ฒฝํด์ฃผ์ธ์. "
|
334 |
|
335 |
# ์กฐ๋ช
, ์ง๊ฐ, ์๊ฐ, ๋ถ์๊ธฐ ์ถ๊ฐ
|
336 |
+
if lighting:
|
337 |
+
if lighting == "์์ฐ๊ด":
|
338 |
+
prompt += "๋ถ๋๋ฌ์ด ์์ฐ๊ด์ด ๋น์น๋ ํ๊ฒฝ์์ "
|
339 |
+
elif lighting == "๋ฐ๋ปํ ์กฐ๋ช
":
|
340 |
+
prompt += "๋ฐ๋ปํ ๏ฟฝ๏ฟฝ๊ธ๋น ์กฐ๋ช
์ด ๊ฐ์ธ๋ ํ๊ฒฝ์์ "
|
341 |
+
elif lighting == "๊ทธ๋ฆผ์ ์๋ ์กฐ๋ช
":
|
342 |
+
prompt += "๋๋ผ๋งํฑํ ๊ทธ๋ฆผ์๋ฅผ ๋ง๋๋ ์กฐ๋ช
์๋์์ "
|
343 |
+
elif lighting == "๋ฏธ๋๋ฉ ์กฐ๋ช
":
|
344 |
+
prompt += "๊น๋ํ๊ณ ๋ฏธ๋๋ฉํ ์กฐ๋ช
์๋์์ "
|
|
|
|
|
|
|
345 |
|
346 |
# ์ง๊ฐ ์ถ๊ฐ
|
347 |
if texture and texture != "์ ํ ์ํจ":
|
348 |
if texture == "ํฐ ๋ฒฝ":
|
349 |
+
prompt += "๊น๋ํ ํฐ ๋ฒฝ์ ๋ฐฐ๊ฒฝ์ผ๋ก ํ์ฌ "
|
350 |
elif texture == "๋๋ฆฌ์":
|
351 |
prompt += "๊ณ ๊ธ์ค๋ฌ์ด ๋๋ฆฌ์ ์ง๊ฐ ์์ "
|
352 |
elif texture == "๋๋ฌด":
|
|
|
408 |
|
409 |
return prompt
|
410 |
|
411 |
+
# ํ๋กฌํํธ ์์ฑ ๋ฐ LLM์ 2์ฐจ ์ง๋ฌธ ํจ์
|
412 |
+
def generate_prompt_and_ask_llm(product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood):
|
413 |
+
# 1์ฐจ ํ๋กฌํํธ ์์ฑ
|
414 |
+
kr_prompt = generate_llm_prompt(product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood)
|
415 |
+
|
416 |
+
# LLM์ 2์ฐจ ์ง๋ฌธํ์ฌ ์ต์ข
ํ๋กฌํํธ ์์ฑ
|
417 |
+
final_prompt = ask_llm_for_final_prompt(kr_prompt)
|
418 |
+
|
419 |
+
# ์ ํ ์ต์
์์ฝ
|
420 |
+
options_summary = f"์ํ๋ช
: {product_name if product_name else '์ง์ ๋์ง ์์'}\n"
|
421 |
+
options_summary += f"์ ํ๊ตฐ: {product_category}\n"
|
422 |
+
options_summary += f"๋ฐฐ๊ฒฝ ์ ํ: {background_type}\n"
|
423 |
+
options_summary += f"์ธ๋ถ ์คํ์ผ: {background_style}\n"
|
424 |
+
|
425 |
+
if lighting:
|
426 |
+
options_summary += f"์กฐ๋ช
: {lighting}\n"
|
427 |
+
if texture and texture != "์ ํ ์ํจ":
|
428 |
+
options_summary += f"๋ฐฐ๊ฒฝ ์ง๊ฐ: {texture}\n"
|
429 |
+
if color_tone and color_tone != "์ ํ ์ํจ":
|
430 |
+
options_summary += f"์๊ฐ: {color_tone}\n"
|
431 |
+
if mood and mood != "์ ํ ์ํจ":
|
432 |
+
options_summary += f"๋ถ์๊ธฐ: {mood}\n"
|
433 |
+
|
434 |
+
return kr_prompt, final_prompt, options_summary
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
435 |
|
436 |
# ๋ฐฐ๊ฒฝ ์ ํ์ ๋ฐ๋ฅธ ์ธ๋ถ ์คํ์ผ ์ต์
์
๋ฐ์ดํธ
|
437 |
def update_background_style_options(background_type):
|
|
|
444 |
else:
|
445 |
return gr.update(choices=["์ ํํ์ธ์"], value="์ ํํ์ธ์")
|
446 |
|
|
|
447 |
# Gradio ์ธํฐํ์ด์ค
|
448 |
with gr.Blocks() as demo:
|
449 |
gr.HTML(
|
|
|
555 |
visible=False
|
556 |
)
|
557 |
|
558 |
+
# ๋ฒํผ๋ค์ ๊ทธ๋ฃนํ
|
559 |
+
with gr.Row(visible=False) as buttons_row:
|
560 |
+
# ํ๋กฌํํธ ์์ฑ ๋ฒํผ ์ถ๊ฐ
|
561 |
+
prompt_generate_btn = gr.Button("ํ๋กฌํํธ ์์ฑ", variant="secondary")
|
562 |
+
# ์ด๋ฏธ์ง ์์ฑ ๋ฒํผ
|
563 |
+
submit_btn = gr.Button("์ด๋ฏธ์ง ์์ฑ", variant="primary")
|
564 |
|
|
|
|
|
565 |
with gr.Column(scale=1):
|
566 |
output_image = gr.Image(label="์์ฑ๋ ์ด๋ฏธ์ง")
|
567 |
output_text = gr.Textbox(label="์ํ ๋ฉ์์ง")
|
568 |
+
kr_prompt_display = gr.Textbox(label="์ฌ์ฉ๋ ํ๋กฌํํธ (ํ๊ตญ์ด)", visible=True, lines=4)
|
569 |
+
prompt_display = gr.Textbox(label="์ฌ์ฉ๋ ํ๋กฌํํธ (์์ด)", visible=True, lines=4)
|
570 |
options_summary = gr.Textbox(label="์ ํ๋ ์ต์
์์ฝ", lines=8, visible=True)
|
571 |
|
572 |
# ๋ฐฐ๊ฒฝ ๋ณ๊ฒฝ ๋ฒํผ ํด๋ฆญ ์ด๋ฒคํธ๋ฅผ ๋ ๊ฐ๋จํ๊ฒ ์์
|
|
|
575 |
gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
|
576 |
gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
|
577 |
gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
|
578 |
+
gr.update(visible=True), "", gr.update(visible=True)) # ๋ฒํผ ๊ทธ๋ฃน ํ์ ์ถ๊ฐ
|
579 |
|
580 |
background_change_btn.click(
|
581 |
fn=show_background_options,
|
582 |
inputs=[],
|
583 |
outputs=[prompt_input, current_selection, background_header, product_name, product_category,
|
584 |
background_type, background_style, additional_header, lighting, texture,
|
585 |
+
color_tone, mood, selection_preview, buttons_row]
|
586 |
)
|
587 |
|
588 |
# ๋ค๋ฅธ ๊ธฐ๋ฅ ๋ฒํผ๋ค๋ ๊ฐ๋จํ ๋ฐฉ์์ผ๋ก ์์
|
|
|
591 |
gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
|
592 |
gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
|
593 |
gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
|
594 |
+
gr.update(visible=False), "", gr.update(visible=False)) # ๋ฒํผ ๊ทธ๋ฃน ์จ๊น ์ถ๊ฐ
|
595 |
|
596 |
image_change_btn.click(
|
597 |
fn=lambda: hide_background_options("#1 ์ด๋ฏธ์ง์ [๋ค๋ฅธ ๋ชจ์ต]์ผ๋ก ๋ณ๊ฒฝํ๋ผ."),
|
598 |
inputs=[],
|
599 |
outputs=[prompt_input, current_selection, background_header, product_name, product_category,
|
600 |
background_type, background_style, additional_header, lighting, texture,
|
601 |
+
color_tone, mood, selection_preview, buttons_row]
|
602 |
)
|
603 |
|
604 |
text_remove_btn.click(
|
|
|
606 |
inputs=[],
|
607 |
outputs=[prompt_input, current_selection, background_header, product_name, product_category,
|
608 |
background_type, background_style, additional_header, lighting, texture,
|
609 |
+
color_tone, mood, selection_preview, buttons_row]
|
610 |
)
|
611 |
|
612 |
clothes_change_btn.click(
|
|
|
614 |
inputs=[],
|
615 |
outputs=[prompt_input, current_selection, background_header, product_name, product_category,
|
616 |
background_type, background_style, additional_header, lighting, texture,
|
617 |
+
color_tone, mood, selection_preview, buttons_row]
|
618 |
)
|
619 |
|
620 |
composite_product_btn.click(
|
|
|
622 |
inputs=[],
|
623 |
outputs=[prompt_input, current_selection, background_header, product_name, product_category,
|
624 |
background_type, background_style, additional_header, lighting, texture,
|
625 |
+
color_tone, mood, selection_preview, buttons_row]
|
626 |
)
|
627 |
|
628 |
# ์ ํ ์ต์
๋ณ๊ฒฝ ์ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์ LLM ํ๋กฌํํธ ์
๋ฐ์ดํธ
|
629 |
def update_all_previews(product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood):
|
630 |
+
llm_prompt = generate_llm_prompt(product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood)
|
631 |
+
|
632 |
+
preview = f"์ํ๋ช
: {product_name}\n"
|
633 |
+
preview += f"์ ํ๊ตฐ: {product_category}\n"
|
634 |
+
preview += f"๋ฐฐ๊ฒฝ ์ ํ: {background_type}\n"
|
635 |
+
preview += f"์ธ๋ถ ์คํ์ผ: {background_style}\n"
|
636 |
+
|
637 |
+
if lighting:
|
638 |
+
preview += f"์กฐ๋ช
: {lighting}\n"
|
639 |
+
if texture and texture != "์ ํ ์ํจ":
|
640 |
+
preview += f"๋ฐฐ๊ฒฝ ์ง๊ฐ: {texture}\n"
|
641 |
+
if color_tone and color_tone != "์ ํ ์ํจ":
|
642 |
+
preview += f"์๊ฐ: {color_tone}\n"
|
643 |
+
if mood and mood != "์ ํ ์ํจ":
|
644 |
+
preview += f"๋ถ์๊ธฐ: {mood}\n"
|
645 |
+
|
646 |
+
preview += f"\n์์ฑ๋ ํ๋กฌํํธ ๋ฏธ๋ฆฌ๋ณด๊ธฐ:\n{llm_prompt}"
|
647 |
+
|
648 |
+
return preview
|
649 |
|
650 |
# ๋ฐฐ๊ฒฝ ์ ํ์ ๋ฐ๋ผ ์ธ๋ถ ์คํ์ผ ์ต์
์
๋ฐ์ดํธ (๋จผ์ ์ํ)
|
651 |
background_type.change(
|
|
|
655 |
).then(
|
656 |
fn=update_all_previews,
|
657 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
658 |
+
outputs=[selection_preview]
|
659 |
)
|
660 |
|
661 |
# ๋ชจ๋ ์ ํ ์ปดํฌ๋ํธ์ ๋ณ๊ฒฝ ์ด๋ฒคํธ์ ์ฐ๊ฒฐ
|
662 |
product_name.change(
|
663 |
fn=update_all_previews,
|
664 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
665 |
+
outputs=[selection_preview]
|
666 |
)
|
667 |
+
|
668 |
product_category.change(
|
669 |
fn=update_all_previews,
|
670 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
671 |
+
outputs=[selection_preview]
|
672 |
)
|
673 |
+
|
674 |
background_style.change(
|
675 |
fn=update_all_previews,
|
676 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
677 |
+
outputs=[selection_preview]
|
678 |
)
|
679 |
+
|
680 |
lighting.change(
|
681 |
fn=update_all_previews,
|
682 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
683 |
+
outputs=[selection_preview]
|
684 |
)
|
685 |
+
|
686 |
texture.change(
|
687 |
fn=update_all_previews,
|
688 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
689 |
+
outputs=[selection_preview]
|
690 |
)
|
691 |
+
|
692 |
color_tone.change(
|
693 |
fn=update_all_previews,
|
694 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
695 |
+
outputs=[selection_preview]
|
696 |
)
|
697 |
+
|
698 |
mood.change(
|
699 |
fn=update_all_previews,
|
700 |
inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
|
701 |
+
outputs=[selection_preview]
|
702 |
+
)
|
703 |
+
|
704 |
+
# ํ๋กฌํํธ ์์ฑ ๋ฒํผ ํด๋ฆญ ์ด๋ฒคํธ
|
705 |
+
prompt_generate_btn.click(
|
706 |
+
fn=generate_prompt_and_ask_llm,
|
707 |
+
inputs=[product_name, product_category, background_type, background_style,
|
708 |
+
lighting, texture, color_tone, mood],
|
709 |
+
outputs=[kr_prompt_display, prompt_input, options_summary]
|
710 |
)
|
711 |
|
712 |
+
# ์ด๋ฏธ์ง ์์ฑ ๋ฒํผ ํด๋ฆญ ์ด๋ฒคํธ (์๋ ๊ธฐ๋ฅ ๋ณต์)
|
713 |
submit_btn.click(
|
714 |
+
fn=process_images_with_prompt,
|
715 |
+
inputs=[image1_input, image2_input, image3_input, prompt_input],
|
716 |
+
outputs=[output_image, output_text, prompt_display],
|
|
|
|
|
717 |
)
|
718 |
|
719 |
gr.Markdown(
|
|
|
724 |
2. "๋ฐฐ๊ฒฝ๋ฐ๊พธ๊ธฐ" ๋ฒํผ์ ํด๋ฆญํ๋ฉด ๋ฐฐ๊ฒฝ ๋ณ๊ฒฝ ์ต์
์ด ๋ํ๋ฉ๋๋ค.
|
725 |
3. ์ํ๋ช
์ ์
๋ ฅํ๊ณ ์ ํ๊ตฐ, ๋ฐฐ๊ฒฝ ์ ํ, ๋ฐฐ๊ฒฝ ์ธ๋ถ ์คํ์ผ์ ์ ํํ์ธ์.
|
726 |
4. ์ถ๊ฐ ์ต์
(์กฐ๋ช
, ์ง๊ฐ, ์๊ฐ, ๋ถ์๊ธฐ)์ ์ ํํ๋ฉด ๋ ์ธ๋ฐํ ๋ฐฐ๊ฒฝ์ ์์ฑํ ์ ์์ต๋๋ค.
|
727 |
+
5. "ํ๋กฌํํธ ์์ฑ" ๋ฒํผ์ ํด๋ฆญํ๋ฉด LLM ์คํ์ผ ํ๋กฌํํธ๊ฐ ์์ฑ๋๊ณ , ์ด๋ฅผ ๋ฐํ์ผ๋ก ์ด๋ฏธ์ง ์์ฑ์ฉ ํ๋กฌํํธ๊ฐ ์๋์ผ๋ก ์์ฑ๋ฉ๋๋ค.
|
728 |
+
6. "์ด๋ฏธ์ง ์์ฑ" ๋ฒํผ์ ํด๋ฆญํ๋ฉด ์์ฑ๋ ํ๋กฌํํธ๋ฅผ ์ฌ์ฉํ์ฌ ์ด๋ฏธ์ง๊ฐ ์์ฑ๋ฉ๋๋ค.
|
729 |
+
7. ํ๋กฌํํธ ์
๋ ฅ๋์ ์ง์ ํ๋กฌํํธ๋ฅผ ์์ฑํ ์๋ ์์ต๋๋ค.
|
730 |
|
731 |
+
> **ํ**: ์ ํ ๋ด์ฉ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์์ ์์ฑ๋ ํ๋กฌํํธ๋ฅผ ํ์ธํ ์ ์์ต๋๋ค.
|
732 |
"""
|
733 |
)
|
734 |
|