Update app.py
Browse files
app.py
CHANGED
|
@@ -68,8 +68,8 @@ def create_coupang_thumbnail_fixed(image_path):
|
|
| 68 |
return None, "Replicate API ํ ํฐ์ด ํ์ํฉ๋๋ค."
|
| 69 |
|
| 70 |
try:
|
| 71 |
-
# ๊ณ ์ ๋ ํ๋กฌํํธ: ์์ ํ ํฐ์๋ฐฐ๊ฒฝ, 85%์ํ์ด๋ฏธ์ง, ๊ทธ๋ฆผ์ํจ๊ณผ,
|
| 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 |
-
#
|
| 126 |
-
|
| 127 |
-
|
| 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 |
|