Kims12 commited on
Commit
853fc8a
ยท
verified ยท
1 Parent(s): faf60ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -551
app.py CHANGED
@@ -61,7 +61,7 @@ def translate_prompt_to_english(prompt):
61
  logger.exception("๋ฒˆ์—ญ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ:")
62
  return prompt
63
 
64
- def preprocess_prompt(prompt, image1, image2, image3, bg_options=None):
65
  """
66
  ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ณ  ๊ธฐ๋Šฅ ๋ช…๋ น์„ ํ•ด์„
67
  """
@@ -103,37 +103,11 @@ def preprocess_prompt(prompt, image1, image2, image3, bg_options=None):
103
  elif "4. ์˜ท๋ฐ”๊พธ๊ธฐ" in prompt:
104
  prompt = "์ฒซ ๋ฒˆ์งธ ์ด๋ฏธ์ง€์˜ ์ธ๋ฌผ ์˜์ƒ์„ ๋‘ ๋ฒˆ์งธ ์ด๋ฏธ์ง€์˜ ์˜์ƒ์œผ๋กœ ๋ณ€๊ฒฝํ•ด์ฃผ์„ธ์š”. ์˜์ƒ์˜ ์Šคํƒ€์ผ๊ณผ ์ƒ‰์ƒ์€ ๋‘ ๋ฒˆ์งธ ์ด๋ฏธ์ง€๋ฅผ ๋”ฐ๋ฅด๋˜, ์‹ ์ฒด ๋น„์œจ๊ณผ ํฌ์ฆˆ๋Š” ์ฒซ ๋ฒˆ์งธ ์ด๋ฏธ์ง€๋ฅผ ์œ ์ง€ํ•ด์ฃผ์„ธ์š”."
105
 
106
- elif "5. ๋ฐฐ๊ฒฝ๋ฐ”๊พธ๊ธฐ" in prompt or "๋ฐฐ๊ฒฝ ๋ณ€๊ฒฝ" in prompt:
107
- # ๋ฐฐ๊ฒฝ ์˜ต์…˜์ด ์žˆ์œผ๋ฉด ๊ทธ๊ฒƒ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ
108
- if bg_options and all([bg_options.get("product_name"), bg_options.get("background_type"), bg_options.get("background_style")]):
109
- product_name = bg_options.get("product_name", "")
110
- product_category = bg_options.get("product_category", "์ผ๋ฐ˜ ์ƒํ’ˆ")
111
- background_type = bg_options.get("background_type", "์ž์—ฐ ๋ฐฐ๊ฒฝ")
112
- background_style = bg_options.get("background_style", "์ˆฒ")
113
- lighting = bg_options.get("lighting", "์ž์—ฐ๊ด‘")
114
- texture = bg_options.get("texture", "")
115
- color_tone = bg_options.get("color_tone", "")
116
- mood = bg_options.get("mood", "")
117
-
118
- # ์ด์ปค๋จธ์Šค ์ธ๋„ค์ผ์šฉ ๊ณ ํ’ˆ์งˆ ์ƒ์—…์  ๋ฐฐ๊ฒฝ ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ
119
- prompt = f"์ด์ปค๋จธ์Šค ์ธ๋„ค์ผ์šฉ ๊ณ ํ’ˆ์งˆ ์ƒ์—… ์‚ฌ์ง„: #1 ์ด๋ฏธ์ง€์˜ {product_name} ์ƒํ’ˆ์„ ์™„๋ฒฝํ•˜๊ฒŒ ๋ณด์กดํ•˜๋ฉด์„œ ๋ฐฐ๊ฒฝ๋งŒ {background_type} ์ค‘ {background_style}์œผ๋กœ ๋ณ€๊ฒฝํ•ด์ฃผ์„ธ์š”. "
120
-
121
- # ์ถ”๊ฐ€ ์„ธ๋ถ€ ์‚ฌํ•ญ ํฌํ•จ
122
- if lighting:
123
- prompt += f"{lighting}์„ ์‚ฌ์šฉํ•˜์—ฌ ์ƒํ’ˆ์„ ๋‹๋ณด์ด๊ฒŒ ํ•˜๊ณ , "
124
- if texture and texture != "์„ ํƒ ์•ˆํ•จ":
125
- prompt += f"{texture} ์งˆ๊ฐ์˜ ๋ฐฐ๊ฒฝ์œผ๋กœ ์ƒํ’ˆ์˜ ๊ณ ๊ธ‰์Šค๋Ÿฌ์›€์„ ๊ฐ•์กฐํ•˜๋ฉฐ, "
126
- if color_tone and color_tone != "์„ ํƒ ์•ˆํ•จ":
127
- prompt += f"์ „์ฒด์ ์œผ๋กœ {color_tone}์œผ๋กœ ์กฐํ™”๋กญ๊ฒŒ ์ฒ˜๋ฆฌํ•˜๊ณ , "
128
- if mood and mood != "์„ ํƒ ์•ˆํ•จ":
129
- prompt += f"{mood}ํ•œ ๋ถ„์œ„๊ธฐ๋กœ "
130
-
131
- prompt += f"์—ฐ์ถœํ•ด์ฃผ์„ธ์š”. {product_category} ์ƒํ’ˆ์˜ ๋””ํ…Œ์ผ, ์ƒ‰์ƒ, ์งˆ๊ฐ, ํ˜•ํƒœ, ๊ทธ๋ฆผ์ž๋Š” ์›๋ณธ #1 ์ด๋ฏธ์ง€์™€ 100% ๋™์ผํ•˜๊ฒŒ ์œ ์ง€ํ•˜๊ณ , ๋ฐฐ๊ฒฝ๋งŒ ๋ณ€๊ฒฝํ•˜์—ฌ ์ „๋ฌธ์ ์ด๊ณ  ์ƒ์—…์„ฑ ๋†’์€ ์ด์ปค๋จธ์Šค ์ œํ’ˆ ์‚ฌ์ง„์œผ๋กœ ์ œ์ž‘ํ•ด์ฃผ์„ธ์š”."
132
- else:
133
- prompt = "์ฒซ ๋ฒˆ์งธ ์ด๋ฏธ์ง€์˜ ๋ฐฐ๊ฒฝ์„ ๋‘ ๋ฒˆ์งธ ์ด๋ฏธ์ง€์˜ ๋ฐฐ๊ฒฝ์œผ๋กœ ๋ณ€๊ฒฝํ•ด์ฃผ์„ธ์š”. ์ฒซ ๋ฒˆ์งธ ์ด๋ฏธ์ง€์˜ ์ฃผ์š” ํ”ผ์‚ฌ์ฒด๋Š” ์œ ์ง€ํ•˜๊ณ , ๋‘ ๋ฒˆ์งธ ์ด๋ฏธ์ง€์˜ ๋ฐฐ๊ฒฝ๊ณผ ์กฐํ™”๋กญ๊ฒŒ ํ•ฉ์„ฑํ•ด์ฃผ์„ธ์š”."
134
 
135
- elif "์ƒํ’ˆํ•ฉ์„ฑ" in prompt:
136
- prompt = "#1 ์ƒํ’ˆ ์ด๋ฏธ์ง€์— #2 ์ด๋ฏธ์ง€ ๋˜๋Š” #3 ์ด๋ฏธ์ง€๋ฅผ [๋ชจ๋“  ์ด๋ฏธ์ง€์˜ ์ฃผ์š” ์š”์†Œ๋ฅผ ํฌํ•จํ•˜๊ณ , ํŠนํžˆ ์ƒํ’ˆ์ด ๋‹๋ณด์ด๋„๋ก ์กฐํ™”๋กญ๊ฒŒ ํ†ตํ•ฉํ•˜์—ฌ]์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ํ•ฉ์„ฑํ•˜๋ผ."
137
 
138
  prompt += " ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•ด์ฃผ์„ธ์š”."
139
  return prompt
@@ -190,7 +164,7 @@ def generate_with_images(prompt, images):
190
  logger.exception("์ด๋ฏธ์ง€ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ:")
191
  return None, f"์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
192
 
193
- def process_images_with_prompt(image1, image2, image3, prompt, bg_options=None):
194
  """
195
  3๊ฐœ์˜ ์ด๋ฏธ์ง€์™€ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•˜์—ฌ ์ตœ์ข… ์˜์–ด ํ”„๋กฌํ”„ํŠธ(final_prompt)๋ฅผ ์ƒ์„ฑํ•œ ํ›„,
196
  API๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ๊ฒฐ๊ณผ ์ด๋ฏธ์ง€๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
@@ -202,7 +176,7 @@ def process_images_with_prompt(image1, image2, image3, prompt, bg_options=None):
202
  return None, "์ ์–ด๋„ ํ•˜๋‚˜์˜ ์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•ด์ฃผ์„ธ์š”.", ""
203
 
204
  if prompt and prompt.strip():
205
- processed_prompt = preprocess_prompt(prompt, image1, image2, image3, bg_options)
206
  if re.search("[๊ฐ€-ํžฃ]", processed_prompt):
207
  final_prompt = translate_prompt_to_english(processed_prompt)
208
  else:
@@ -224,552 +198,106 @@ 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 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"#1 {kr_prompt}"
237
-
238
- client = genai.Client(api_key=api_key)
239
-
240
- llm_prompt = f"""
241
- ์ด์ปค๋จธ์Šค ์ƒํ’ˆ ์ด๋ฏธ์ง€ ๋ฐฐ๊ฒฝ ๋ณ€๊ฒฝ์„ ์œ„ํ•œ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”. ์•„๋ž˜ ์›๋ณธ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ฐธ๊ณ ํ•˜์—ฌ, ์ƒํ’ˆ์ด ์ƒˆ๋กœ์šด ๋ฐฐ๊ฒฝ๊ณผ ์™„๋ฒฝํ•˜๊ฒŒ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์–ด์šฐ๋Ÿฌ์ง€๋Š” ๊ณ ํ’ˆ์งˆ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ž‘์„ฑํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
242
-
243
- ํ•„์ˆ˜ ์š”๊ตฌ์‚ฌํ•ญ:
244
- 1. ๋ฐ˜๋“œ์‹œ "#1"์œผ๋กœ ์‹œ์ž‘ํ•˜์—ฌ ์›๋ณธ ์ด๋ฏธ์ง€๋ฅผ ์ฐธ์กฐํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
245
- 2. ์›๋ณธ ์ œํ’ˆ์˜ ๋ชจ๋“  ํŠน์„ฑ(์ƒ‰์ƒ, ์งˆ๊ฐ, ๋””์ž์ธ, ๋กœ๊ณ , ๋น„์œจ ๋“ฑ)์ด 100% ๊ทธ๋Œ€๋กœ ์œ ์ง€๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
246
- 3. ์ œํ’ˆ์ด ๋ฐฐ๊ฒฝ์— ์‹ค์ œ๋กœ ๋†“์—ฌ์žˆ๋Š” ๋ชจ์Šต์„ ๋งค์šฐ ๊ตฌ์ฒด์ ์œผ๋กœ ๋ฌ˜์‚ฌํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
247
- ์˜ˆ: "๋Œ์˜ ํ‰ํ‰ํ•œ ํ‘œ๋ฉด์— ์•ˆ์ •์ ์œผ๋กœ ์ž๋ฆฌ์žก๊ณ  ์žˆ์Œ" ๋˜๋Š” "๋ชจ๋ž˜ ์œ„์— ๋‹จ๋‹จํžˆ ์„œ ์žˆ์œผ๋ฉฐ ์ฃผ๋ณ€ ๋ชจ๋ž˜ ์ž…์ž๋“ค์ด ์ œํ’ˆ ํ•˜๋‹จ๋ถ€๋ฅผ ์‚ด์ง ๊ฐ์‹ธ๊ณ  ์žˆ์Œ"
248
- 4. ๋ฐฐ๊ฒฝ ํ™˜๊ฒฝ, ์กฐ๋ช…, ์ฃผ๋ณ€ ์š”์†Œ๋ฅผ ๋งค์šฐ ๊ตฌ์ฒด์ ์œผ๋กœ ์„ค๋ช…ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
249
- 5. ์ œํ’ˆ๊ณผ ๋ฐฐ๊ฒฝ ์‚ฌ์ด์˜ ๋ฌผ๋ฆฌ์  ์ƒํ˜ธ์ž‘์šฉ(๊ทธ๋ฆผ์ž, ๋ฐ˜์‚ฌ, ์ฃผ๋ณ€ ์š”์†Œ์™€์˜ ๊ด€๊ณ„)์„ ์ƒ์„ธํžˆ ๋ฌ˜์‚ฌํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
250
- 6. ์ตœ์ข… ์ด๋ฏธ์ง€๊ฐ€ ์ „๋ฌธ์ ์ธ ์ƒํ’ˆ ์‚ฌ์ง„์ฒ˜๋Ÿผ ๋ณด์ด๋„๋ก ์นด๋ฉ”๋ผ ์„ค์ •, ์กฐ๋ช… ํšจ๊ณผ ๋“ฑ์„ ํฌํ•จํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
251
- 7. ์ธ์œ„์ ์ด๊ฑฐ๋‚˜ ํ•ฉ์„ฑ๋œ ๋А๋‚Œ์ด ์•„๋‹Œ, ์‹ค์ œ ๊ทธ ์žฅ์†Œ์—์„œ ์ดฌ์˜ํ•œ ๊ฒƒ์ฒ˜๋Ÿผ ์ž์—ฐ์Šค๋Ÿฌ์›Œ์•ผ ํ•ฉ๋‹ˆ๋‹ค.
252
-
253
- ์•„๋ž˜๋Š” ์ž˜ ์ž‘์„ฑ๋œ ํ”„๋กฌํ”„ํŠธ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค:
254
-
255
- ์˜ˆ์‹œ 1 (๊ณ„๊ณก ๋Œ ์œ„์˜ ํ™”์žฅํ’ˆ):
256
- "Purdell skincare tube (#1) elegantly positioned on a smooth river stone in a gentle flowing stream. Clear mountain water flowing around the base of the gray stone, creating subtle splashes and ripples. The silver packaging reflecting natural daylight, nestled securely on the flat surface of the polished stone. Background shows tranquil forest scenery with soft-focus greenery. Natural color palette with blue-green water, gray stone, and verdant surroundings complementing the silver product tube. Professional commercial photography lighting highlighting the product while maintaining its original appearance."
257
-
258
- ์˜ˆ์‹œ 2 (ํ•ด๋ณ€ ๋ชจ๋ž˜ ์œ„์˜ ํ™”์žฅํ’ˆ):
259
- "Purdell Ultra HA Gel skincare tube (#1) positioned securely on pristine white beach sand. Gentle golden sand grains surrounding the base of the silver packaging, creating a stable foundation. Soft ocean waves visible in the background with turquoise water meeting clear blue sky at the horizon. Natural sunlight highlighting the metallic silver tube while casting a subtle shadow on the sand. A few delicate seashells scattered nearby, adding natural beach elements. Commercial-quality product photography maintaining the original appearance of the skincare product while presenting it in a refreshing beach setting for marketing purposes."
260
-
261
- ์˜ˆ์‹œ 3 (๊ณ„๊ณก ๋ฐ”์œ„ ์œ„์˜ ๋ฌผ๋ณ‘):
262
- "JIRV brand lavender and cream water bottles (#1) preserved exactly as shown, placed on a wide rock in a cool mountain stream. Clear creek water flowing around the rock base, surrounded by lush green trees and moss-covered stones. All product details (colors, logo, design, proportions) remain completely unchanged from the original image, only modifying the environment background. Natural sunlight filtering through tree branches gently illuminates the matte surface of the bottles. Commercial product photography that maintains all original product characteristics while only applying a natural creek background setting."
263
-
264
- ์œ„ ์˜ˆ์‹œ๋“ค์ฒ˜๋Ÿผ ๊ตฌ์ฒด์ ์ด๊ณ  ์ƒ์„ธํ•œ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”. ์ค‘์š”ํ•œ ๊ฒƒ์€ ์›๋ณธ ์ œํ’ˆ ์ด๋ฏธ์ง€(#1)์˜ ๋ชจ๋“  ๋””ํ…Œ์ผ์„ ๋ณด์กดํ•˜๋ฉด์„œ, ๋ฐฐ๊ฒฝ๊ณผ ๋ฌผ๋ฆฌ์ ์œผ๋กœ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์–ด์šฐ๋Ÿฌ์ง€๋Š” ๋ชจ์Šต์„ ์„ค๋ช…ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.
265
-
266
- ์›๋ณธ ํ”„๋กฌํ”„ํŠธ:
267
- {kr_prompt}
268
-
269
- ์œ„ ๋‚ด์šฉ์„ ๋ฐ”ํƒ•์œผ๋กœ ์ตœ์ข… ํ”„๋กฌํ”„ํŠธ๋งŒ ์ž‘์„ฑํ•ด์ฃผ์„ธ์š”. ์„ค๋ช…์ด๋‚˜ ์ถ”๊ฐ€ ํ…์ŠคํŠธ ์—†์ด ํ”„๋กฌํ”„ํŠธ ์ž์ฒด๋งŒ ์ถœ๋ ฅํ•˜์„ธ์š”.
270
- """
271
-
272
- response = client.models.generate_content(
273
- model="gemini-2.0-flash",
274
- contents=[llm_prompt],
275
- config=types.GenerateContentConfig(
276
- response_modalities=['Text'],
277
- temperature=0.7,
278
- top_p=0.95,
279
- top_k=40,
280
- max_output_tokens=1024
281
- )
282
- )
283
-
284
- final_prompt = ""
285
- for part in response.candidates[0].content.parts:
286
- if hasattr(part, 'text') and part.text:
287
- final_prompt += part.text
288
-
289
- # LLM ์‘๋‹ต์— #1์ด ์—†๋Š” ๊ฒฝ์šฐ ๊ฐ•์ œ๋กœ ์ถ”๊ฐ€
290
- final_prompt = final_prompt.strip()
291
- if not final_prompt.startswith("#1"):
292
- final_prompt = f"#1 {final_prompt}"
293
-
294
- if final_prompt.strip():
295
- logger.info(f"LLM 2์ฐจ ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ ๊ฒฐ๊ณผ: {final_prompt.strip()}")
296
- return final_prompt.strip()
297
- else:
298
- logger.warning("LLM 2์ฐจ ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ ๊ฒฐ๊ณผ๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ์›๋ณธ ํ”„๋กฌํ”„ํŠธ ์‚ฌ์šฉ")
299
- return f"#1 {kr_prompt}"
300
  except Exception as e:
301
- logger.exception("LLM 2์ฐจ ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ:")
302
- return f"#1 {kr_prompt}"
303
-
304
- def generate_llm_prompt(product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood):
305
- """
306
- ์‚ฌ์šฉ์ž ์„ ํƒ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ์ƒ์„ธํ•œ ์ƒํ’ˆ ์ด๋ฏธ์ง€ ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ
307
- """
308
- # ์ƒํ’ˆ๋ช… ํ™•์ธ ๋ฐ ๊ธฐ๋ณธ๊ฐ’ ์„ค์ •
309
- product_display = product_name if product_name and product_name.strip() else "์ œํ’ˆ"
310
-
311
- # ๊ธฐ๋ณธ ํ”„๋กฌํ”„ํŠธ ํ…œํ”Œ๋ฆฟ ์‹œ์ž‘
312
- prompt = f"#1 {product_display} "
313
-
314
- # ์ œํ’ˆ๊ตฐ๋ณ„ ์„ค๋ช… ์ถ”๊ฐ€
315
- if product_category == "ํ™”์žฅํ’ˆ":
316
- prompt += f"ํ™”์žฅํ’ˆ ํŠœ๋ธŒ๊ฐ€ "
317
- elif product_category == "๊ฐ€๋ฐฉ":
318
- prompt += f"๊ฐ€๋ฐฉ์ด "
319
- elif product_category == "์•ก์„ธ์„œ๋ฆฌ":
320
- prompt += f"์•ก์„ธ์„œ๋ฆฌ๊ฐ€ "
321
- elif product_category == "๋ณด์„๋ฅ˜":
322
- prompt += f"๋ณด์„ ์ œํ’ˆ์ด "
323
- elif product_category == "ํ™ˆ ๋ฐ์ฝ”":
324
- prompt += f"ํ™ˆ ๋ฐ์ฝ” ์ œํ’ˆ์ด "
325
- elif product_category == "์‹ ๋ฐœ":
326
- prompt += f"์‹ ๋ฐœ์ด "
327
- elif product_category == "์˜๋ฅ˜":
328
- prompt += f"์˜๋ฅ˜ ์ œํ’ˆ์ด "
329
- elif product_category == "์ฃผ๋ฐฉ์šฉํ’ˆ":
330
- prompt += f"์ฃผ๋ฐฉ์šฉํ’ˆ์ด "
331
- elif product_category == "์ „์ž๊ธฐ๊ธฐ":
332
- prompt += f"์ „์ž๊ธฐ๊ธฐ๊ฐ€ "
333
- else:
334
- prompt += f"์ œํ’ˆ์ด "
335
-
336
- # ๋ฐฐ๊ฒฝ ์œ ํ˜• ๋ฐ ์„ธ๋ถ€ ์Šคํƒ€์ผ์— ๋”ฐ๋ฅธ ๋ฐฐ์น˜ ์„ค๋ช… ์ถ”๊ฐ€
337
- if background_type == "์ž์—ฐ ๋ฐฐ๊ฒฝ":
338
- if background_style == "์ˆฒ":
339
- prompt += "ํ‘ธ๋ฅธ ์ˆฒ์† ํ™˜๊ฒฝ์˜ ์ž์—ฐ์Šค๋Ÿฌ์šด ๋ฐ”์œ„๋‚˜ ๊ทธ๋ฃจํ„ฐ๊ธฐ ์œ„์— ์•ˆ์ •์ ์œผ๋กœ ๋†“์—ฌ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฃผ๋ณ€์—๋Š” ์„ ๋ช…ํ•œ ๋…น์ƒ‰ ์žŽ์‚ฌ๊ท€๋“ค๊ณผ ๋ถ€๋“œ๋Ÿฌ์šด ์ด๋ผ๊ฐ€ ๋ณด์ด๋ฉฐ, "
340
- elif background_style == "ํ•ด๋ณ€":
341
- prompt += "๊นจ๋—ํ•œ ๋ฐฑ์‚ฌ์žฅ ์œ„์— ๋‹จ๋‹จํžˆ ์ž๋ฆฌ์žก๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ฃผ๋ณ€ ๋ชจ๋ž˜ ์ž…์ž๋“ค์ด ์ œํ’ˆ ํ•˜๋‹จ๋ถ€๋ฅผ ์‚ด์ง ๊ฐ์‹ธ๊ณ  ์žˆ์œผ๋ฉฐ, ๋ฐฐ๊ฒฝ์—๋Š” ์ฒญ๋ก์ƒ‰ ๋ฐ”๋‹ค์™€ ๋ง‘์€ ํ•˜๋Š˜์ด ๋ณด์ž…๋‹ˆ๋‹ค. "
342
- elif background_style == "์‚ฐ":
343
- prompt += "์›…์žฅํ•œ ์‚ฐ์˜ ์ •์ƒ์— ์žˆ๋Š” ๋ฐ”์œ„ ์œ„์— ์•ˆ์ •์ ์œผ๋กœ ๋†“์—ฌ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฃผ๋ณ€์œผ๋กœ ํƒ ํŠธ์ธ ์‚ฐ์•… ํ’๊ฒฝ๊ณผ ํ‘ธ๋ฅธ ํ•˜๋Š˜์ด ํŽผ์ณ์ง€๋ฉฐ, "
344
- elif background_style == "๋“คํŒ":
345
- prompt += "๋„“๊ฒŒ ํŽผ์ณ์ง„ ์•ผ์ƒํ™” ๋“คํŒ ๊ฐ€์šด๋ฐ ํ‰ํ‰ํ•œ ๋Œ ์œ„์— ์ž๋ฆฌ์žก๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ฃผ๋ณ€์—๋Š” ๋‹ค์–‘ํ•œ ์ƒ‰์ƒ์˜ ์•ผ์ƒํ™”๋“ค์ด ๋ถ€๋“œ๋Ÿฝ๊ฒŒ ํ”๋“ค๋ฆฌ๋ฉฐ, "
346
- elif background_style == "๊ณ„๊ณก":
347
- prompt += "๋ง‘์€ ๊ณ„๊ณก๋ฌผ์ด ํ๋ฅด๋Š” ๊ณณ์˜ ๋งค๋„๋Ÿฌ์šด ๋ฐ”์œ„ ์œ„์— ์•ˆ์ •์ ์œผ๋กœ ๋†“์—ฌ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฐ”์œ„ ์ฃผ๋ณ€์œผ๋กœ ํˆฌ๋ช…ํ•œ ๋ฌผ์ด ๋ถ€๋“œ๋Ÿฝ๊ฒŒ ํ๋ฅด๋ฉฐ ์ž‘์€ ๋ฌผ๋ฐฉ์šธ๋“ค์ด ๋ฐ˜์ง์ด๊ณ , "
348
- elif background_style == "์—ด๋Œ€ ์ •์›":
349
- prompt += "ํ™”๋ คํ•œ ์—ด๋Œ€ ์‹๋ฌผ๋“ค๋กœ ๋‘˜๋Ÿฌ์‹ธ์ธ ๊ณต๊ฐ„์˜ ํ‰ํ‰ํ•œ ๋Œ ์œ„์— ๋†“์—ฌ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฃผ๋ณ€์—๋Š” ์„ ๋ช…ํ•œ ๋…น์ƒ‰ ์žŽ๊ณผ ํ™”๋ คํ•œ ๊ฝƒ๋“ค์ด ํ’๋ถ€ํ•˜๊ฒŒ ์ž๋ผ๊ณ  ์žˆ์œผ๋ฉฐ, "
350
- elif background_style == "์‚ฌ๋ง‰":
351
- prompt += "ํ™ฉ๊ธˆ๋น› ์‚ฌ๋ง‰ ๋ชจ๋ž˜ ์œ„์— ์•ˆ์ •์ ์œผ๋กœ ์ž๋ฆฌ์žก๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋ถ€๋“œ๋Ÿฌ์šด ๋ชจ๋ž˜ ๋ฌผ๊ฒฐ๊ณผ ์‚ฌ๋ง‰ ํŠน์œ ์˜ ๊ณ ์š”ํ•จ์ด ๋ฐฐ๊ฒฝ์— ๋‚˜ํƒ€๋‚˜๋ฉฐ, "
352
- elif background_style == "๋ˆˆ ํ’๊ฒฝ":
353
- prompt += "ํ•˜์–€ ๋ˆˆ์œผ๋กœ ๋ฎ์ธ ํ’๊ฒฝ ์† ์–ผ์Œ์ฒ˜๋Ÿผ ๋ง‘์€ ๋ฐ”์œ„ ์œ„์— ๋†“์—ฌ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฃผ๋ณ€์˜ ๋ˆˆ ๊ฒฐ์ •์ฒด๊ฐ€ ๋ฐ˜์ง์ด๊ณ  ์ฐจ๊ฐ€์šด ๊ฒจ์šธ ๋ถ„์œ„๊ธฐ๊ฐ€ ๋А๊ปด์ง€๋ฉฐ, "
354
- else:
355
- prompt += f"{background_style} ์ž์—ฐ ๋ฐฐ๊ฒฝ์˜ ์ ์ ˆํ•œ ํ‘œ๋ฉด ์œ„์— ์•ˆ์ •์ ์œผ๋กœ ๋†“์—ฌ ์žˆ์Šต๋‹ˆ๋‹ค. "
356
- elif background_type == "์‹ค๋‚ด ๋ฐฐ๊ฒฝ":
357
- if background_style == "๊ฑฐ์‹ค":
358
- prompt += "์„ธ๋ จ๋œ ๊ฑฐ์‹ค ๊ณต๊ฐ„์˜ ์šฐ์•„ํ•œ ์ปคํ”ผ ํ…Œ์ด๋ธ” ์œ„์— ์™„๋ฒฝํ•˜๊ฒŒ ๋ฐฐ์น˜๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ํ˜„๋Œ€์ ์ธ ๊ฐ€๊ตฌ์™€ ์•„๋Š‘ํ•œ ์ƒํ™œ ๊ณต๊ฐ„์ด ๋ฐฐ๊ฒฝ์œผ๋กœ ๋ณด์ด๋ฉฐ, "
359
- elif background_style == "์ฃผ๋ฐฉ":
360
- prompt += "๋ชจ๋˜ํ•œ ์ฃผ๋ฐฉ ์นด์šดํ„ฐ ์œ„์— ๊น”๋”ํ•˜๊ฒŒ ๋†“์—ฌ ์žˆ์Šต๋‹ˆ๋‹ค. ์ฃผ๋ณ€์—๋Š” ์ •๋ˆ๋œ ์ฃผ๋ฐฉ ์šฉํ’ˆ๋“ค๊ณผ ์„ธ๋ จ๋œ ์ฃผ๋ฐฉ ์ธํ…Œ๋ฆฌ์–ด๊ฐ€ ๋ณด์ด๋ฉฐ, "
361
- elif background_style == "์„œ์žฌ":
362
- prompt += "๏ฟฝ๏ฟฝ๊ธ‰์Šค๋Ÿฌ์šด ๋ชฉ์žฌ ์ฑ…์ƒ์ด๋‚˜ ์ฑ…์žฅ ์œ„์— ์•ˆ์ •์ ์œผ๋กœ ์ž๋ฆฌ์žก๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ฃผ๋ณ€์—๋Š” ์ฑ…๊ณผ ์ง€์ ์ธ ๋ถ„์œ„๊ธฐ๋ฅผ ํ’๊ธฐ๋Š” ์†Œํ’ˆ๋“ค์ด ๋ณด์ด๋ฉฐ, "
363
- elif background_style == "ํ™”์žฅ๋Œ€":
364
- prompt += "์šฐ์•„ํ•œ ํ™”์žฅ๋Œ€ ์œ„์— ๋‹ค๋ฅธ ํ™”์žฅํ’ˆ๋“ค๊ณผ ํ•จ๊ป˜ ์กฐํ™”๋กญ๊ฒŒ ๋ฐฐ์น˜๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์„ธ๋ จ๋œ ๊ฑฐ์šธ๊ณผ ํ™”์žฅ๋Œ€ ์†Œํ’ˆ๋“ค์ด ๋ฐฐ๊ฒฝ์œผ๋กœ ๋ณด์ด๋ฉฐ, "
365
- elif background_style == "ํ˜ธํ…” ๋กœ๋น„":
366
- prompt += "๊ณ ๊ธ‰์Šค๋Ÿฌ์šด ํ˜ธํ…” ๋กœ๋น„์˜ ๋Œ€๋ฆฌ์„ ํ…Œ์ด๋ธ”์ด๋‚˜ ์นด์šดํ„ฐ ์œ„์— ์šฐ์•„ํ•˜๊ฒŒ ๋†“์—ฌ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ณ ๊ธ‰์Šค๋Ÿฌ์šด ์ธํ…Œ๋ฆฌ์–ด์™€, ๊ณต๊ฐ„์˜ ๋„“๊ณ  ์พŒ์ ํ•œ ๋А๋‚Œ์ด ๋ฐฐ๊ฒฝ์— ๋‚˜ํƒ€๋‚˜๋ฉฐ, "
367
- elif background_style == "์นดํŽ˜":
368
- prompt += "๋ถ„์œ„๊ธฐ ์žˆ๋Š” ์นดํŽ˜ ํ…Œ์ด๋ธ” ์œ„์— ์™„๋ฒฝํ•˜๊ฒŒ ๋ฐฐ์น˜๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋”ฐ๋œปํ•œ ์นดํŽ˜ ๋ถ„์œ„๊ธฐ์™€ ์•„๋Š‘ํ•œ ๊ณต๊ฐ„๊ฐ์ด ๋ฐฐ๊ฒฝ์œผ๋กœ ํŽผ์ณ์ง€๋ฉฐ, "
369
- elif background_style == "๋ฏธ๋‹ˆ๋ฉ€ ๊ณต๊ฐ„":
370
- prompt += "๊น”๋”ํ•œ ๋ฏธ๋‹ˆ๋ฉ€ ๊ณต๊ฐ„์˜ ๋‹จ์ˆœํ•œ ํ‘œ๋ฉด ์œ„์— ๋†“์—ฌ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ถˆํ•„์š”ํ•œ ์š”์†Œ ์—†์ด ๊นจ๋—ํ•˜๊ณ  ์ •์ œ๋œ ๋ฐฐ๊ฒฝ์ด ์ œํ’ˆ์„ ๋‹๋ณด์ด๊ฒŒ ํ•˜๋ฉฐ, "
371
- else:
372
- prompt += f"{background_style} ์‹ค๋‚ด ๊ณต๊ฐ„์˜ ์ ์ ˆํ•œ ํ‘œ๋ฉด ์œ„์— ์•ˆ์ •์ ์œผ๋กœ ๋†“์—ฌ ์žˆ์Šต๋‹ˆ๋‹ค. "
373
- elif background_type == "ํŠน์ˆ˜ ๋ฐฐ๊ฒฝ":
374
- if background_style == "๋„์‹œ ํ’๊ฒฝ":
375
- prompt += "ํ˜„๋Œ€์ ์ธ ๋„์‹œ ํ’๊ฒฝ์„ ๋ฐฐ๊ฒฝ์œผ๋กœ ๋„์‹œ์˜ ๋ฒค์น˜๋‚˜ ์ฝ˜ํฌ๋ฆฌํŠธ ๊ตฌ์กฐ๋ฌผ ์œ„์— ๋†“์—ฌ ์žˆ์Šต๋‹ˆ๋‹ค. ๋„์‹œ์˜ ํ™œ๊ธฐ์ฐฌ ๋ถ„์œ„๊ธฐ์™€ ๊ฑด๋ฌผ๋“ค์ด ๋ฐฐ๊ฒฝ์œผ๋กœ ๋ณด์ด๋ฉฐ, "
376
- elif background_style == "๋ฃจํ”„ํƒ‘":
377
- prompt += "๋„์‹œ๊ฐ€ ๋‚ด๋ ค๋‹ค๋ณด์ด๋Š” ๋ฃจํ”„ํƒ‘ ํ…Œ์ด๋ธ”์ด๋‚˜ ๋‚œ๊ฐ„ ์œ„์— ์•ˆ์ •์ ์œผ๋กœ ์ž๋ฆฌ์žก๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ํƒ ํŠธ์ธ ๋„์‹œ ์ „๋ง๊ณผ ํ•˜๋Š˜์ด ๋ฐฐ๊ฒฝ์œผ๋กœ ํŽผ์ณ์ง€๋ฉฐ, "
378
- elif background_style == "ํ•ด์•ˆ๊ฐ€":
379
- prompt += "์•„๋ฆ„๋‹ค์šด ํ•ด์•ˆ๊ฐ€์˜ ๋ฐ”์œ„๋‚˜ ๋ถ€๋‘ ์œ„์— ๋†“์—ฌ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ˆˆ๋ถ€์‹  ๋ฐ”๋‹ค ์ „๋ง๊ณผ ํ•ด์•ˆ์„ ์ด ๋ฐฐ๊ฒฝ์œผ๋กœ ํŽผ์ณ์ง€๋ฉฐ, "
380
- elif background_style == "๋ชจ๋˜ ์ŠคํŠœ๋””์˜ค":
381
- prompt += "์ „๋ฌธ์ ์ธ ์ œํ’ˆ ์ดฌ์˜ ์ŠคํŠœ๋””์˜ค์˜ ์„ธํŠธ ์œ„์— ์™„๋ฒฝํ•˜๊ฒŒ ๋ฐฐ์น˜๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์„ธ๋ จ๋œ ์ŠคํŠœ๋””์˜ค ๋ฐฐ๊ฒฝ๊ณผ ์ „๋ฌธ์ ์ธ ์กฐ๋ช… ์„ค์ •์ด ์ œํ’ˆ์„ ๋‹๋ณด์ด๊ฒŒ ํ•˜๋ฉฐ, "
382
- elif background_style == "๋นˆํ‹ฐ์ง€ ๊ณต๊ฐ„":
383
- prompt += "ํด๋ž˜์‹ํ•œ ๋นˆํ‹ฐ์ง€ ๊ฐ€๊ตฌ๋‚˜ ์•คํ‹ฑ ํ…Œ์ด๋ธ” ์œ„์— ๋ฉ‹์Šค๋Ÿฝ๊ฒŒ ๋†“์—ฌ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ค๋ž˜๋œ ๋‚˜๋ฌด ํ‘œ๋ฉด์˜ ์งˆ๊ฐ๊ณผ ๋นˆํ‹ฐ์ง€ ์†Œํ’ˆ๋“ค์ด ๋ฐฐ๊ฒฝ์— ๋‚˜ํƒ€๋‚˜๋ฉฐ, "
384
- elif background_style == "๋ฏธ๋‹ˆ์–ด์ฒ˜ ๊ณต๊ฐ„":
385
- prompt += "์ •๊ตํ•˜๊ฒŒ ์ œ์ž‘๋œ ๋ฏธ๋‹ˆ์–ด์ฒ˜ ์„ธํŠธ ์œ„์— ์ž‘์€ ์„ธ๊ณ„์˜ ์ผ๋ถ€์ฒ˜๋Ÿผ ๋ฐฐ์น˜๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ์„ฌ์„ธํ•œ ๋ฏธ๋‹ˆ์–ด์ฒ˜ ์š”์†Œ๋“ค๊ณผ ์ฐฝ์˜์ ์ธ ์†Œํ’ˆ๋“ค์ด ์ฃผ๋ณ€์— ๋ณด์ด๋ฉฐ, "
386
- else:
387
- prompt += f"{background_style} ํŠน์ˆ˜ ๋ฐฐ๊ฒฝ์˜ ์ ์ ˆํ•œ ํ‘œ๋ฉด ์œ„์— ์•ˆ์ •์ ์œผ๋กœ ๋†“์—ฌ ์žˆ์Šต๋‹ˆ๋‹ค. "
388
-
389
- # ์กฐ๋ช… ํšจ๊ณผ ์ถ”๊ฐ€
390
- if lighting == "์ž์—ฐ๊ด‘":
391
- prompt += "์ž์—ฐ์Šค๋Ÿฌ์šด ํ–‡๋น›์ด ์ œํ’ˆ์— ๋ถ€๋“œ๋Ÿฝ๊ฒŒ ๋น„์ถฐ ์€์€ํ•œ ๋ฐ˜์‚ฌ๊ด‘๊ณผ ์ž์—ฐ์Šค๋Ÿฌ์šด ๊ทธ๋ฆผ์ž๋ฅผ ๋งŒ๋“ค๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. "
392
- elif lighting == "๋”ฐ๋œปํ•œ ์กฐ๋ช…":
393
- prompt += "๋”ฐ๋œปํ•œ ํ™ฉ๊ธˆ๋น› ์กฐ๋ช…์ด ์ œํ’ˆ ํ‘œ๋ฉด์— ๋ถ€๋“œ๋Ÿฝ๊ฒŒ ๋‹ฟ์•„ ์•„๋Š‘ํ•˜๊ณ  ํŽธ์•ˆํ•œ ๋ถ„์œ„๊ธฐ๋ฅผ ์—ฐ์ถœํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. "
394
- elif lighting == "๊ทธ๋ฆผ์ž ์žˆ๋Š” ์กฐ๋ช…":
395
- prompt += "๋“œ๋ผ๋งˆํ‹ฑํ•œ ์กฐ๋ช…์ด ์ œํ’ˆ์— ๊ฐ•ํ•œ ํ•˜์ด๋ผ์ดํŠธ์™€ ์„ ๋ช…ํ•œ ๊ทธ๋ฆผ์ž๋ฅผ ๋งŒ๋“ค์–ด ๊นŠ์ด๊ฐ๊ณผ ์ž…์ฒด๊ฐ์„ ๊ฐ•์กฐํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. "
396
- elif lighting == "๋ฏธ๋‹ˆ๋ฉ€ ์กฐ๋ช…":
397
- prompt += "๊น”๋”ํ•˜๊ณ  ์ ˆ์ œ๋œ ์กฐ๋ช…์ด ์ œํ’ˆ์„ ๊ท ์ผํ•˜๊ฒŒ ๋น„์ถฐ ์‹ฌํ”Œํ•˜๊ณ  ๋ชจ๋˜ํ•œ ๋А๋‚Œ์„ ๋งŒ๋“ค์–ด๋‚ด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. "
398
-
399
- # ์งˆ๊ฐ ์ถ”๊ฐ€
400
- if texture and texture != "์„ ํƒ ์•ˆํ•จ":
401
- if texture == "ํฐ ๋ฒฝ":
402
- prompt += "๋ฐฐ๊ฒฝ์˜ ๊นจ๋—ํ•œ ํฐ ๋ฒฝ์€ ์ œํ’ˆ์„ ๋”์šฑ ๋‹๋ณด์ด๊ฒŒ ํ•˜๋ฉฐ, ์ œํ’ˆ์˜ ์ƒ‰์ƒ๊ณผ ํ…์Šค์ฒ˜๊ฐ€ ์„ ๋ช…ํ•˜๊ฒŒ ํ‘œํ˜„๋ฉ๋‹ˆ๋‹ค. "
403
- elif texture == "๋Œ€๋ฆฌ์„":
404
- prompt += "๊ณ ๊ธ‰์Šค๋Ÿฌ์šด ๋Œ€๋ฆฌ์„ ์งˆ๊ฐ์˜ ํ‘œ๋ฉด์ด ์ œํ’ˆ๊ณผ ์™„๋ฒฝํ•œ ์กฐํ™”๋ฅผ ์ด๋ฃจ๋ฉฐ, ๋Œ€๋ฆฌ์„์˜ ์ž์—ฐ์Šค๋Ÿฌ์šด ํŒจํ„ด์ด ์„ธ๋ จ๋œ ๋ถ„์œ„๊ธฐ๋ฅผ ๋”ํ•ฉ๋‹ˆ๋‹ค. "
405
- elif texture == "๋‚˜๋ฌด":
406
- prompt += "๋”ฐ๋œปํ•œ ๋‚˜๋ฌด ์งˆ๊ฐ์˜ ํ‘œ๋ฉด์ด ์ œํ’ˆ์— ์ž์—ฐ์Šค๋Ÿฌ์šด ๋А๋‚Œ์„ ๋”ํ•˜๋ฉฐ, ๋‚˜๋ฌด์˜ ๊ฒฐ์ด ์ œํ’ˆ๊ณผ ์กฐํ™”๋กญ๊ฒŒ ์–ด์šฐ๋Ÿฌ์ง‘๋‹ˆ๋‹ค. "
407
- elif texture == "๋ฒฝ๋Œ":
408
- prompt += "ํด๋ž˜์‹ํ•œ ๋ฒฝ๋Œ ๋ฐฐ๊ฒฝ์˜ ์งˆ๊ฐ์ด ์ œํ’ˆ์— ๋…ํŠนํ•œ ๋ถ„์œ„๊ธฐ๋ฅผ ๋”ํ•˜๋ฉฐ, ๋ฒฝ๋Œ์˜ ํˆฌ๋ฐ•ํ•œ ๋А๋‚Œ๊ณผ ์ œํ’ˆ์˜ ์„ธ๋ จ๋œ ์™ธ๊ด€์ด ํฅ๋ฏธ๋กœ์šด ๋Œ€๋น„๋ฅผ ์ด๋ฃน๋‹ˆ๋‹ค. "
409
- elif texture == "ํฐ ์ฒœ":
410
- prompt += "๋ถ€๋“œ๋Ÿฌ์šด ํฐ ์ฒœ์ด ๊น”๋ฆฐ ํ‘œ๋ฉด ์œ„์— ์ œํ’ˆ์ด ๋†“์—ฌ์žˆ์–ด ๋ถ€๋“œ๋Ÿฝ๊ณ  ๊นจ๋—ํ•œ ๋А๋‚Œ์„ ๊ฐ•์กฐํ•ฉ๋‹ˆ๋‹ค. "
411
- elif texture == "์‹œ๋ฉ˜ํŠธ":
412
- prompt += "๋ชจ๋˜ํ•œ ์‹œ๋ฉ˜ํŠธ ์งˆ๊ฐ์˜ ํ‘œ๋ฉด์ด, ๋„์‹œ์ ์ด๊ณ  ํ˜„๋Œ€์ ์ธ ๋ถ„์œ„๊ธฐ๋ฅผ ์—ฐ์ถœํ•˜๋ฉฐ ์ œํ’ˆ๊ณผ ๋ฏธ๋‹ˆ๋ฉ€ํ•œ ์กฐํ™”๋ฅผ ์ด๋ฃน๋‹ˆ๋‹ค. "
413
-
414
- # ์ƒ‰๊ฐ ์ถ”๊ฐ€
415
- if color_tone and color_tone != "์„ ํƒ ์•ˆํ•จ":
416
- if color_tone == "ํ™”์ดํŠธ ํ†ค":
417
- prompt += "์ „์ฒด์ ์œผ๋กœ ๊นจ๋—ํ•˜๊ณ  ์ˆœ์ˆ˜ํ•œ ํ™”์ดํŠธ ํ†ค์˜ ์ƒ‰๊ฐ์ด ์ œํ’ˆ์˜ ์„ธ๋ จ๋ฏธ๋ฅผ ๋ถ€๊ฐ์‹œํ‚ค๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. "
418
- elif color_tone == "๋ธ”๋ฃจ ํ†ค":
419
- prompt += "์‹œ์›ํ•˜๊ณ  ์ฐจ๋ถ„ํ•œ ๋ธ”๋ฃจ ํ†ค์˜ ์ƒ‰๊ฐ์ด ์ „์ฒด์ ์ธ ์ด๋ฏธ์ง€์— ํ‰์˜จํ•จ๊ณผ ์‹ ๋ขฐ๊ฐ์„ ๋”ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. "
420
- elif color_tone == "๋”ฐ๋œปํ•œ ์ƒ‰์ƒ":
421
- prompt += "๋”ฐ๋œปํ•˜๊ณ  ํฌ๊ทผํ•œ ์ƒ‰์ƒ ํ†ค์ด ์ „์ฒด ์ด๋ฏธ์ง€์— ์•„๋Š‘ํ•˜๊ณ  ํŽธ์•ˆํ•œ ๋ถ„์œ„๊ธฐ๋ฅผ ๋งŒ๋“ค์–ด๋ƒ…๋‹ˆ๋‹ค. "
422
- elif color_tone == "๋ชจ๋…ธํ†ค":
423
- prompt += "์„ธ๋ จ๋œ ๋ชจ๋…ธํ†ค ์ƒ‰๊ฐ์œผ๋กœ ์ ˆ์ œ๋œ ๋ฏธ๋‹ˆ๋ฉ€ํ•œ ๋ถ„์œ„๊ธฐ๋ฅผ ์—ฐ์ถœํ•˜๋ฉฐ ์ œํ’ˆ์˜ ํ˜•ํƒœ์— ์ง‘์ค‘ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค. "
424
- elif color_tone == "ํŒŒ์Šคํ…”":
425
- prompt += "๋ถ€๋“œ๋Ÿฝ๊ณ  ์€์€ํ•œ ํŒŒ์Šคํ…” ํ†ค์ด ์ „์ฒด์ ์ธ ์ด๋ฏธ์ง€์— ๊ฐ์„ฑ์ ์ด๊ณ  ๋ถ€๋“œ๋Ÿฌ์šด ๋А๋‚Œ์„ ๋”ํ•ฉ๋‹ˆ๋‹ค. "
426
-
427
- # ๋ถ„์œ„๊ธฐ ์ถ”๊ฐ€
428
- if mood and mood != "์„ ํƒ ์•ˆํ•จ":
429
- if mood == "ํฌ๊ทผํ•œ":
430
- prompt += "์ „์ฒด์ ์œผ๋กœ ํฌ๊ทผํ•˜๊ณ  ์•„๋Š‘ํ•œ ๋ถ„์œ„๊ธฐ๊ฐ€ ๋А๊ปด์ง€๋ฉฐ, ํŽธ์•ˆํ•˜๊ณ  ๋”ฐ๋œปํ•œ ๊ฐ์„ฑ์„ ๋ถˆ๋Ÿฌ์ผ์œผํ‚ต๋‹ˆ๋‹ค. "
431
- elif mood == "์‹ฌํ”Œํ•œ":
432
- prompt += "์ „์ฒด์ ์œผ๋กœ ์‹ฌํ”Œํ•˜๊ณ  ๊น”๋”ํ•œ ๋ถ„์œ„๊ธฐ๋กœ, ๋ถˆํ•„์š”ํ•œ ์š”์†Œ ์—†์ด ์ œํ’ˆ ์ž์ฒด์— ์ง‘์ค‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. "
433
- elif mood == "๋ชจ๋˜ํ•œ":
434
- prompt += "ํ˜„๋Œ€์ ์ด๊ณ  ์„ธ๋ จ๋œ ๋ถ„์œ„๊ธฐ๊ฐ€ ์ „์ฒด ์ด๋ฏธ์ง€์— ์Šคํƒ€์ผ๋ฆฌ์‹œํ•œ ๋А๋‚Œ์„ ๋”ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. "
435
- elif mood == "๋‚ด์ถ”๋Ÿด":
436
- prompt += "์ž์—ฐ์Šค๋Ÿฝ๊ณ  ํŽธ์•ˆํ•œ ๋ถ„์œ„๊ธฐ๋กœ, ์ธ์œ„์ ์ธ ์š”์†Œ ์—†์ด ์ œํ’ˆ์ด ํ™˜๊ฒฝ๊ณผ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์กฐํ™”๋ฅผ ์ด๋ฃน๋‹ˆ๋‹ค. "
437
- elif mood == "๋ฏธ๋‹ˆ๋ฉ€":
438
- prompt += "๋ฏธ๋‹ˆ๋ฉ€๋ฆฌ์ฆ˜์˜ ์ •์ œ๋œ ๋ถ„์œ„๊ธฐ๊ฐ€ ๋‹๋ณด์ด๋ฉฐ, ๋‹จ์ˆœํ•จ ์†์˜ ์•„๋ฆ„๋‹ค์›€์„ ๊ฐ•์กฐํ•ฉ๋‹ˆ๋‹ค. "
439
-
440
- # ๋งˆ๋ฌด๋ฆฌ - ์ œํ’ˆ ํŠน์„ฑ ๋ณด์กด ๋ฐ ์ „๋ฌธ์ ์ธ ์‚ฌ์ง„ ํ’ˆ์งˆ ๊ฐ•์กฐ
441
- prompt += f"์›๋ณธ ์ด๋ฏธ์ง€์˜ {product_display} ์ œํ’ˆ ์ž์ฒด๋Š” ์ƒ‰์ƒ, ์งˆ๊ฐ, ๋””์ž์ธ, ๋กœ๊ณ , ํ…์ŠคํŠธ, ๋ฐ˜์‚ฌ๊ด‘ ๋“ฑ ๋ชจ๋“  ๋””ํ…Œ์ผ์ด 100% ๊ทธ๋Œ€๋กœ ๋ณด์กด๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. "
442
-
443
- # ์ œํ’ˆ๊ตฐ๋ณ„ ์ถ”๊ฐ€ ์„ค๋ช…
444
- if product_category == "ํ™”์žฅํ’ˆ":
445
- prompt += "์ œํ’ˆ ํ‘œ๋ฉด์˜ ๊ด‘ํƒ๊ณผ ๋กœ๊ณ ์˜ ๋””ํ…Œ์ผ, ํŒจํ‚ค์ง€์˜ ๋ชจ๋“  ํŠน์„ฑ์ด ์™„๋ฒฝํ•˜๊ฒŒ ์œ ์ง€๋œ ์ฑ„ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋ฐฐ๊ฒฝ๊ณผ ์–ด์šฐ๋Ÿฌ์ ธ ์žˆ์Šต๋‹ˆ๋‹ค. "
446
- elif product_category == "๊ฐ€๋ฐฉ":
447
- prompt += "๊ฐ€๋ฐฉ์˜ ์†Œ์žฌ ์งˆ๊ฐ, ์ƒ‰์ƒ, ๋””์ž์ธ ์š”์†Œ, ๋กœ๊ณ , ๋ฒ„ํด ๋“ฑ์˜ ๋ชจ๋“  ๋””ํ…Œ์ผ์ด ๊ทธ๋Œ€๋กœ ์œ ์ง€๋˜๋ฉฐ, ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋ฐฐ๊ฒฝ๊ณผ ์กฐํ™”๋ฅผ ์ด๋ฃน๋‹ˆ๋‹ค. "
448
- elif product_category == "์•ก์„ธ์„œ๋ฆฌ":
449
- prompt += "์•ก์„ธ์„œ๋ฆฌ์˜ ์„ฌ์„ธํ•œ ๋””ํ…Œ์ผ, ๊ด‘ํƒ, ๋ณด์„, ๊ธˆ์†์˜ ์งˆ๊ฐ ๋“ฑ์ด ๋ชจ๋‘ ๊ทธ๋Œ€๋กœ ๋ณด์กด๋˜๋ฉด์„œ ์ฃผ๋ณ€ ํ™˜๊ฒฝ๊ณผ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์–ด์šฐ๋Ÿฌ์ง‘๋‹ˆ๋‹ค. "
450
- elif product_category == "๋ณด์„๋ฅ˜":
451
- prompt += "๋ณด์„์˜ ๋ฐ˜์ง์ž„, ์ปทํŒ…, ๊ด‘์ฑ„, ์„ธํŒ… ๋“ฑ์˜ ๋ชจ๋“  ์„ฌ์„ธํ•œ ๋””ํ…Œ์ผ์ด ์™„๋ฒฝํ•˜๊ฒŒ ๋ณด์กด๋˜๋ฉด์„œ ๋ฐฐ๊ฒฝ๊ณผ ๊ณ ๊ธ‰์Šค๋Ÿฌ์šด ์กฐํ™”๋ฅผ ์ด๋ฃน๋‹ˆ๋‹ค. "
452
- elif product_category == "ํ™ˆ ๋ฐ์ฝ”":
453
- prompt += "ํ™ˆ ๋ฐ์ฝ” ์ œํ’ˆ์˜ ๋””์ž์ธ ์š”์†Œ, ์งˆ๊ฐ, ๋ฌด๋Šฌ, ์ƒ‰์ƒ ๋“ฑ ๋ชจ๋“  ํŠน์„ฑ์ด ๊ทธ๋Œ€๋กœ ์œ ์ง€๋˜๋ฉด์„œ ์ฃผ๋ณ€ ํ™˜๊ฒฝ๊ณผ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์–ด์šฐ๋Ÿฌ์ง‘๋‹ˆ๋‹ค. "
454
- elif product_category == "์‹ ๋ฐœ":
455
- prompt += "์‹ ๋ฐœ์˜ ์†Œ์žฌ, ๋””์ž์ธ ๋ผ์ธ, ํ…์Šค์ฒ˜, ๋กœ๊ณ , ๋””ํ…Œ์ผ ๋“ฑ์ด ์™„๋ฒฝํ•˜๊ฒŒ ๋ณด์กด๋˜๋ฉด์„œ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋ฐฐ๊ฒฝ๊ณผ ์กฐํ™”๋ฅผ ์ด๋ฃน๋‹ˆ๋‹ค. "
456
- elif product_category == "์˜๋ฅ˜":
457
- prompt += "์˜๋ฅ˜ ์ œํ’ˆ์˜ ์›๋‹จ ์งˆ๊ฐ, ์ƒ‰์ƒ, ํŒจํ„ด, ๋ด‰์ œ์„ , ๋กœ๊ณ  ๋“ฑ์˜ ๋ชจ๋“  ๋””ํ…Œ์ผ์ด ๊ทธ๋Œ€๋กœ ์œ ์ง€๋˜๋ฉด์„œ ์ฃผ๋ณ€ ํ™˜๊ฒฝ๊ณผ ๋ฉ‹์Šค๋Ÿฝ๊ฒŒ ์–ด์šฐ๋Ÿฌ์ง‘๋‹ˆ๋‹ค. "
458
- elif product_category == "์ฃผ๋ฐฉ์šฉํ’ˆ":
459
- prompt += "์ฃผ๋ฐฉ์šฉํ’ˆ์˜ ์žฌ์งˆ๊ฐ, ๋””์ž์ธ ์š”์†Œ, ๊ธฐ๋Šฅ์  ๋””ํ…Œ์ผ ๋“ฑ์ด ๋ชจ๋‘ ๊ทธ๋Œ€๋กœ ๋ณด์กด๋˜๋ฉด์„œ ๋ฐฐ๊ฒฝ๊ณผ ์‹ค์šฉ์ ์ด๋ฉด์„œ๋„ ๋ฏธ์ ์ธ ์กฐํ™”๋ฅผ ์ด๋ฃน๋‹ˆ๋‹ค. "
460
- elif product_category == "์ „์ž๊ธฐ๊ธฐ":
461
- prompt += "์ „์ž๊ธฐ๊ธฐ์˜ ๋””์Šคํ”Œ๋ ˆ์ด, ๋ฒ„ํŠผ, ํฌํŠธ, ๋กœ๊ณ , ํ‘œ๋ฉด ์งˆ๊ฐ ๋“ฑ ๋ชจ๋“  ๋””ํ…Œ์ผ์ด ์™„๋ฒฝํ•˜๊ฒŒ ์œ ์ง€๋˜๋ฉด์„œ ์ฃผ๋ณ€ ํ™˜๊ฒฝ๊ณผ ํ˜„๋Œ€์ ์ธ ์กฐํ™”๋ฅผ ์ด๋ฃน๋‹ˆ๋‹ค. "
462
- else:
463
- prompt += "์ œํ’ˆ์˜ ๋ชจ๋“  ๋””ํ…Œ์ผ๊ณผ ํŠน์„ฑ์ด ๊ทธ๋Œ€๋กœ ์œ ์ง€๋˜๋ฉด์„œ ์ฃผ๋ณ€ ํ™˜๊ฒฝ๊ณผ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์–ด์šฐ๋Ÿฌ์ ธ ์žˆ์Šต๋‹ˆ๋‹ค. "
464
-
465
- # ์ „๋ฌธ์ ์ธ ์‚ฌ์ง„ ํ’ˆ์งˆ ์„ค๋ช… ์ถ”๊ฐ€
466
- prompt += "์ „๋ฌธ ์ƒ์—… ์ œํ’ˆ ์‚ฌ์ง„ ํ’ˆ์งˆ์„ ๊ฐ–์ถ˜ ์ด๋ฏธ์ง€๋กœ, 8K ํ•ด์ƒ๋„, ์™„๋ฒฝํ•œ ์กฐ๋ช…, ์ •ํ™•ํ•œ ์ƒ‰๊ฐ ์žฌํ˜„, ๊ทธ๋ฆฌ๊ณ  ์„ธ๋ จ๋œ ๊ตฌ๋„๋กœ ์ œํ’ˆ์„ ๊ฐ•์กฐํ•ฉ๋‹ˆ๋‹ค. ์นด๋ฉ”๋ผ ์ดˆ์ ์€ ์ œํ’ˆ์— ๋งž์ถฐ์ ธ ์žˆ์œผ๋ฉฐ, ๋ฐฐ๊ฒฝ์€ ์ ์ ˆํ•œ ์‹ฌ๋„๋กœ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋ธ”๋Ÿฌ ์ฒ˜๋ฆฌ๋˜์–ด ์ œํ’ˆ์ด ์ฃผ์ธ๊ณต์œผ๋กœ ๋‹๋ณด์ž…๋‹ˆ๋‹ค."
467
-
468
- return prompt
469
-
470
- # ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ ๋ฐ LLM์— 2์ฐจ ์งˆ๋ฌธ ํ•จ์ˆ˜
471
- def generate_prompt_and_ask_llm(product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood):
472
- # 1์ฐจ ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ
473
- kr_prompt = generate_llm_prompt(product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood)
474
-
475
- # LLM์— 2์ฐจ ์งˆ๋ฌธํ•˜์—ฌ ์ตœ์ข… ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ
476
- final_prompt = ask_llm_for_final_prompt(kr_prompt)
477
-
478
- # ์„ ํƒ ์˜ต์…˜ ์š”์•ฝ
479
- options_summary = f"์ƒํ’ˆ๋ช…: {product_name if product_name else '์ง€์ •๋˜์ง€ ์•Š์Œ'}\n"
480
- options_summary += f"์ œํ’ˆ๊ตฐ: {product_category}\n"
481
- options_summary += f"๋ฐฐ๊ฒฝ ์œ ํ˜•: {background_type}\n"
482
- options_summary += f"์„ธ๋ถ€ ์Šคํƒ€์ผ: {background_style}\n"
483
-
484
- if lighting:
485
- options_summary += f"์กฐ๋ช…: {lighting}\n"
486
- if texture and texture != "์„ ํƒ ์•ˆํ•จ":
487
- options_summary += f"๋ฐฐ๊ฒฝ ์งˆ๊ฐ: {texture}\n"
488
- if color_tone and color_tone != "์„ ํƒ ์•ˆํ•จ":
489
- options_summary += f"์ƒ‰๊ฐ: {color_tone}\n"
490
- if mood and mood != "์„ ํƒ ์•ˆํ•จ":
491
- options_summary += f"๋ถ„์œ„๊ธฐ: {mood}\n"
492
-
493
- return kr_prompt, final_prompt, options_summary
494
-
495
- # ๋ฐฐ๊ฒฝ ์œ ํ˜•์— ๋”ฐ๋ฅธ ์„ธ๋ถ€ ์Šคํƒ€์ผ ์˜ต์…˜ ์—…๋ฐ์ดํŠธ
496
- def update_background_style_options(background_type):
497
- if background_type == "์ž์—ฐ ๋ฐฐ๊ฒฝ":
498
- return gr.update(choices=["์ˆฒ", "ํ•ด๋ณ€", "์‚ฐ", "๋“คํŒ", "๊ณ„๊ณก", "์—ด๋Œ€ ์ •์›", "์‚ฌ๋ง‰", "๋ˆˆ ํ’๊ฒฝ"], value="์ˆฒ")
499
- elif background_type == "์‹ค๋‚ด ๋ฐฐ๊ฒฝ":
500
- return gr.update(choices=["๊ฑฐ์‹ค", "์ฃผ๋ฐฉ", "์„œ์žฌ", "ํ™”์žฅ๋Œ€", "ํ˜ธํ…” ๋กœ๋น„", "์นดํŽ˜", "๋ฏธ๋‹ˆ๋ฉ€ ๊ณต๊ฐ„"], value="๊ฑฐ์‹ค")
501
- elif background_type == "ํŠน์ˆ˜ ๋ฐฐ๊ฒฝ":
502
- return gr.update(choices=["๋„์‹œ ํ’๊ฒฝ", "๋ฃจํ”„ํƒ‘", "ํ•ด์•ˆ๊ฐ€", "๋ชจ๋˜ ์ŠคํŠœ๋””์˜ค", "๋นˆํ‹ฐ์ง€ ๊ณต๊ฐ„", "๋ฏธ๋‹ˆ์–ด์ฒ˜ ๊ณต๊ฐ„"], value="๋„์‹œ ํ’๊ฒฝ")
503
- else:
504
- return gr.update(choices=["์„ ํƒํ•˜์„ธ์š”"], value="์„ ํƒํ•˜์„ธ์š”")
505
 
506
- # ์ธํ„ฐํŽ˜์ด์Šค ๋ถ€๋ถ„ ์ˆ˜์ •
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
507
  with gr.Blocks() as demo:
508
  gr.HTML(
509
  """
510
  <div style="text-align: center; margin-bottom: 1rem;">
511
- <h1>์ด์ปค๋จธ์Šค ์ƒํ’ˆ ์ด๋ฏธ์ง€ ๋ฐฐ๊ฒฝ ์ƒ์„ฑ๊ธฐ</h1>
512
- <p>์ƒํ’ˆ ์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•˜๊ณ  ์›ํ•˜๋Š” ๋ฐฐ๊ฒฝ ์˜ต์…˜์„ ์„ ํƒํ•˜์—ฌ ์ƒˆ๋กœ์šด ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•˜์„ธ์š”.</p>
513
  </div>
514
  """
515
  )
516
 
517
- current_selection = gr.State("")
518
-
519
  with gr.Row():
520
- with gr.Column(scale=1):
521
  with gr.Row():
522
- image1_input = gr.Image(type="pil", label="#1 ์ƒํ’ˆ ์ด๋ฏธ์ง€", image_mode="RGB")
523
- image2_input = gr.Image(type="pil", label="#2 (์„ ํƒ์‚ฌํ•ญ)", image_mode="RGB")
524
- image3_input = gr.Image(type="pil", label="#3 (์„ ํƒ์‚ฌํ•ญ)", image_mode="RGB")
525
-
526
  prompt_input = gr.Textbox(
527
  lines=3,
528
  placeholder="ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜ ๋น„์›Œ๋‘๋ฉด ์ž๋™ ํ•ฉ์„ฑ๋ฉ๋‹ˆ๋‹ค.",
529
  label="ํ”„๋กฌํ”„ํŠธ (์„ ํƒ ์‚ฌํ•ญ)"
530
  )
531
-
532
  with gr.Row():
533
- image_change_btn = gr.Button("์ด๋ฏธ์ง€ ๋ณ€๊ฒฝ", variant="secondary")
534
- text_remove_btn = gr.Button("๊ธ€์ž์ง€์šฐ๊ธฐ", variant="secondary")
535
- clothes_change_btn = gr.Button("์˜ท๋ฐ”๊พธ๊ธฐ", variant="secondary")
536
- background_change_btn = gr.Button("๋ฐฐ๊ฒฝ๋ฐ”๊พธ๊ธฐ", variant="secondary")
537
- composite_product_btn = gr.Button("์ƒํ’ˆํ•ฉ์„ฑ", variant="secondary")
538
-
539
- # ๋ฐฐ๊ฒฝ ๋ณ€๊ฒฝ ๊ด€๋ จ ์„น์…˜ (๊ธฐ๋ณธ์ ์œผ๋กœ ์ˆจ๊น€ ์ƒํƒœ)
540
- with gr.Row(visible=False) as background_header:
541
- gr.HTML("<h3 style='margin-top: 20px; margin-bottom: 10px; width: 100%; text-align: center;'>๋ฐฐ๊ฒฝ ๋ณ€๊ฒฝ ์˜ต์…˜</h3>")
542
-
543
- # ์ƒํ’ˆ๋ช… ์ž…๋ ฅ
544
- product_name = gr.Textbox(
545
- label="์ƒํ’ˆ๋ช… ์ž…๋ ฅ",
546
- placeholder="์ƒํ’ˆ๋ช…์„ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”",
547
- visible=False
548
- )
549
-
550
- # ์ œํ’ˆ๊ตฐ ์นดํ…Œ๊ณ ๋ฆฌ ๋“œ๋กญ๋‹ค์šด
551
- product_category = gr.Dropdown(
552
- choices=["ํ™”์žฅํ’ˆ", "๊ฐ€๋ฐฉ", "์•ก์„ธ์„œ๋ฆฌ", "๋ณด์„๋ฅ˜", "ํ™ˆ ๋ฐ์ฝ”", "์‹ ๋ฐœ", "์˜๋ฅ˜", "์ฃผ๋ฐฉ์šฉํ’ˆ", "์ „์ž๊ธฐ๊ธฐ", "๊ธฐํƒ€"],
553
- label="์ œํ’ˆ๊ตฐ ์„ ํƒ",
554
- value="๊ธฐํƒ€",
555
- visible=False
556
- )
557
-
558
- # ๋ฐฐ๊ฒฝ ์œ ํ˜• ๋“œ๋กญ๋‹ค์šด
559
- background_type = gr.Dropdown(
560
- choices=["์ž์—ฐ ๋ฐฐ๊ฒฝ", "์‹ค๋‚ด ๋ฐฐ๊ฒฝ", "ํŠน์ˆ˜ ๋ฐฐ๊ฒฝ"],
561
- label="๋ฐฐ๊ฒฝ ์œ ํ˜• ์„ ํƒ",
562
- value="์ž์—ฐ ๋ฐฐ๊ฒฝ",
563
- visible=False
564
- )
565
-
566
- # ๋ฐฐ๊ฒฝ ์„ธ๋ถ€ ์Šคํƒ€์ผ ๋“œ๋กญ๋‹ค์šด (๋ฐฐ๊ฒฝ ์œ ํ˜•์— ๋”ฐ๋ผ ๋™์  ๋ณ€๊ฒฝ)
567
- background_style = gr.Dropdown(
568
- choices=["์ˆฒ", "ํ•ด๋ณ€", "์‚ฐ", "๋“คํŒ", "๊ณ„๊ณก", "์—ด๋Œ€ ์ •์›", "์‚ฌ๋ง‰", "๋ˆˆ ํ’๊ฒฝ"],
569
- label="๋ฐฐ๊ฒฝ ์„ธ๋ถ€ ์Šคํƒ€์ผ ์„ ํƒ",
570
- value="์ˆฒ",
571
- visible=False
572
- )
573
-
574
- # ์ถ”๊ฐ€ ์„ ํƒ ์˜ต์…˜ ํ—ค๋”
575
- with gr.Row(visible=False) as additional_header:
576
- gr.HTML("<h4 style='margin-top: 15px; margin-bottom: 10px; width: 100%; text-align: center;'>์ถ”๊ฐ€ ์„ ํƒ ์˜ต์…˜</h4>")
577
-
578
- # ์กฐ๋ช… ๋“œ๋กญ๋‹ค์šด
579
- lighting = gr.Dropdown(
580
- choices=["์ž์—ฐ๊ด‘", "๋”ฐ๋œปํ•œ ์กฐ๋ช…", "๊ทธ๋ฆผ์ž ์žˆ๋Š” ์กฐ๋ช…", "๋ฏธ๋‹ˆ๋ฉ€ ์กฐ๋ช…"],
581
- label="์กฐ๋ช… ์„ ํƒ",
582
- value="์ž์—ฐ๊ด‘",
583
- visible=False
584
- )
585
-
586
- # ๋ฐฐ๊ฒฝ ์งˆ๊ฐ ๋“œ๋กญ๋‹ค์šด
587
- texture = gr.Dropdown(
588
- choices=["์„ ํƒ ์•ˆํ•จ", "ํฐ ๋ฒฝ", "๋Œ€๋ฆฌ์„", "๋‚˜๋ฌด", "๋ฒฝ๋Œ", "ํฐ ์ฒœ", "์‹œ๋ฉ˜ํŠธ"],
589
- label="๋ฐฐ๊ฒฝ ์งˆ๊ฐ ์„ ํƒ",
590
- value="์„ ํƒ ์•ˆํ•จ",
591
- visible=False
592
- )
593
-
594
- # ์ƒ‰๊ฐ ๋“œ๋กญ๋‹ค์šด
595
- color_tone = gr.Dropdown(
596
- choices=["์„ ํƒ ์•ˆํ•จ", "ํ™”์ดํŠธ ํ†ค", "๋ธ”๋ฃจ ํ†ค", "๋”ฐ๋œปํ•œ ์ƒ‰์ƒ", "๋ชจ๋…ธํ†ค", "ํŒŒ์Šคํ…”"],
597
- label="์ƒ‰๊ฐ ์„ ํƒ",
598
- value="์„ ํƒ ์•ˆํ•จ",
599
- visible=False
600
- )
601
-
602
- # ๋ถ„์œ„๊ธฐ ๋“œ๋กญ๋‹ค์šด
603
- mood = gr.Dropdown(
604
- choices=["์„ ํƒ ์•ˆํ•จ", "ํฌ๊ทผํ•œ", "์‹ฌํ”Œํ•œ", "๋ชจ๋˜ํ•œ", "๋‚ด์ถ”๋Ÿด", "๋ฏธ๋‹ˆ๋ฉ€"],
605
- label="๋ถ„์œ„๊ธฐ ์„ ํƒ",
606
- value="์„ ํƒ ์•ˆํ•จ",
607
- visible=False
608
- )
609
-
610
- # ์„ ํƒ ๋‚ด์šฉ ๋ฏธ๋ฆฌ๋ณด๊ธฐ
611
- selection_preview = gr.Textbox(
612
- label="์„ ํƒ ๋‚ด์šฉ ๋ฏธ๋ฆฌ๋ณด๊ธฐ",
613
- lines=8,
614
- visible=False
615
- )
616
-
617
- # ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ ๋ฒ„ํŠผ (๋ฐฐ๊ฒฝ๋ฐ”๊พธ๊ธฐ ์„ ํƒ์‹œ์—๋งŒ ๋‚˜ํƒ€๋‚จ)
618
- prompt_generate_btn = gr.Button("ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ", variant="secondary", visible=False)
619
-
620
- # ์ด๋ฏธ์ง€ ์ƒ์„ฑ ๋ฒ„ํŠผ (ํ•ญ์ƒ ํ‘œ์‹œ)
621
  submit_btn = gr.Button("์ด๋ฏธ์ง€ ์ƒ์„ฑ", variant="primary")
622
-
623
- with gr.Column(scale=1):
624
  output_image = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€")
625
  output_text = gr.Textbox(label="์ƒํƒœ ๋ฉ”์‹œ์ง€")
626
- kr_prompt_display = gr.Textbox(label="์‚ฌ์šฉ๋œ ํ”„๋กฌํ”„ํŠธ (ํ•œ๊ตญ์–ด)", visible=True, lines=4)
627
- prompt_display = gr.Textbox(label="์‚ฌ์šฉ๋œ ํ”„๋กฌํ”„ํŠธ (์˜์–ด)", visible=True, lines=4)
628
- options_summary = gr.Textbox(label="์„ ํƒ๋œ ์˜ต์…˜ ์š”์•ฝ", lines=8, visible=True)
629
-
630
- # ๋ฐฐ๊ฒฝ ๋ณ€๊ฒฝ ๋ฒ„ํŠผ ํด๋ฆญ ์ด๋ฒคํŠธ๋ฅผ ๋” ๊ฐ„๋‹จํ•˜๊ฒŒ ์ˆ˜์ •
631
- def show_background_options():
632
- return ("๋ฐฐ๊ฒฝ ๋ณ€๊ฒฝ", "๋ฐฐ๊ฒฝ๋ฐ”๊พธ๊ธฐ",
633
- gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
634
- gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
635
- gr.update(visible=True), gr.update(visible=True), gr.update(visible=True),
636
- gr.update(visible=True), "", gr.update(visible=True)) # ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ ๋ฒ„ํŠผ ํ‘œ์‹œ
637
-
638
- background_change_btn.click(
639
- fn=show_background_options,
640
- inputs=[],
641
- outputs=[prompt_input, current_selection, background_header, product_name, product_category,
642
- background_type, background_style, additional_header, lighting, texture,
643
- color_tone, mood, selection_preview, prompt_generate_btn]
644
- )
645
-
646
- # ๋‹ค๋ฅธ ๊ธฐ๋Šฅ ๋ฒ„ํŠผ๋“ค๋„ ๊ฐ„๋‹จํ•œ ๋ฐฉ์‹์œผ๋กœ ์ˆ˜์ •
647
- def hide_background_options(prompt_value):
648
- return (prompt_value, "๊ธฐํƒ€",
649
- gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
650
- gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
651
- gr.update(visible=False), gr.update(visible=False), gr.update(visible=False),
652
- gr.update(visible=False), "", gr.update(visible=False)) # ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ ๋ฒ„ํŠผ ์ˆจ๊น€
653
 
 
654
  image_change_btn.click(
655
- fn=lambda: hide_background_options("#1 ์ด๋ฏธ์ง€์˜ [๋‹ค๋ฅธ ๋ชจ์Šต]์œผ๋กœ ๋ณ€๊ฒฝํ•˜๋ผ."),
656
  inputs=[],
657
- outputs=[prompt_input, current_selection, background_header, product_name, product_category,
658
- background_type, background_style, additional_header, lighting, texture,
659
- color_tone, mood, selection_preview, prompt_generate_btn]
660
  )
661
-
662
  text_remove_btn.click(
663
- fn=lambda: hide_background_options("#1 ์ด๋ฏธ์ง€์˜ [์ค‘๊ตญ์–ด๋ฅผ ๋ชจ๋‘]๋ฅผ ์ œ๊ฑฐํ•˜๋ผ."),
664
  inputs=[],
665
- outputs=[prompt_input, current_selection, background_header, product_name, product_category,
666
- background_type, background_style, additional_header, lighting, texture,
667
- color_tone, mood, selection_preview, prompt_generate_btn]
668
  )
669
-
670
  clothes_change_btn.click(
671
- fn=lambda: hide_background_options("#1์ด๋ฏธ์ง€์—์„œ [์‹ ์ฒด ๋น„์œจ๊ณผ ํฌ์ฆˆ๋Š” ์œ ์ง€ํ•œ ์ฒด] ์˜์ƒ[์Šคํƒ€์ผ๊ณผ ์ƒ‰์ƒ์„]#2, #3์œผ๋กœ ๋ณ€๊ฒฝํ•ด์ฃผ์„ธ์š”."),
672
  inputs=[],
673
- outputs=[prompt_input, current_selection, background_header, product_name, product_category,
674
- background_type, background_style, additional_header, lighting, texture,
675
- color_tone, mood, selection_preview, prompt_generate_btn]
676
  )
677
-
678
- composite_product_btn.click(
679
- fn=lambda: hide_background_options("์ด๋ฏธ์ง€ #1์˜ ๋ชจ๋ธ์ด ํ•„์š”์— ๋”ฐ๋ผ ์ž์„ธ๋‚˜ ํ‘œ์ •์„ ์œ ๋™์ ์œผ๋กœ ๋ณ€ํ˜•ํ•œ ํ›„, ์ด๋ฏธ์ง€ #2(๋˜๋Š” #3)์˜ ์ƒํ’ˆ์„ ์ตœ๋Œ€ํ•œ ์›๋ž˜ ํ˜•ํƒœ์™€ ๋””ํ…Œ์ผ์„ ์œ ์ง€ํ•˜๋ฉด์„œ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์ฐฉ์šฉํ•œ ๋ชจ์Šต์„ ํ•ฉ์„ฑํ•˜๋ผ."),
680
  inputs=[],
681
- outputs=[prompt_input, current_selection, background_header, product_name, product_category,
682
- background_type, background_style, additional_header, lighting, texture,
683
- color_tone, mood, selection_preview, prompt_generate_btn]
684
- )
685
-
686
- # ์„ ํƒ ์˜ต์…˜ ๋ณ€๊ฒฝ ์‹œ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์™€ LLM ํ”„๋กฌํ”„ํŠธ ์—…๋ฐ์ดํŠธ
687
- def update_all_previews(product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood):
688
- llm_prompt = generate_llm_prompt(product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood)
689
-
690
- preview = f"์ƒํ’ˆ๋ช…: {product_name}\n"
691
- preview += f"์ œํ’ˆ๊ตฐ: {product_category}\n"
692
- preview += f"๋ฐฐ๊ฒฝ ์œ ํ˜•: {background_type}\n"
693
- preview += f"์„ธ๋ถ€ ์Šคํƒ€์ผ: {background_style}\n"
694
-
695
- if lighting:
696
- preview += f"์กฐ๋ช…: {lighting}\n"
697
- if texture and texture != "์„ ํƒ ์•ˆํ•จ":
698
- preview += f"๋ฐฐ๊ฒฝ ์งˆ๊ฐ: {texture}\n"
699
- if color_tone and color_tone != "์„ ํƒ ์•ˆํ•จ":
700
- preview += f"์ƒ‰๊ฐ: {color_tone}\n"
701
- if mood and mood != "์„ ํƒ ์•ˆํ•จ":
702
- preview += f"๋ถ„์œ„๊ธฐ: {mood}\n"
703
-
704
- preview += f"\n์ƒ์„ฑ๋  ํ”„๋กฌํ”„ํŠธ ๋ฏธ๋ฆฌ๋ณด๊ธฐ:\n{llm_prompt}"
705
-
706
- return preview
707
-
708
- # ๋ฐฐ๊ฒฝ ์œ ํ˜•์— ๋”ฐ๋ผ ์„ธ๋ถ€ ์Šคํƒ€์ผ ์˜ต์…˜ ์—…๋ฐ์ดํŠธ (๋จผ์ € ์ˆ˜ํ–‰)
709
- background_type.change(
710
- fn=update_background_style_options,
711
- inputs=[background_type],
712
- outputs=[background_style]
713
- ).then(
714
- fn=update_all_previews,
715
- inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
716
- outputs=[selection_preview]
717
- )
718
-
719
- # ๋ชจ๋“  ์„ ํƒ ์ปดํฌ๋„ŒํŠธ์˜ ๋ณ€๊ฒฝ ์ด๋ฒคํŠธ์— ์—ฐ๊ฒฐ
720
- product_name.change(
721
- fn=update_all_previews,
722
- inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
723
- outputs=[selection_preview]
724
- )
725
-
726
- product_category.change(
727
- fn=update_all_previews,
728
- inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
729
- outputs=[selection_preview]
730
- )
731
-
732
- background_style.change(
733
- fn=update_all_previews,
734
- inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
735
- outputs=[selection_preview]
736
  )
737
-
738
- lighting.change(
739
- fn=update_all_previews,
740
- inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
741
- outputs=[selection_preview]
742
- )
743
-
744
- texture.change(
745
- fn=update_all_previews,
746
- inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
747
- outputs=[selection_preview]
748
- )
749
-
750
- color_tone.change(
751
- fn=update_all_previews,
752
- inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
753
- outputs=[selection_preview]
754
- )
755
-
756
- mood.change(
757
- fn=update_all_previews,
758
- inputs=[product_name, product_category, background_type, background_style, lighting, texture, color_tone, mood],
759
- outputs=[selection_preview]
760
- )
761
-
762
- # ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ ๋ฒ„ํŠผ ํด๋ฆญ ์ด๋ฒคํŠธ
763
- prompt_generate_btn.click(
764
- fn=generate_prompt_and_ask_llm,
765
- inputs=[product_name, product_category, background_type, background_style,
766
- lighting, texture, color_tone, mood],
767
- outputs=[kr_prompt_display, prompt_input, options_summary]
768
  )
769
 
770
- # ์ด๋ฏธ์ง€ ์ƒ์„ฑ ๋ฒ„ํŠผ ํด๋ฆญ ์ด๋ฒคํŠธ (์›๋ž˜ ๊ธฐ๋Šฅ ๋ณต์›)
771
  submit_btn.click(
772
- fn=process_images_with_prompt,
773
  inputs=[image1_input, image2_input, image3_input, prompt_input],
774
  outputs=[output_image, output_text, prompt_display],
775
  )
@@ -778,17 +306,13 @@ with gr.Blocks() as demo:
778
  """
779
  ### ์‚ฌ์šฉ ๋ฐฉ๋ฒ•:
780
 
781
- 1. ์ƒํ’ˆ ์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•˜์„ธ์š” (#1 ์ด๋ฏธ์ง€).
782
- 2. "๋ฐฐ๊ฒฝ๋ฐ”๊พธ๊ธฐ" ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด ๋ฐฐ๊ฒฝ ๋ณ€๊ฒฝ ์˜ต์…˜์ด ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค.
783
- 3. ์ƒํ’ˆ๋ช…์„ ์ž…๋ ฅํ•˜๊ณ  ์ œํ’ˆ๊ตฐ, ๋ฐฐ๊ฒฝ ์œ ํ˜•, ๋ฐฐ๊ฒฝ ์„ธ๋ถ€ ์Šคํƒ€์ผ์„ ์„ ํƒํ•˜์„ธ์š”.
784
- 4. ์ถ”๊ฐ€ ์˜ต์…˜(์กฐ๋ช…, ์งˆ๊ฐ, ์ƒ‰๊ฐ, ๋ถ„์œ„๊ธฐ)์„ ์„ ํƒํ•˜๋ฉด ๋” ์„ธ๋ฐ€ํ•œ ๋ฐฐ๊ฒฝ์„ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
785
- 5. "ํ”„๋กฌํ”„ํŠธ ์ƒ์„ฑ" ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด LLM ์Šคํƒ€์ผ ํ”„๋กฌํ”„ํŠธ๊ฐ€ ์ƒ์„ฑ๋˜๊ณ , ์ด๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ์ด๋ฏธ์ง€ ์ƒ์„ฑ์šฉ ํ”„๋กฌํ”„ํŠธ๊ฐ€ ์ž๋™์œผ๋กœ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.
786
- 6. "์ด๋ฏธ์ง€ ์ƒ์„ฑ" ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด ์ƒ์„ฑ๋œ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ด๋ฏธ์ง€๊ฐ€ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.
787
- 7. ํ”„๋กฌํ”„ํŠธ ์ž…๋ ฅ๋ž€์— ์ง์ ‘ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
788
 
789
- > **ํŒ**: ์„ ํƒ ๋‚ด์šฉ ๋ฏธ๋ฆฌ๋ณด๊ธฐ์—์„œ ์ƒ์„ฑ๋  ํ”„๋กฌํ”„ํŠธ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
790
  """
791
  )
792
-
793
  if __name__ == "__main__":
794
  demo.launch(share=True)
 
61
  logger.exception("๋ฒˆ์—ญ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ:")
62
  return prompt
63
 
64
+ def preprocess_prompt(prompt, image1, image2, image3):
65
  """
66
  ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ณ  ๊ธฐ๋Šฅ ๋ช…๋ น์„ ํ•ด์„
67
  """
 
103
  elif "4. ์˜ท๋ฐ”๊พธ๊ธฐ" in prompt:
104
  prompt = "์ฒซ ๋ฒˆ์งธ ์ด๋ฏธ์ง€์˜ ์ธ๋ฌผ ์˜์ƒ์„ ๋‘ ๋ฒˆ์งธ ์ด๋ฏธ์ง€์˜ ์˜์ƒ์œผ๋กœ ๋ณ€๊ฒฝํ•ด์ฃผ์„ธ์š”. ์˜์ƒ์˜ ์Šคํƒ€์ผ๊ณผ ์ƒ‰์ƒ์€ ๋‘ ๋ฒˆ์งธ ์ด๋ฏธ์ง€๋ฅผ ๋”ฐ๋ฅด๋˜, ์‹ ์ฒด ๋น„์œจ๊ณผ ํฌ์ฆˆ๋Š” ์ฒซ ๋ฒˆ์งธ ์ด๋ฏธ์ง€๋ฅผ ์œ ์ง€ํ•ด์ฃผ์„ธ์š”."
105
 
106
+ elif "5. ๋ฐฐ๊ฒฝ๋ฐ”๊พธ๊ธฐ" in prompt:
107
+ prompt = "์ฒซ ๋ฒˆ์งธ ์ด๋ฏธ์ง€์˜ ๋ฐฐ๊ฒฝ์„ ๋‘ ๋ฒˆ์งธ ์ด๋ฏธ์ง€์˜ ๋ฐฐ๊ฒฝ์œผ๋กœ ๋ณ€๊ฒฝํ•ด์ฃผ์„ธ์š”. ์ฒซ ๋ฒˆ์งธ ์ด๋ฏธ์ง€์˜ ์ฃผ์š” ํ”ผ์‚ฌ์ฒด๋Š” ์œ ์ง€ํ•˜๊ณ , ๋‘ ๋ฒˆ์งธ ์ด๋ฏธ์ง€์˜ ๋ฐฐ๊ฒฝ๊ณผ ์กฐํ™”๋กญ๊ฒŒ ํ•ฉ์„ฑํ•ด์ฃผ์„ธ์š”."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
+ elif "6. ์ด๋ฏธ์ง€ ํ•ฉ์„ฑ(์ƒํ’ˆํฌํ•จ)" in prompt:
110
+ prompt = "์ฒซ ๋ฒˆ์งธ ์ด๋ฏธ์ง€์™€ ๋‘ ๋ฒˆ์งธ ์ด๋ฏธ์ง€(๋˜๋Š” ์„ธ ๋ฒˆ์งธ ์ด๋ฏธ์ง€)๋ฅผ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ํ•ฉ์„ฑํ•ด์ฃผ์„ธ์š”. ๋ชจ๋“  ์ด๋ฏธ์ง€์˜ ์ฃผ์š” ์š”์†Œ๋ฅผ ํฌํ•จํ•˜๊ณ , ํŠนํžˆ ์ƒํ’ˆ์ด ๋‹๋ณด์ด๋„๋ก ์กฐํ™”๋กญ๊ฒŒ ํ†ตํ•ฉํ•ด์ฃผ์„ธ์š”."
111
 
112
  prompt += " ์ด๋ฏธ์ง€๋ฅผ ์ƒ์„ฑํ•ด์ฃผ์„ธ์š”."
113
  return prompt
 
164
  logger.exception("์ด๋ฏธ์ง€ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ:")
165
  return None, f"์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}"
166
 
167
+ def process_images_with_prompt(image1, image2, image3, prompt):
168
  """
169
  3๊ฐœ์˜ ์ด๋ฏธ์ง€์™€ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•˜์—ฌ ์ตœ์ข… ์˜์–ด ํ”„๋กฌํ”„ํŠธ(final_prompt)๋ฅผ ์ƒ์„ฑํ•œ ํ›„,
170
  API๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ๊ฒฐ๊ณผ ์ด๋ฏธ์ง€๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
 
176
  return None, "์ ์–ด๋„ ํ•˜๋‚˜์˜ ์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•ด์ฃผ์„ธ์š”.", ""
177
 
178
  if prompt and prompt.strip():
179
+ processed_prompt = preprocess_prompt(prompt, image1, image2, image3)
180
  if re.search("[๊ฐ€-ํžฃ]", processed_prompt):
181
  final_prompt = translate_prompt_to_english(processed_prompt)
182
  else:
 
198
  logger.exception("์ด๋ฏธ์ง€ ์ฒ˜๋ฆฌ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ:")
199
  return None, f"์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}", prompt
200
 
201
+ def process_and_show_prompt(image1, image2, image3, prompt):
 
 
 
 
202
  try:
203
+ result_img, status, final_prompt = process_images_with_prompt(image1, image2, image3, prompt)
204
+ return result_img, status, final_prompt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  except Exception as e:
206
+ logger.exception("์ฒ˜๋ฆฌ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ:")
207
+ return None, f"์˜ค๋ฅ˜ ๋ฐœ์ƒ: {str(e)}", prompt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
 
209
+ # ์˜ˆ์ œ ์‹คํ–‰ ํ•จ์ˆ˜๋“ค
210
+ def run_example_1():
211
+ """์˜ˆ์ œ 1: ์ด๋ฏธ์ง€ ๋ณ€๊ฒฝ ์˜ˆ์ œ"""
212
+ input_path = os.path.join("down", "1_in-1.png")
213
+ output_path = os.path.join("down", "1_out-1.webp")
214
+ try:
215
+ input_img = Image.open(input_path)
216
+ except Exception as e:
217
+ return None, f"์ž…๋ ฅ ์ด๋ฏธ์ง€ ์—ด๊ธฐ ์˜ค๋ฅ˜: {str(e)}", ""
218
+ prompt = "#1 ์ด๋ฏธ์ง€์˜ [์ฒญ์ƒ‰ ์ƒ์–ด๋ ˆ๊ณ ๋ฅผ ๊ฒ€์€ ๊ณ ๋ž˜๋ ˆ๊ณ ]์œผ๋กœ ๋ณ€๊ฒฝํ•˜๋ผ."
219
+ result_img, status, final_prompt = process_and_show_prompt(input_img, None, None, prompt)
220
+ if result_img is not None:
221
+ result_img.save(output_path, "WEBP")
222
+ return result_img, status, final_prompt
223
+
224
+ def run_example_2():
225
+ """์˜ˆ์ œ 2: ๊ธ€์ž์ง€์šฐ๊ธฐ ์˜ˆ์ œ"""
226
+ input_path = os.path.join("down", "2_in-1.png")
227
+ output_path = os.path.join("down", "2_out-1.webp")
228
+ try:
229
+ input_img = Image.open(input_path)
230
+ except Exception as e:
231
+ return None, f"์ž…๋ ฅ ์ด๋ฏธ์ง€ ์—ด๊ธฐ ์˜ค๋ฅ˜: {str(e)}", ""
232
+ prompt = "#1 ์ด๋ฏธ์ง€์˜ [์ค‘๊ตญ์–ด๋ฅผ ๋ชจ๋‘]๋ฅผ ์ œ๊ฑฐํ•˜๋ผ."
233
+ result_img, status, final_prompt = process_and_show_prompt(input_img, None, None, prompt)
234
+ if result_img is not None:
235
+ result_img.save(output_path, "WEBP")
236
+ return result_img, status, final_prompt
237
+
238
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค
239
  with gr.Blocks() as demo:
240
  gr.HTML(
241
  """
242
  <div style="text-align: center; margin-bottom: 1rem;">
243
+ <h1>๊ฐ„๋‹จํ•œ ์ด๋ฏธ์ง€ ์ƒ์„ฑ๊ธฐ (์˜ˆ์ œ ํฌํ•จ)</h1>
244
+ <p>์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•˜๊ฑฐ๋‚˜ ์•„๋ž˜ ์˜ˆ์ œ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด ์ฒ˜๋ฆฌ๋œ ๊ฒฐ๊ณผ๊ฐ€ down ํด๋”์— ์ €์žฅ๋ฉ๋‹ˆ๋‹ค.</p>
245
  </div>
246
  """
247
  )
248
 
 
 
249
  with gr.Row():
250
+ with gr.Column():
251
  with gr.Row():
252
+ image1_input = gr.Image(type="pil", label="#1", image_mode="RGB")
253
+ image2_input = gr.Image(type="pil", label="#2", image_mode="RGB")
254
+ image3_input = gr.Image(type="pil", label="#3", image_mode="RGB")
 
255
  prompt_input = gr.Textbox(
256
  lines=3,
257
  placeholder="ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜ ๋น„์›Œ๋‘๋ฉด ์ž๋™ ํ•ฉ์„ฑ๋ฉ๋‹ˆ๋‹ค.",
258
  label="ํ”„๋กฌํ”„ํŠธ (์„ ํƒ ์‚ฌํ•ญ)"
259
  )
 
260
  with gr.Row():
261
+ image_change_btn = gr.Button("์ด๋ฏธ์ง€ ๋ณ€๊ฒฝ")
262
+ text_remove_btn = gr.Button("๊ธ€์ž์ง€์šฐ๊ธฐ")
263
+ clothes_change_btn = gr.Button("์˜ท๋ฐ”๊พธ๊ธฐ")
264
+ background_change_btn = gr.Button("๋ฐฐ๊ฒฝ๋ฐ”๊พธ๊ธฐ")
265
+ composite_product_btn = gr.Button("์ด๋ฏธ์ง€ ํ•ฉ์„ฑ(์ƒํ’ˆํฌํ•จ)")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  submit_btn = gr.Button("์ด๋ฏธ์ง€ ์ƒ์„ฑ", variant="primary")
267
+ with gr.Column():
 
268
  output_image = gr.Image(label="์ƒ์„ฑ๋œ ์ด๋ฏธ์ง€")
269
  output_text = gr.Textbox(label="์ƒํƒœ ๋ฉ”์‹œ์ง€")
270
+ prompt_display = gr.Textbox(label="์‚ฌ์šฉ๋œ ํ”„๋กฌํ”„ํŠธ (์˜์–ด)", visible=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
 
272
+ # ์„ ํƒ ์˜ต์…˜ ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ํ”„๋กฌํ”„ํŠธ ์ž…๋ ฅ๋ž€ ์—…๋ฐ์ดํŠธ (ํ•œ๊ตญ์–ด ๋ฌธ๊ตฌ)
273
  image_change_btn.click(
274
+ fn=lambda: "#1 ์ด๋ฏธ์ง€์˜ [๋‹ค๋ฅธ ๋ชจ์Šต]์œผ๋กœ ๋ณ€๊ฒฝํ•˜๋ผ.",
275
  inputs=[],
276
+ outputs=prompt_input
 
 
277
  )
 
278
  text_remove_btn.click(
279
+ fn=lambda: "#1 ์ด๋ฏธ์ง€์˜ [์ค‘๊ตญ์–ด๋ฅผ ๋ชจ๋‘]๋ฅผ ์ œ๊ฑฐํ•˜๋ผ.",
280
  inputs=[],
281
+ outputs=prompt_input
 
 
282
  )
 
283
  clothes_change_btn.click(
284
+ fn=lambda: "#1์ด๋ฏธ์ง€์—์„œ [์‹ ์ฒด ๋น„์œจ๊ณผ ํฌ์ฆˆ๋Š” ์œ ์ง€ํ•œ ์ฒด] ์˜์ƒ[์Šคํƒ€์ผ๊ณผ ์ƒ‰์ƒ์„]#2, #3์œผ๋กœ ๋ณ€๊ฒฝํ•ด์ฃผ์„ธ์š”.",
285
  inputs=[],
286
+ outputs=prompt_input
 
 
287
  )
288
+ background_change_btn.click(
289
+ fn=lambda: "#1 ์ด๋ฏธ์ง€์˜ ๋ฐฐ๊ฒฝ์„ #2 ์ด๋ฏธ์ง€์˜ ๋ฐฐ๊ฒฝ์œผ๋กœ ๋ณ€๊ฒฝํ•˜๋ผ.",
 
290
  inputs=[],
291
+ outputs=prompt_input
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
292
  )
293
+ composite_product_btn.click(
294
+ fn=lambda: "#1 ์ด๋ฏธ์ง€์™€ #2 ์ด๋ฏธ์ง€(๋˜๋Š” #3 ์ด๋ฏธ์ง€)๋ฅผ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ํ•ฉ์„ฑํ•˜๋ผ.",
295
+ inputs=[],
296
+ outputs=prompt_input
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  )
298
 
 
299
  submit_btn.click(
300
+ fn=process_and_show_prompt,
301
  inputs=[image1_input, image2_input, image3_input, prompt_input],
302
  outputs=[output_image, output_text, prompt_display],
303
  )
 
306
  """
307
  ### ์‚ฌ์šฉ ๋ฐฉ๋ฒ•:
308
 
309
+ 1. **์ž๋™ ํ•ฉ์„ฑ**: ์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•˜๊ณ  ํ”„๋กฌํ”„ํŠธ๋ฅผ ๋น„์›Œ๋‘๋ฉด ์ž๋™์œผ๋กœ ํ•ฉ์„ฑ๋ฉ๋‹ˆ๋‹ค.
310
+ 2. **์ด๋ฏธ์ง€ ์ฐธ์กฐ**: #1, #2, #3์œผ๋กœ ๊ฐ ์ด๋ฏธ์ง€๋ฅผ ์ฐธ์กฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
311
+ 3. **์„ ํƒ ์˜ต์…˜**: ์œ„์˜ ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜๋ฉด ํ”„๋กฌํ”„ํŠธ ์ž…๋ ฅ๋ž€์— ํ•œ๊ตญ์–ด ๋ฌธ๊ตฌ๋กœ ์ž…๋ ฅํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.
 
 
 
 
312
 
313
+ > **ํŒ**: ํ”„๋กฌํ”„ํŠธ๋ฅผ ์ง์ ‘ ์ˆ˜์ •ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
314
  """
315
  )
316
+
317
  if __name__ == "__main__":
318
  demo.launch(share=True)