Update app.py
Browse files
app.py
CHANGED
@@ -268,14 +268,41 @@ def process_images_with_prompt(image1, prompt, variation_index=0, max_retries=3)
|
|
268 |
|
269 |
# ------------------- ν둬ννΈ κ΄λ ¨ ν¨μ -------------------
|
270 |
def filter_prompt_only(prompt):
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
return prompt.strip()
|
280 |
|
281 |
def get_selected_background_info(bg_type, simple, studio, nature, indoor, tech, colorful, abstract):
|
@@ -338,22 +365,14 @@ def generate_enhanced_system_instruction():
|
|
338 |
λ€μ κ°μ΄λλΌμΈμ λ°λμ μ€μν΄μΌ ν©λλ€:
|
339 |
|
340 |
1. μνμ "#1"λ‘ μ§μ νμ¬ μ°Έμ‘°ν©λλ€. (μ: "skincare tube (#1)")
|
341 |
-
|
342 |
2. *** λ§€μ° μ€μ: μνμ μλ νΉμ±(λμμΈ, μμ, νν, λ‘κ³ , ν¨ν€μ§ λ±)μ μ΄λ€ μν©μμλ μ λ λ³κ²½νμ§ μμ΅λλ€. ***
|
343 |
-
|
344 |
3. *** μνμ λ³Έμ§μ νΉμ±μ μ μ§νλ, μνμ ν¬μ»€μ€λ₯Ό λ§μΆ° λͺ¨λ μΈλΆ μ¬νμ΄ μ λͺ
νκ² λλ¬λλλ‘ νλ©°,
|
345 |
8K ν΄μλ(8K resolution), μ€λ²μ€νλ μλ μ΄κ³ νμ§(ultra high definition without oversharpening)λ‘ λ λλ§λμ΄μΌ ν©λλ€. ***
|
346 |
-
|
347 |
4. μ΄λ―Έμ§ λΉμ¨μ μ νν 1:1(μ μ¬κ°ν) νμμΌλ‘ μ§μ ν©λλ€. ν둬ννΈμ "square format", "1:1 ratio" λλ "aspect ratio 1:1"μ λͺ
μμ μΌλ‘ ν¬ν¨ν©λλ€.
|
348 |
-
|
349 |
5. μνμ λ°λμ μ μ¬κ°ν ꡬλμ μ μ€μμ λ°°μΉλμ΄μΌ νλ©°, μ μ ν ν¬κΈ°λ‘ νννμ¬ λν
μΌμ΄ μλ²½νκ² λ³΄μ΄λλ‘ ν©λλ€.
|
350 |
-
|
351 |
6. μνμ μ΄λ―Έμ§μ μ£Όμ μ΄μ μΌλ‘ λΆκ°μν€κ³ , μνμ λΉμ¨μ΄ μ 체 μ΄λ―Έμ§μμ 60-70% μ΄μ μ°¨μ§νλλ‘ ν©λλ€.
|
352 |
-
|
353 |
7. μ‘°λͺ
μ€λͺ
μ λ§€μ° κ΅¬μ²΄μ μΌλ‘ ν΄μ£ΌμΈμ. μ: "soft directional lighting from left side", "dramatic rim lighting", "diffused natural light through windows"
|
354 |
-
|
355 |
8. λ°°κ²½μ μ¬μ§κ³Ό μ§κ°μ μμΈν μ€λͺ
ν΄μ£ΌμΈμ. μ: "polished marble surface", "rustic wooden table with visible grain", "matte concrete wall with subtle texture"
|
356 |
-
|
357 |
9. ν둬ννΈμ λ€μ μμλ€μ λͺ
μμ μΌλ‘ ν¬ν¨νλ, μ¬μ© λ§₯λ½μ μ μ νκ² λ³ννμΈμ:
|
358 |
- "award-winning product photography"
|
359 |
- "magazine-worthy commercial product shot"
|
@@ -363,10 +382,9 @@ def generate_enhanced_system_instruction():
|
|
363 |
- "commercial product photography with precise detail rendering"
|
364 |
- "ultra high definition"
|
365 |
- "crystal clear details"
|
366 |
-
|
367 |
10. μ¬μ©μκ° μ 곡ν ꡬ체μ μΈ λ°°κ²½κ³Ό μΆκ° μμ²μ¬νμ ν둬ννΈμ μ νν λ°μνκ³ νμ₯ν©λλ€.
|
368 |
-
|
369 |
11. ν둬ννΈ λμ "--ar 1:1 --s 750 --q 2 --v 5.2" νλΌλ―Έν°λ₯Ό μΆκ°νμ¬ λ―Έλμ λμμ κ³ νμ§ μ μ¬κ°ν λΉμ¨μ κ°μ ν©λλ€.
|
|
|
370 |
"""
|
371 |
|
372 |
def generate_prompt_with_gemini(product_name, background_info, additional_info=""):
|
|
|
268 |
|
269 |
# ------------------- ν둬ννΈ κ΄λ ¨ ν¨μ -------------------
|
270 |
def filter_prompt_only(prompt):
|
271 |
+
"""Geminiμ μ€λͺ
λ° λΆνμν λ©μμ§λ₯Ό μ κ±°νκ³ μ€μ ν둬ννΈλ§ μΆμΆνλ ν¨μ"""
|
272 |
+
|
273 |
+
# μ½λ λΈλ‘ λ΄λΆμ ν둬ννΈ μ°ΎκΈ°
|
274 |
+
code_block_pattern = r"```\s*(.*?)```"
|
275 |
+
code_match = re.search(code_block_pattern, prompt, re.DOTALL)
|
276 |
+
if code_match:
|
277 |
+
return code_match.group(1).strip()
|
278 |
+
|
279 |
+
# Midjourney νλΌλ―Έν°λ₯Ό ν¬ν¨νλ ν둬ννΈ λΆλΆ μ°ΎκΈ°
|
280 |
+
if "--ar 1:1" in prompt:
|
281 |
+
lines = prompt.split('\n')
|
282 |
+
prompt_lines = []
|
283 |
+
in_prompt = False
|
284 |
+
|
285 |
+
for line in lines:
|
286 |
+
# ν둬ννΈ μμ λΆλΆ μΈμ (μΌλ°μ μΈ μ ν μ€λͺ
μ΄λ 'Magazine-worthy' κ°μ ν€μλλ‘ μμ)
|
287 |
+
if (not in_prompt and
|
288 |
+
("product" in line.lower() or
|
289 |
+
"magazine" in line.lower() or
|
290 |
+
"commercial" in line.lower() or
|
291 |
+
"photography" in line.lower())):
|
292 |
+
in_prompt = True
|
293 |
+
prompt_lines.append(line)
|
294 |
+
# μ΄λ―Έ ν둬ννΈ μμμ μλ κ²½μ° κ³μ μΆκ°
|
295 |
+
elif in_prompt:
|
296 |
+
# μ€λͺ
μ΄λ λ©ν ν
μ€νΈκ° μμλλ©΄ μ€λ¨
|
297 |
+
if "explanation" in line.lower() or "let me know" in line.lower():
|
298 |
+
break
|
299 |
+
prompt_lines.append(line)
|
300 |
+
|
301 |
+
# ν둬ννΈ λΌμΈ ν©μΉκΈ°
|
302 |
+
if prompt_lines:
|
303 |
+
return '\n'.join(prompt_lines).strip()
|
304 |
+
|
305 |
+
# μ λ°©λ²μΌλ‘ μ°Ύμ§ λͺ»ν κ²½μ° μλ³Έ λ°ν
|
306 |
return prompt.strip()
|
307 |
|
308 |
def get_selected_background_info(bg_type, simple, studio, nature, indoor, tech, colorful, abstract):
|
|
|
365 |
λ€μ κ°μ΄λλΌμΈμ λ°λμ μ€μν΄μΌ ν©λλ€:
|
366 |
|
367 |
1. μνμ "#1"λ‘ μ§μ νμ¬ μ°Έμ‘°ν©λλ€. (μ: "skincare tube (#1)")
|
|
|
368 |
2. *** λ§€μ° μ€μ: μνμ μλ νΉμ±(λμμΈ, μμ, νν, λ‘κ³ , ν¨ν€μ§ λ±)μ μ΄λ€ μν©μμλ μ λ λ³κ²½νμ§ μμ΅λλ€. ***
|
|
|
369 |
3. *** μνμ λ³Έμ§μ νΉμ±μ μ μ§νλ, μνμ ν¬μ»€μ€λ₯Ό λ§μΆ° λͺ¨λ μΈλΆ μ¬νμ΄ μ λͺ
νκ² λλ¬λλλ‘ νλ©°,
|
370 |
8K ν΄μλ(8K resolution), μ€λ²μ€νλ μλ μ΄κ³ νμ§(ultra high definition without oversharpening)λ‘ λ λλ§λμ΄μΌ ν©λλ€. ***
|
|
|
371 |
4. μ΄λ―Έμ§ λΉμ¨μ μ νν 1:1(μ μ¬κ°ν) νμμΌλ‘ μ§μ ν©λλ€. ν둬ννΈμ "square format", "1:1 ratio" λλ "aspect ratio 1:1"μ λͺ
μμ μΌλ‘ ν¬ν¨ν©λλ€.
|
|
|
372 |
5. μνμ λ°λμ μ μ¬κ°ν ꡬλμ μ μ€μμ λ°°μΉλμ΄μΌ νλ©°, μ μ ν ν¬κΈ°λ‘ νννμ¬ λν
μΌμ΄ μλ²½νκ² λ³΄μ΄λλ‘ ν©λλ€.
|
|
|
373 |
6. μνμ μ΄λ―Έμ§μ μ£Όμ μ΄μ μΌλ‘ λΆκ°μν€κ³ , μνμ λΉμ¨μ΄ μ 체 μ΄λ―Έμ§μμ 60-70% μ΄μ μ°¨μ§νλλ‘ ν©λλ€.
|
|
|
374 |
7. μ‘°λͺ
μ€λͺ
μ λ§€μ° κ΅¬μ²΄μ μΌλ‘ ν΄μ£ΌμΈμ. μ: "soft directional lighting from left side", "dramatic rim lighting", "diffused natural light through windows"
|
|
|
375 |
8. λ°°κ²½μ μ¬μ§κ³Ό μ§κ°μ μμΈν μ€λͺ
ν΄μ£ΌμΈμ. μ: "polished marble surface", "rustic wooden table with visible grain", "matte concrete wall with subtle texture"
|
|
|
376 |
9. ν둬ννΈμ λ€μ μμλ€μ λͺ
μμ μΌλ‘ ν¬ν¨νλ, μ¬μ© λ§₯λ½μ μ μ νκ² λ³ννμΈμ:
|
377 |
- "award-winning product photography"
|
378 |
- "magazine-worthy commercial product shot"
|
|
|
382 |
- "commercial product photography with precise detail rendering"
|
383 |
- "ultra high definition"
|
384 |
- "crystal clear details"
|
|
|
385 |
10. μ¬μ©μκ° μ 곡ν ꡬ체μ μΈ λ°°κ²½κ³Ό μΆκ° μμ²μ¬νμ ν둬ννΈμ μ νν λ°μνκ³ νμ₯ν©λλ€.
|
|
|
386 |
11. ν둬ννΈ λμ "--ar 1:1 --s 750 --q 2 --v 5.2" νλΌλ―Έν°λ₯Ό μΆκ°νμ¬ λ―Έλμ λμμ κ³ νμ§ μ μ¬κ°ν λΉμ¨μ κ°μ ν©λλ€.
|
387 |
+
12. λ§€μ° μ€μ: ν둬ννΈ μΈμ λ€λ₯Έ μ€λͺ
μ΄λ λ©ν ν
μ€νΈλ₯Ό ν¬ν¨νμ§ λ§μΈμ. μλ₯Ό λ€μ΄ "Here's a prompt for you" λλ "Let me know if you need adjustments" κ°μ λ©μμ§λ μ€λͺ
μ ν¬ν¨νμ§ λ§μΈμ. μ€μ§ ν둬ννΈ μμ²΄λ§ μ 곡νμΈμ.
|
388 |
"""
|
389 |
|
390 |
def generate_prompt_with_gemini(product_name, background_info, additional_info=""):
|