Kims12 commited on
Commit
71eb020
ยท
verified ยท
1 Parent(s): 07f49b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -11
app.py CHANGED
@@ -196,8 +196,7 @@ def generate_with_images(prompt, images, variation_index=0):
196
  )
197
  )
198
 
199
- # .jpg ํ™•์žฅ์ž๋กœ ๋ณ€๊ฒฝ
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("์ด๋ฏธ์ง€ ์ƒ์„ฑ ์ค‘ ์˜ค๋ฅ˜ ๋ฐœ์ƒ:")