Update app.py
Browse files
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
|
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
|
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 "
|
136 |
-
prompt = "
|
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
|
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
|
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
|
228 |
-
"""
|
229 |
-
LLM์ 2์ฐจ ์ง๋ฌธํ์ฌ ๋ ์์ฐ์ค๋ฌ์ด ์ด๋ฏธ์ง ์์ฑ ํ๋กฌํํธ๋ฅผ ์ป๋ ํจ์
|
230 |
-
์ค์ ๊ตฌํ์์๋ LLM API๋ฅผ ํธ์ถํด์ผ ํจ
|
231 |
-
"""
|
232 |
try:
|
233 |
-
|
234 |
-
|
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("
|
302 |
-
return f"
|
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
|
512 |
-
<p
|
513 |
</div>
|
514 |
"""
|
515 |
)
|
516 |
|
517 |
-
current_selection = gr.State("")
|
518 |
-
|
519 |
with gr.Row():
|
520 |
-
with gr.Column(
|
521 |
with gr.Row():
|
522 |
-
image1_input = gr.Image(type="pil", label="#1
|
523 |
-
image2_input = gr.Image(type="pil", label="#2
|
524 |
-
image3_input = gr.Image(type="pil", label="#3
|
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("์ด๋ฏธ์ง ๋ณ๊ฒฝ"
|
534 |
-
text_remove_btn = gr.Button("๊ธ์์ง์ฐ๊ธฐ"
|
535 |
-
clothes_change_btn = gr.Button("์ท๋ฐ๊พธ๊ธฐ"
|
536 |
-
background_change_btn = gr.Button("๋ฐฐ๊ฒฝ๋ฐ๊พธ๊ธฐ"
|
537 |
-
composite_product_btn = gr.Button("
|
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 |
-
|
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:
|
656 |
inputs=[],
|
657 |
-
outputs=
|
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:
|
664 |
inputs=[],
|
665 |
-
outputs=
|
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:
|
672 |
inputs=[],
|
673 |
-
outputs=
|
674 |
-
background_type, background_style, additional_header, lighting, texture,
|
675 |
-
color_tone, mood, selection_preview, prompt_generate_btn]
|
676 |
)
|
677 |
-
|
678 |
-
|
679 |
-
fn=lambda: hide_background_options("์ด๋ฏธ์ง #1์ ๋ชจ๋ธ์ด ํ์์ ๋ฐ๋ผ ์์ธ๋ ํ์ ์ ์ ๋์ ์ผ๋ก ๋ณํํ ํ, ์ด๋ฏธ์ง #2(๋๋ #3)์ ์ํ์ ์ต๋ํ ์๋ ํํ์ ๋ํ
์ผ์ ์ ์งํ๋ฉด์ ์์ฐ์ค๋ฝ๊ฒ ์ฐฉ์ฉํ ๋ชจ์ต์ ํฉ์ฑํ๋ผ."),
|
680 |
inputs=[],
|
681 |
-
outputs=
|
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 |
-
|
739 |
-
|
740 |
-
|
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=
|
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.
|
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)
|