Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ import io
|
|
8 |
import base64
|
9 |
|
10 |
# ๋ก๊น
์ค์
|
11 |
-
logging.basicConfig(level=logging.
|
12 |
|
13 |
# API ํด๋ผ์ด์ธํธ ์ค์
|
14 |
api_client = Client("http://211.233.58.202:7960/")
|
@@ -17,22 +17,27 @@ api_client = Client("http://211.233.58.202:7960/")
|
|
17 |
WEBHOOK_URL = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjUwNTY0MDYzMTA0MzE1MjZlNTUzYzUxM2Ei_pc"
|
18 |
|
19 |
# Imgur ํด๋ผ์ด์ธํธ ID
|
20 |
-
IMGUR_CLIENT_ID = "
|
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
|
28 |
headers = {'Authorization': f'Client-ID {IMGUR_CLIENT_ID}'}
|
29 |
|
30 |
response = requests.post(url, headers=headers, data=payload)
|
|
|
|
|
|
|
31 |
response.raise_for_status()
|
32 |
|
33 |
return response.json()['data']['link']
|
34 |
-
except
|
35 |
logging.error(f"Failed to upload image to Imgur: {e}")
|
|
|
|
|
36 |
return None
|
37 |
|
38 |
def send_to_webhook(prompt, image_url):
|
@@ -90,8 +95,6 @@ def respond(message, seed, randomize_seed, width, height, guidance_scale, num_in
|
|
90 |
return "Failed to generate image due to an error."
|
91 |
|
92 |
|
93 |
-
|
94 |
-
|
95 |
css = """
|
96 |
footer {
|
97 |
visibility: hidden;
|
@@ -167,7 +170,6 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
167 |
outputs=output_image
|
168 |
)
|
169 |
|
170 |
-
# ... (๋๋จธ์ง ์ฝ๋๋ ๊ทธ๋๋ก ์ ์ง)
|
171 |
-
|
172 |
if __name__ == "__main__":
|
|
|
173 |
demo.launch()
|
|
|
8 |
import base64
|
9 |
|
10 |
# ๋ก๊น
์ค์
|
11 |
+
logging.basicConfig(level=logging.DEBUG) # DEBUG ๋ ๋ฒจ๋ก ๋ณ๊ฒฝ
|
12 |
|
13 |
# API ํด๋ผ์ด์ธํธ ์ค์
|
14 |
api_client = Client("http://211.233.58.202:7960/")
|
|
|
17 |
WEBHOOK_URL = "https://connect.pabbly.com/workflow/sendwebhookdata/IjU3NjUwNTY0MDYzMTA0MzE1MjZlNTUzYzUxM2Ei_pc"
|
18 |
|
19 |
# Imgur ํด๋ผ์ด์ธํธ ID
|
20 |
+
IMGUR_CLIENT_ID = "์ฌ๊ธฐ์_๋น์ ์_IMGUR_CLIENT_ID๋ฅผ_์
๋ ฅํ์ธ์"
|
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}
|
28 |
headers = {'Authorization': f'Client-ID {IMGUR_CLIENT_ID}'}
|
29 |
|
30 |
response = requests.post(url, headers=headers, data=payload)
|
31 |
+
logging.debug(f"Imgur API response status: {response.status_code}")
|
32 |
+
logging.debug(f"Imgur API response content: {response.text}")
|
33 |
+
|
34 |
response.raise_for_status()
|
35 |
|
36 |
return response.json()['data']['link']
|
37 |
+
except requests.exceptions.RequestException as e:
|
38 |
logging.error(f"Failed to upload image to Imgur: {e}")
|
39 |
+
if hasattr(e, 'response'):
|
40 |
+
logging.error(f"Response content: {e.response.text}")
|
41 |
return None
|
42 |
|
43 |
def send_to_webhook(prompt, image_url):
|
|
|
95 |
return "Failed to generate image due to an error."
|
96 |
|
97 |
|
|
|
|
|
98 |
css = """
|
99 |
footer {
|
100 |
visibility: hidden;
|
|
|
170 |
outputs=output_image
|
171 |
)
|
172 |
|
|
|
|
|
173 |
if __name__ == "__main__":
|
174 |
+
logging.info(f"Starting application with Imgur Client ID: {IMGUR_CLIENT_ID[:5]}...") # ๋ณด์์ ์ํด ์ ์ฒด ID๋ฅผ ๋ก๊น
ํ์ง ์์ต๋๋ค
|
175 |
demo.launch()
|