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
|
| 8 |
+
import tempfile
|
| 9 |
+
import numpy as np
|
| 10 |
+
|
| 11 |
+
# Replicate API ํ ํฐ ์ค์ (ํ๊ฒฝ๋ณ์์์ ๊ฐ์ ธ์ค๊ธฐ)
|
| 12 |
+
REPLICATE_API_TOKEN = os.getenv("REPLICATE_API_TOKEN")
|
| 13 |
+
if REPLICATE_API_TOKEN:
|
| 14 |
+
os.environ["REPLICATE_API_TOKEN"] = REPLICATE_API_TOKEN
|
| 15 |
+
|
| 16 |
+
def upload_image_to_temp_url(image):
|
| 17 |
+
"""์ด๋ฏธ์ง๋ฅผ ์์ URL๋ก ์
๋ก๋ํ๋ ํจ์ (์ค์ ๋ก๋ base64 ์ธ์ฝ๋ฉ)"""
|
| 18 |
+
if image is None:
|
| 19 |
+
return None
|
| 20 |
+
|
| 21 |
+
# PIL Image๋ฅผ base64๋ก ์ธ์ฝ๋ฉ
|
| 22 |
+
buffer = io.BytesIO()
|
| 23 |
+
image.save(buffer, format='PNG')
|
| 24 |
+
buffer.seek(0)
|
| 25 |
+
|
| 26 |
+
# ์์ ํ์ผ๋ก ์ ์ฅ
|
| 27 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix='.png') as tmp_file:
|
| 28 |
+
image.save(tmp_file.name, format='PNG')
|
| 29 |
+
return tmp_file.name
|
| 30 |
+
|
| 31 |
+
def create_white_background_shadow(image, shadow_intensity=0.3, shadow_offset=(10, 10)):
|
| 32 |
+
"""ํฐ ๋ฐฐ๊ฒฝ์ ๊ทธ๋ฆผ์ ํจ๊ณผ ์ถ๊ฐ"""
|
| 33 |
+
if image.mode != 'RGBA':
|
| 34 |
+
image = image.convert('RGBA')
|
| 35 |
+
|
| 36 |
+
# ์๋ณธ ์ด๋ฏธ์ง ํฌ๊ธฐ
|
| 37 |
+
width, height = image.size
|
| 38 |
+
|
| 39 |
+
# ๊ทธ๋ฆผ์๋ฅผ ์ํ ์ฌ๋ฐฑ ์ถ๊ฐ
|
| 40 |
+
shadow_margin = max(shadow_offset) + 20
|
| 41 |
+
new_width = width + shadow_margin * 2
|
| 42 |
+
new_height = height + shadow_margin * 2
|
| 43 |
+
|
| 44 |
+
# ํฐ์ ๋ฐฐ๊ฒฝ ์์ฑ
|
| 45 |
+
result = Image.new('RGBA', (new_width, new_height), (255, 255, 255, 255))
|
| 46 |
+
|
| 47 |
+
# ๊ทธ๋ฆผ์ ์์ฑ
|
| 48 |
+
shadow = Image.new('RGBA', (new_width, new_height), (0, 0, 0, 0))
|
| 49 |
+
shadow_draw = ImageDraw.Draw(shadow)
|
| 50 |
+
|
| 51 |
+
# ์๋ณธ ์ด๋ฏธ์ง์ ์ํ ์ฑ๋์ ์ด์ฉํด ๊ทธ๋ฆผ์ ๋ง์คํฌ ์์ฑ
|
| 52 |
+
alpha = image.split()[-1]
|
| 53 |
+
shadow_pos = (shadow_margin + shadow_offset[0], shadow_margin + shadow_offset[1])
|
| 54 |
+
shadow.paste(Image.new('RGBA', image.size, (0, 0, 0, int(255 * shadow_intensity))), shadow_pos, alpha)
|
| 55 |
+
|
| 56 |
+
# ๊ทธ๋ฆผ์ ๋ธ๋ฌ ํจ๊ณผ
|
| 57 |
+
shadow = shadow.filter(ImageFilter.GaussianBlur(radius=8))
|
| 58 |
+
|
| 59 |
+
# ๊ทธ๋ฆผ์๋ฅผ ๋ฐฐ๊ฒฝ์ ํฉ์ฑ
|
| 60 |
+
result = Image.alpha_composite(result, shadow)
|
| 61 |
+
|
| 62 |
+
# ์๋ณธ ์ด๋ฏธ์ง๋ฅผ ์ค์์ ๋ฐฐ์น
|
| 63 |
+
image_pos = (shadow_margin, shadow_margin)
|
| 64 |
+
result.paste(image, image_pos, image)
|
| 65 |
+
|
| 66 |
+
return result.convert('RGB')
|
| 67 |
+
|
| 68 |
+
def enhance_image_quality(image):
|
| 69 |
+
"""์ด๋ฏธ์ง ํ์ง ํฅ์"""
|
| 70 |
+
# ์ ๋ช
๋ ํฅ์
|
| 71 |
+
enhancer = ImageEnhance.Sharpness(image)
|
| 72 |
+
image = enhancer.enhance(1.2)
|
| 73 |
+
|
| 74 |
+
# ๋๋น ํฅ์
|
| 75 |
+
enhancer = ImageEnhance.Contrast(image)
|
| 76 |
+
image = enhancer.enhance(1.1)
|
| 77 |
+
|
| 78 |
+
# ์์ ์ฑ๋ ํฅ์
|
| 79 |
+
enhancer = ImageEnhance.Color(image)
|
| 80 |
+
image = enhancer.enhance(1.05)
|
| 81 |
+
|
| 82 |
+
return image
|
| 83 |
+
|
| 84 |
+
def rotate_image_slightly(image, angle=5):
|
| 85 |
+
"""์ด๋ฏธ์ง๋ฅผ ์ฝ๊ฐ ํ์ ์์ผ ์์ดํ
์๋ ํํผ"""
|
| 86 |
+
return image.rotate(angle, expand=True, fillcolor=(255, 255, 255))
|
| 87 |
+
|
| 88 |
+
def check_white_background_ratio(image, threshold=0.85):
|
| 89 |
+
"""ํฐ์ ๋ฐฐ๊ฒฝ ๋น์จ ํ์ธ (85% ๊ท์น)"""
|
| 90 |
+
if image.mode != 'RGB':
|
| 91 |
+
image = image.convert('RGB')
|
| 92 |
+
|
| 93 |
+
pixels = np.array(image)
|
| 94 |
+
white_pixels = np.sum(np.all(pixels >= [240, 240, 240], axis=2))
|
| 95 |
+
total_pixels = pixels.shape[0] * pixels.shape[1]
|
| 96 |
+
white_ratio = white_pixels / total_pixels
|
| 97 |
+
|
| 98 |
+
return white_ratio >= threshold, white_ratio
|
| 99 |
+
|
| 100 |
+
def process_with_ai_enhancement(image_path, prompt_option):
|
| 101 |
+
"""AI๋ฅผ ์ด์ฉํ ์ด๋ฏธ์ง ํ์ง ํฅ์"""
|
| 102 |
+
if not REPLICATE_API_TOKEN:
|
| 103 |
+
return None, "Replicate API ํ ํฐ์ด ์ค์ ๋์ง ์์์ต๋๋ค."
|
| 104 |
+
|
| 105 |
+
try:
|
| 106 |
+
# ํ๋กฌํํธ ์ต์
๋ณ ์ค์
|
| 107 |
+
prompts = {
|
| 108 |
+
"๊ธฐ๋ณธ ํ์งํฅ์": "Enhance image quality, make it more professional and crisp, white background",
|
| 109 |
+
"์ ํ ์ฌ์ง ์ต์ ํ": "Transform into professional product photography, clean white background, high quality, studio lighting",
|
| 110 |
+
"์ฟ ํก ์คํ์ผ": "Make it look like a professional e-commerce product photo for Korean online shopping, clean white background, perfect lighting",
|
| 111 |
+
"ํ๋ฆฌ๋ฏธ์ ๋๋": "Make it look premium and luxury, professional product shot, perfect white background, studio quality"
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
selected_prompt = prompts.get(prompt_option, prompts["๊ธฐ๋ณธ ํ์งํฅ์"])
|
| 115 |
+
|
| 116 |
+
# Replicate API ํธ์ถ
|
| 117 |
+
output = replicate.run(
|
| 118 |
+
"black-forest-labs/flux-kontext-pro",
|
| 119 |
+
input={
|
| 120 |
+
"prompt": selected_prompt,
|
| 121 |
+
"input_image": open(image_path, "rb"),
|
| 122 |
+
"output_format": "jpg"
|
| 123 |
+
}
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
# ๊ฒฐ๊ณผ ์ด๋ฏธ์ง ๋ค์ด๋ก๋
|
| 127 |
+
response = requests.get(output)
|
| 128 |
+
if response.status_code == 200:
|
| 129 |
+
enhanced_image = Image.open(io.BytesIO(response.content))
|
| 130 |
+
return enhanced_image, "AI ํฅ์ ์๋ฃ"
|
| 131 |
+
else:
|
| 132 |
+
return None, "AI ์ฒ๋ฆฌ ์คํจ"
|
| 133 |
+
|
| 134 |
+
except Exception as e:
|
| 135 |
+
return None, f"AI ์ฒ๋ฆฌ ์ค ์ค๋ฅ: {str(e)}"
|
| 136 |
+
|
| 137 |
+
def create_coupang_thumbnail(image, apply_shadow, apply_rotation, rotation_angle, ai_enhancement, prompt_option):
|
| 138 |
+
"""์ฟ ํก ์ธ๋ค์ผ ์์ฑ ๋ฉ์ธ ํจ์"""
|
| 139 |
+
if image is None:
|
| 140 |
+
return None, "์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํด์ฃผ์ธ์."
|
| 141 |
+
|
| 142 |
+
try:
|
| 143 |
+
result_image = image.copy()
|
| 144 |
+
status_messages = []
|
| 145 |
+
|
| 146 |
+
# 1๋จ๊ณ: AI ํฅ์ (์ ํ์ฌํญ)
|
| 147 |
+
if ai_enhancement and REPLICATE_API_TOKEN:
|
| 148 |
+
temp_path = upload_image_to_temp_url(result_image)
|
| 149 |
+
if temp_path:
|
| 150 |
+
enhanced_img, ai_msg = process_with_ai_enhancement(temp_path, prompt_option)
|
| 151 |
+
if enhanced_img:
|
| 152 |
+
result_image = enhanced_img
|
| 153 |
+
status_messages.append(f"โ
AI ํฅ์: {ai_msg}")
|
| 154 |
+
else:
|
| 155 |
+
status_messages.append(f"โ AI ํฅ์: {ai_msg}")
|
| 156 |
+
os.unlink(temp_path) # ์์ ํ์ผ ์ญ์
|
| 157 |
+
|
| 158 |
+
# 2๋จ๊ณ: ํ์ง ํฅ์
|
| 159 |
+
result_image = enhance_image_quality(result_image)
|
| 160 |
+
status_messages.append("โ
ํ์ง ํฅ์ ์๋ฃ")
|
| 161 |
+
|
| 162 |
+
# 3๋จ๊ณ: ๊ฐ๋ ๋ณ๊ฒฝ (์์ดํ
์๋ ํํผ)
|
| 163 |
+
if apply_rotation:
|
| 164 |
+
result_image = rotate_image_slightly(result_image, rotation_angle)
|
| 165 |
+
status_messages.append(f"โ
๊ฐ๋ ๋ณ๊ฒฝ: {rotation_angle}๋ ํ์ ")
|
| 166 |
+
|
| 167 |
+
# 4๋จ๊ณ: ํฐ ๋ฐฐ๊ฒฝ + ๊ทธ๋ฆผ์ ํจ๊ณผ
|
| 168 |
+
if apply_shadow:
|
| 169 |
+
result_image = create_white_background_shadow(result_image)
|
| 170 |
+
status_messages.append("โ
๊ทธ๋ฆผ์ ํจ๊ณผ ์ ์ฉ")
|
| 171 |
+
else:
|
| 172 |
+
# ๊ทธ๋ฆผ์ ์์ด ํฐ ๋ฐฐ๊ฒฝ๋ง ์ ์ฉ
|
| 173 |
+
if result_image.mode == 'RGBA':
|
| 174 |
+
white_bg = Image.new('RGB', result_image.size, (255, 255, 255))
|
| 175 |
+
white_bg.paste(result_image, mask=result_image.split()[-1] if result_image.mode == 'RGBA' else None)
|
| 176 |
+
result_image = white_bg
|
| 177 |
+
|
| 178 |
+
# 85% ํฐ์ ๋ฐฐ๊ฒฝ ๊ท์น ํ์ธ
|
| 179 |
+
is_compliant, white_ratio = check_white_background_ratio(result_image)
|
| 180 |
+
if is_compliant:
|
| 181 |
+
status_messages.append(f"โ
85% ํฐ์ ๋ฐฐ๊ฒฝ ๊ท์น ์ค์ ({white_ratio:.1%})")
|
| 182 |
+
else:
|
| 183 |
+
status_messages.append(f"โ ๏ธ ํฐ์ ๋ฐฐ๊ฒฝ ๋น์จ ๋ถ์กฑ ({white_ratio:.1%}) - 85% ๋ฏธ๋ง")
|
| 184 |
+
|
| 185 |
+
# ์ต์ข
์ด๋ฏธ์ง ํฌ๊ธฐ ์กฐ์ (์ฟ ํก ๊ถ์ฅ ์ฌ์ด์ฆ)
|
| 186 |
+
result_image = result_image.resize((1000, 1000), Image.Resampling.LANCZOS)
|
| 187 |
+
status_messages.append("โ
1000x1000 ํฌ๊ธฐ๋ก ์กฐ์ ์๋ฃ")
|
| 188 |
+
|
| 189 |
+
return result_image, "\n".join(status_messages)
|
| 190 |
+
|
| 191 |
+
except Exception as e:
|
| 192 |
+
return None, f"์ฒ๋ฆฌ ์ค ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: {str(e)}"
|
| 193 |
+
|
| 194 |
+
# Gradio ์ธํฐํ์ด์ค ์์ฑ
|
| 195 |
+
def create_interface():
|
| 196 |
+
with gr.Blocks(title="๐ ์ฟ ํก ์ธ๋ค์ผ ์์ฑ๊ธฐ", theme=gr.themes.Soft()) as iface:
|
| 197 |
+
gr.Markdown("""
|
| 198 |
+
# ๐ ์ฟ ํก ์ธ๋ค์ผ ์์ฑ๊ธฐ
|
| 199 |
+
|
| 200 |
+
๋ฐฐ๊ฒฝ์ด ์ ๊ฑฐ๋ ์ํ ์ด๋ฏธ์ง๋ฅผ ์
๋ก๋ํ๋ฉด ์ฟ ํก ๊ท์ ์ ๋ง๋ ์ธ๋ค์ผ๋ก ์๋ ๋ณํํด๋๋ฆฝ๋๋ค!
|
| 201 |
+
|
| 202 |
+
## ๐ก ์ ์ฉ๋๋ ์ฟ ํก ๊ท์ ๋์ ์ ๋ต:
|
| 203 |
+
- โ
**ํฐ ๋ฐฐ๊ฒฝ + 85% ๊ท์น** ์๋ฒฝ ์ค์
|
| 204 |
+
- โ
**AI ๋ง๋ฒ ํ๋กฌํํธ**๋ก ํ์ง ํฅ์
|
| 205 |
+
- โ
**๊ฐ๋ ๋ณ๊ฒฝ**์ผ๋ก ์์ดํ
์๋ ํํผ
|
| 206 |
+
- โ
**๊ทธ๋ฆผ์ ํจ๊ณผ**๋ก ์์ฐ์ค๋ฌ์ด ์
์ฒด๊ฐ ์ฐ์ถ
|
| 207 |
+
""")
|
| 208 |
+
|
| 209 |
+
with gr.Row():
|
| 210 |
+
with gr.Column(scale=1):
|
| 211 |
+
gr.Markdown("### ๐ค ์ด๋ฏธ์ง ์
๋ก๋")
|
| 212 |
+
input_image = gr.Image(
|
| 213 |
+
label="๋ฐฐ๊ฒฝ ์ ๊ฑฐ๋ ์ํ ์ด๋ฏธ์ง",
|
| 214 |
+
type="pil",
|
| 215 |
+
height=300
|
| 216 |
+
)
|
| 217 |
+
|
| 218 |
+
gr.Markdown("### โ๏ธ ์ต์
์ค์ ")
|
| 219 |
+
|
| 220 |
+
with gr.Group():
|
| 221 |
+
gr.Markdown("**๐จ ํจ๊ณผ ์ต์
**")
|
| 222 |
+
apply_shadow = gr.Checkbox(
|
| 223 |
+
label="๊ทธ๋ฆผ์ ํจ๊ณผ ์ ์ฉ",
|
| 224 |
+
value=True,
|
| 225 |
+
info="์์ฐ์ค๋ฌ์ด ์
์ฒด๊ฐ ์ฐ์ถ"
|
| 226 |
+
)
|
| 227 |
+
apply_rotation = gr.Checkbox(
|
| 228 |
+
label="๊ฐ๋ ๋ณ๊ฒฝ ์ ์ฉ",
|
| 229 |
+
value=True,
|
| 230 |
+
info="์์ดํ
์๋ ํํผ"
|
| 231 |
+
)
|
| 232 |
+
rotation_angle = gr.Slider(
|
| 233 |
+
minimum=-15,
|
| 234 |
+
maximum=15,
|
| 235 |
+
value=5,
|
| 236 |
+
step=1,
|
| 237 |
+
label="ํ์ ๊ฐ๋",
|
| 238 |
+
visible=True
|
| 239 |
+
)
|
| 240 |
+
|
| 241 |
+
with gr.Group():
|
| 242 |
+
gr.Markdown("**๐ค AI ํฅ์ (Replicate API ํ์)**")
|
| 243 |
+
ai_enhancement = gr.Checkbox(
|
| 244 |
+
label="AI ํ์ง ํฅ์ ์ฌ์ฉ",
|
| 245 |
+
value=False,
|
| 246 |
+
info="Replicate API ํ ํฐ์ด ํ์ํฉ๋๋ค"
|
| 247 |
+
)
|
| 248 |
+
prompt_option = gr.Dropdown(
|
| 249 |
+
choices=["๊ธฐ๋ณธ ํ์งํฅ์", "์ ํ ์ฌ์ง ์ต์ ํ", "์ฟ ํก ์คํ์ผ", "ํ๋ฆฌ๋ฏธ์ ๋๋"],
|
| 250 |
+
value="์ฟ ํก ์คํ์ผ",
|
| 251 |
+
label="AI ํฅ์ ์คํ์ผ"
|
| 252 |
+
)
|
| 253 |
+
|
| 254 |
+
process_btn = gr.Button("๐ ์ฟ ํก ์ธ๋ค์ผ ์์ฑ", variant="primary", size="lg")
|
| 255 |
+
|
| 256 |
+
with gr.Column(scale=1):
|
| 257 |
+
gr.Markdown("### ๐ฅ ๊ฒฐ๊ณผ")
|
| 258 |
+
output_image = gr.Image(
|
| 259 |
+
label="์ฟ ํก ๊ท์ ์ธ๋ค์ผ",
|
| 260 |
+
height=400
|
| 261 |
+
)
|
| 262 |
+
status_output = gr.Textbox(
|
| 263 |
+
label="์ฒ๋ฆฌ ์ํ",
|
| 264 |
+
lines=8,
|
| 265 |
+
max_lines=15
|
| 266 |
+
)
|
| 267 |
+
|
| 268 |
+
# ์ฌ์ฉ ์์
|
| 269 |
+
gr.Markdown("""
|
| 270 |
+
---
|
| 271 |
+
## ๐ ์ฌ์ฉ ๋ฐฉ๋ฒ
|
| 272 |
+
1. **๋ฐฐ๊ฒฝ์ด ์ ๊ฑฐ๋ ์ํ ์ด๋ฏธ์ง**๋ฅผ ์
๋ก๋ํ์ธ์
|
| 273 |
+
2. ์ํ๋ **ํจ๊ณผ ์ต์
**์ ์ ํํ์ธ์
|
| 274 |
+
3. **AI ํฅ์**์ ์ฌ์ฉํ๋ ค๋ฉด Replicate API ํ ํฐ์ ํ๊ฒฝ๋ณ์๋ก ์ค์ ํ์ธ์
|
| 275 |
+
4. **'์ฟ ํก ์ธ๋ค์ผ ์์ฑ'** ๋ฒํผ์ ํด๋ฆญํ์ธ์
|
| 276 |
+
|
| 277 |
+
## ๐ API ์ค์ (์ ํ์ฌํญ)
|
| 278 |
+
AI ํฅ์ ๊ธฐ๋ฅ์ ์ฌ์ฉํ๋ ค๋ฉด ํ๊ฒฝ๋ณ์๋ฅผ ์ค์ ํ์ธ์:
|
| 279 |
+
```bash
|
| 280 |
+
export REPLICATE_API_TOKEN=your_token_here
|
| 281 |
+
```
|
| 282 |
+
""")
|
| 283 |
+
|
| 284 |
+
# ์ด๋ฒคํธ ์ฒ๋ฆฌ
|
| 285 |
+
def update_rotation_visibility(apply_rot):
|
| 286 |
+
return gr.update(visible=apply_rot)
|
| 287 |
+
|
| 288 |
+
apply_rotation.change(update_rotation_visibility, apply_rotation, rotation_angle)
|
| 289 |
+
|
| 290 |
+
process_btn.click(
|
| 291 |
+
create_coupang_thumbnail,
|
| 292 |
+
inputs=[
|
| 293 |
+
input_image,
|
| 294 |
+
apply_shadow,
|
| 295 |
+
apply_rotation,
|
| 296 |
+
rotation_angle,
|
| 297 |
+
ai_enhancement,
|
| 298 |
+
prompt_option
|
| 299 |
+
],
|
| 300 |
+
outputs=[output_image, status_output]
|
| 301 |
+
)
|
| 302 |
+
|
| 303 |
+
return iface
|
| 304 |
+
|
| 305 |
+
# ์ฑ ์คํ
|
| 306 |
+
if __name__ == "__main__":
|
| 307 |
+
app = create_interface()
|
| 308 |
+
app.launch(
|
| 309 |
+
server_name="0.0.0.0",
|
| 310 |
+
server_port=7860,
|
| 311 |
+
share=True,
|
| 312 |
+
show_error=True
|
| 313 |
+
)
|