ssboost commited on
Commit
42a8c3c
ยท
verified ยท
1 Parent(s): 9fe69b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -18
app.py CHANGED
@@ -68,8 +68,8 @@ def create_coupang_thumbnail_fixed(image_path):
68
  return None, "Replicate API ํ† ํฐ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค."
69
 
70
  try:
71
- # ๊ณ ์ •๋œ ํ”„๋กฌํ”„ํŠธ: ์™„์ „ํ•œ ํฐ์ƒ‰๋ฐฐ๊ฒฝ, 85%์ƒํ’ˆ์ด๋ฏธ์ง€, ๊ทธ๋ฆผ์žํšจ๊ณผ, 3/4๋ทฐ ๊ณ ์ •
72
- fixed_prompt = "Professional product photography, 3/4 angle view, pure white background #FFFFFF, natural soft shadows, clean white backdrop, high quality e-commerce photo, solid white background, product takes 85% of image space"
73
 
74
  output = replicate.run(
75
  "black-forest-labs/flux-kontext-pro",
@@ -98,7 +98,7 @@ def process_image(image, remove_bg, upscale_quality):
98
  result_image = image.copy()
99
  status_messages = []
100
 
101
- # 1๋‹จ๊ณ„: ๋ฐฐ๊ฒฝ ์ œ๊ฑฐ (์„ ํƒ์‚ฌํ•ญ)
102
  if remove_bg:
103
  temp_path = upload_image_to_temp_url(result_image)
104
  if temp_path:
@@ -110,7 +110,19 @@ def process_image(image, remove_bg, upscale_quality):
110
  status_messages.append(f"โŒ {bg_msg}")
111
  os.unlink(temp_path)
112
 
113
- # 2๋‹จ๊ณ„: ํ™”์งˆ ๊ฐœ์„  (์„ ํƒ์‚ฌํ•ญ)
 
 
 
 
 
 
 
 
 
 
 
 
114
  if upscale_quality:
115
  temp_path = upload_image_to_temp_url(result_image)
116
  if temp_path:
@@ -122,20 +134,9 @@ def process_image(image, remove_bg, upscale_quality):
122
  status_messages.append(f"โŒ {upscale_msg}")
123
  os.unlink(temp_path)
124
 
125
- # 3๋‹จ๊ณ„: ์ฟ ํŒก ์ธ๋„ค์ผ ์ƒ์„ฑ (๊ณ ์ • ์„ค์ •)
126
- temp_path = upload_image_to_temp_url(result_image)
127
- if temp_path:
128
- final_img, final_msg = create_coupang_thumbnail_fixed(temp_path)
129
- if final_img:
130
- result_image = final_img
131
- status_messages.append(f"โœ… {final_msg}")
132
-
133
- # ์ตœ์ข… ํฌ๊ธฐ ์กฐ์ •
134
- result_image = result_image.resize((1000, 1000), Image.Resampling.LANCZOS)
135
- status_messages.append("โœ… 1000x1000 ํฌ๊ธฐ ์กฐ์ • ์™„๋ฃŒ")
136
- else:
137
- status_messages.append(f"โŒ {final_msg}")
138
- os.unlink(temp_path)
139
 
140
  return result_image, "\n".join(status_messages)
141
 
 
68
  return None, "Replicate API ํ† ํฐ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค."
69
 
70
  try:
71
+ # ๊ณ ์ •๋œ ํ”„๋กฌํ”„ํŠธ: ์™„์ „ํ•œ ํฐ์ƒ‰๋ฐฐ๊ฒฝ, 85%์ƒํ’ˆ์ด๋ฏธ์ง€, ๊ทธ๋ฆผ์žํšจ๊ณผ, ๊ฐ๋„๋ฅผ ๋” ํ‹€์–ด์„œ
72
+ fixed_prompt = "Professional product photography, dramatic 3/4 angle view rotated 45 degrees, dynamic perspective, pure white background #FFFFFF, natural soft shadows, clean white backdrop, high quality e-commerce photo, solid white background, product takes 85% of image space, tilted composition, angled product placement"
73
 
74
  output = replicate.run(
75
  "black-forest-labs/flux-kontext-pro",
 
98
  result_image = image.copy()
99
  status_messages = []
100
 
101
+ # 1๋‹จ๊ณ„: ๋ฐฐ๊ฒฝ ์ œ๊ฑฐ (์ด๋ฏธ์ง€ ์ƒ์„ฑ ์ „)
102
  if remove_bg:
103
  temp_path = upload_image_to_temp_url(result_image)
104
  if temp_path:
 
110
  status_messages.append(f"โŒ {bg_msg}")
111
  os.unlink(temp_path)
112
 
113
+ # 2๋‹จ๊ณ„: ์ฟ ํŒก ์ธ๋„ค์ผ ์ƒ์„ฑ (๊ณ ์ • ์„ค์ •)
114
+ temp_path = upload_image_to_temp_url(result_image)
115
+ if temp_path:
116
+ final_img, final_msg = create_coupang_thumbnail_fixed(temp_path)
117
+ if final_img:
118
+ result_image = final_img
119
+ status_messages.append(f"โœ… {final_msg}")
120
+ else:
121
+ status_messages.append(f"โŒ {final_msg}")
122
+ return None, "\n".join(status_messages)
123
+ os.unlink(temp_path)
124
+
125
+ # 3๋‹จ๊ณ„: ํ™”์งˆ ๊ฐœ์„  (์ด๋ฏธ์ง€ ์ƒ์„ฑ ํ›„)
126
  if upscale_quality:
127
  temp_path = upload_image_to_temp_url(result_image)
128
  if temp_path:
 
134
  status_messages.append(f"โŒ {upscale_msg}")
135
  os.unlink(temp_path)
136
 
137
+ # 4๋‹จ๊ณ„: ์ตœ์ข… ํฌ๊ธฐ ์กฐ์ •
138
+ result_image = result_image.resize((1000, 1000), Image.Resampling.LANCZOS)
139
+ status_messages.append("โœ… 1000x1000 ํฌ๊ธฐ ์กฐ์ • ์™„๋ฃŒ")
 
 
 
 
 
 
 
 
 
 
 
140
 
141
  return result_image, "\n".join(status_messages)
142