fantaxy commited on
Commit
12bf62b
โ€ข
1 Parent(s): 5ab2ea5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -25,7 +25,15 @@ def upload_to_imgur(image_data):
25
  logger.debug(f"Image data type: {type(image_data)}")
26
  logger.debug(f"Image data length: {len(image_data)}")
27
 
28
- im_b64 = base64.b64encode(image_data).decode("utf-8")
 
 
 
 
 
 
 
 
29
 
30
  url = "https://api.imgur.com/3/image"
31
  payload = {'image': im_b64, 'type': 'base64'}
@@ -102,7 +110,6 @@ def respond(message, seed, randomize_seed, width, height, guidance_scale, num_in
102
  # ... (๋‚˜๋จธ์ง€ ์ฝ”๋“œ๋Š” ๊ทธ๋Œ€๋กœ ์œ ์ง€)
103
 
104
 
105
-
106
  css = """
107
  footer {
108
  visibility: hidden;
 
25
  logger.debug(f"Image data type: {type(image_data)}")
26
  logger.debug(f"Image data length: {len(image_data)}")
27
 
28
+ # ์ด๋ฏธ์ง€ ๋ฐ์ดํ„ฐ๋ฅผ PIL Image ๊ฐ์ฒด๋กœ ๋ณ€ํ™˜
29
+ image = Image.open(io.BytesIO(image_data))
30
+
31
+ # PNG ํ˜•์‹์œผ๋กœ ๋ณ€ํ™˜
32
+ buffered = io.BytesIO()
33
+ image.save(buffered, format="PNG")
34
+
35
+ # Base64๋กœ ์ธ์ฝ”๋”ฉ
36
+ im_b64 = base64.b64encode(buffered.getvalue()).decode("utf-8")
37
 
38
  url = "https://api.imgur.com/3/image"
39
  payload = {'image': im_b64, 'type': 'base64'}
 
110
  # ... (๋‚˜๋จธ์ง€ ์ฝ”๋“œ๋Š” ๊ทธ๋Œ€๋กœ ์œ ์ง€)
111
 
112
 
 
113
  css = """
114
  footer {
115
  visibility: hidden;