fantaxy commited on
Commit
6a468e1
·
verified ·
1 Parent(s): 84ba97a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -5,7 +5,6 @@ import logging
5
  import requests
6
  from PIL import Image
7
  import io
8
- import tempfile
9
  import base64
10
 
11
  # 로깅 설정
@@ -18,13 +17,11 @@ api_client = Client("http://211.233.58.202:7960/")
18
  WEBHOOK_URL = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjUwNTY0MDYzMTA0MzE1MjZlNTUzYzUxM2Ei_pc"
19
 
20
  # Imgur 클라이언트 ID
21
- IMGUR_CLIENT_ID = "여기에_당신의_IMGUR_CLIENT_ID를_입력하세요"
22
 
23
- def upload_to_imgur(image_path):
24
  try:
25
- with open(image_path, "rb") as file:
26
- im_bytes = file.read()
27
- im_b64 = base64.b64encode(im_bytes).decode("utf-8")
28
 
29
  url = "https://api.imgur.com/3/image"
30
  payload = {'image': im_b64, 'type': 'base64'}
@@ -73,13 +70,17 @@ def respond(message, seed, randomize_seed, width, height, guidance_scale, num_in
73
  if isinstance(result, tuple) and len(result) >= 1:
74
  local_image_path = result[0]
75
 
 
 
 
 
76
  # Imgur에 이미지 업로드
77
- imgur_url = upload_to_imgur(local_image_path)
78
 
79
  if imgur_url:
80
  # Webhook으로 데이터 전송
81
  send_to_webhook(message, imgur_url)
82
- return Image.open(local_image_path)
83
  else:
84
  raise ValueError("Failed to upload image to Imgur")
85
  else:
@@ -90,6 +91,7 @@ def respond(message, seed, randomize_seed, width, height, guidance_scale, num_in
90
 
91
 
92
 
 
93
  css = """
94
  footer {
95
  visibility: hidden;
 
5
  import requests
6
  from PIL import Image
7
  import io
 
8
  import base64
9
 
10
  # 로깅 설정
 
17
  WEBHOOK_URL = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjUwNTY0MDYzMTA0MzE1MjZlNTUzYzUxM2Ei_pc"
18
 
19
  # Imgur 클라이언트 ID
20
+ IMGUR_CLIENT_ID = "4990123196cbfcc"
21
 
22
+ def upload_to_imgur(image_data):
23
  try:
24
+ im_b64 = base64.b64encode(image_data).decode("utf-8")
 
 
25
 
26
  url = "https://api.imgur.com/3/image"
27
  payload = {'image': im_b64, 'type': 'base64'}
 
70
  if isinstance(result, tuple) and len(result) >= 1:
71
  local_image_path = result[0]
72
 
73
+ # 이미지 파일을 메모리에 로드
74
+ with open(local_image_path, "rb") as f:
75
+ image_data = f.read()
76
+
77
  # Imgur에 이미지 업로드
78
+ imgur_url = upload_to_imgur(image_data)
79
 
80
  if imgur_url:
81
  # Webhook으로 데이터 전송
82
  send_to_webhook(message, imgur_url)
83
+ return Image.open(io.BytesIO(image_data))
84
  else:
85
  raise ValueError("Failed to upload image to Imgur")
86
  else:
 
91
 
92
 
93
 
94
+
95
  css = """
96
  footer {
97
  visibility: hidden;