Kims12 commited on
Commit
af9a6de
Β·
verified Β·
1 Parent(s): dcc09a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -18
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
- idx = prompt.find("Highly detailed commercial photography")
272
- if idx != -1:
273
- prompt_text = prompt[idx:].strip()
274
- end_idx = prompt_text.rfind("--ar 1:1 --s 750 --q 2")
275
- if end_idx != -1:
276
- end_idx += len("--ar 1:1 --s 750 --q 2")
277
- prompt_text = prompt_text[:end_idx].strip()
278
- return prompt_text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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=""):