Update app.py
Browse files
app.py
CHANGED
|
@@ -196,8 +196,7 @@ def generate_with_images(prompt, images, variation_index=0):
|
|
| 196 |
)
|
| 197 |
)
|
| 198 |
|
| 199 |
-
|
| 200 |
-
with tempfile.NamedTemporaryFile(suffix=".jpg", delete=False) as tmp:
|
| 201 |
temp_path = tmp.name
|
| 202 |
result_text = ""
|
| 203 |
image_found = False
|
|
@@ -211,18 +210,9 @@ def generate_with_images(prompt, images, variation_index=0):
|
|
| 211 |
logger.info("์๋ต์์ ์ด๋ฏธ์ง ์ถ์ถ ์ฑ๊ณต")
|
| 212 |
if not image_found:
|
| 213 |
return None, f"API์์ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ์ง ๋ชปํ์ต๋๋ค. ์๋ต ํ
์คํธ: {result_text}"
|
| 214 |
-
|
| 215 |
-
# ์ด๋ฏธ์ง๋ฅผ ์ด๊ณ JPG ํ์์ผ๋ก ์ ์ฅ
|
| 216 |
result_img = Image.open(temp_path)
|
| 217 |
if result_img.mode == "RGBA":
|
| 218 |
-
# RGBA ๋ชจ๋๋ JPG์์ ์ง์ํ์ง ์์ผ๋ฏ๋ก RGB๋ก ๋ณํ
|
| 219 |
result_img = result_img.convert("RGB")
|
| 220 |
-
|
| 221 |
-
# ์ด๋ฏธ์ง๋ฅผ JPG๋ก ์ ์ฅํ๊ณ ๋ค์ ๋ก๋
|
| 222 |
-
jpg_path = temp_path + ".jpg"
|
| 223 |
-
result_img.save(jpg_path, "JPEG", quality=95)
|
| 224 |
-
result_img = Image.open(jpg_path)
|
| 225 |
-
|
| 226 |
return result_img, f"์ด๋ฏธ์ง๊ฐ ์ฑ๊ณต์ ์ผ๋ก ์์ฑ๋์์ต๋๋ค. {result_text}"
|
| 227 |
except Exception as e:
|
| 228 |
logger.exception("์ด๋ฏธ์ง ์์ฑ ์ค ์ค๋ฅ ๋ฐ์:")
|
|
|
|
| 196 |
)
|
| 197 |
)
|
| 198 |
|
| 199 |
+
with tempfile.NamedTemporaryFile(suffix=".png", delete=False) as tmp:
|
|
|
|
| 200 |
temp_path = tmp.name
|
| 201 |
result_text = ""
|
| 202 |
image_found = False
|
|
|
|
| 210 |
logger.info("์๋ต์์ ์ด๋ฏธ์ง ์ถ์ถ ์ฑ๊ณต")
|
| 211 |
if not image_found:
|
| 212 |
return None, f"API์์ ์ด๋ฏธ์ง๋ฅผ ์์ฑํ์ง ๋ชปํ์ต๋๋ค. ์๋ต ํ
์คํธ: {result_text}"
|
|
|
|
|
|
|
| 213 |
result_img = Image.open(temp_path)
|
| 214 |
if result_img.mode == "RGBA":
|
|
|
|
| 215 |
result_img = result_img.convert("RGB")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
return result_img, f"์ด๋ฏธ์ง๊ฐ ์ฑ๊ณต์ ์ผ๋ก ์์ฑ๋์์ต๋๋ค. {result_text}"
|
| 217 |
except Exception as e:
|
| 218 |
logger.exception("์ด๋ฏธ์ง ์์ฑ ์ค ์ค๋ฅ ๋ฐ์:")
|