Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,9 @@
|
|
1 |
-
|
2 |
import gradio as gr
|
3 |
from gradio_client import Client
|
4 |
import os
|
5 |
import logging
|
6 |
import requests
|
7 |
-
|
8 |
# ๋ก๊น
์ค์
|
9 |
logging.basicConfig(level=logging.INFO)
|
10 |
|
@@ -14,10 +13,18 @@ api_client = Client("http://211.233.58.202:7960/")
|
|
14 |
# Zapier ์นํ
URL
|
15 |
WEBHOOK_URL = "https://hooks.zapier.com/hooks/catch/14523965/264pyhj/"
|
16 |
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
payload = {
|
19 |
"prompt": prompt,
|
20 |
-
"
|
21 |
}
|
22 |
try:
|
23 |
response = requests.post(WEBHOOK_URL, json=payload)
|
@@ -51,8 +58,11 @@ def respond(message, seed, randomize_seed, width, height, guidance_scale, num_in
|
|
51 |
# ์ด๋ฏธ์ง URL ์์ฑ (์ค์ ์๋ฒ URL๋ก ๋ณ๊ฒฝ ํ์)
|
52 |
image_url = f"http://211.233.58.202:7960/file={image_path}"
|
53 |
|
|
|
|
|
|
|
54 |
# ์นํ
์ผ๋ก ๋ฐ์ดํฐ ์ ์ก
|
55 |
-
send_to_webhook(message,
|
56 |
|
57 |
return image_url
|
58 |
else:
|
@@ -61,8 +71,6 @@ def respond(message, seed, randomize_seed, width, height, guidance_scale, num_in
|
|
61 |
logging.error("Error during API request: %s", str(e))
|
62 |
return "Failed to generate image due to an error."
|
63 |
|
64 |
-
|
65 |
-
|
66 |
css = """
|
67 |
footer {
|
68 |
visibility: hidden;
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from gradio_client import Client
|
3 |
import os
|
4 |
import logging
|
5 |
import requests
|
6 |
+
import base64
|
7 |
# ๋ก๊น
์ค์
|
8 |
logging.basicConfig(level=logging.INFO)
|
9 |
|
|
|
13 |
# Zapier ์นํ
URL
|
14 |
WEBHOOK_URL = "https://hooks.zapier.com/hooks/catch/14523965/264pyhj/"
|
15 |
|
16 |
+
|
17 |
+
def download_image(image_url):
|
18 |
+
response = requests.get(image_url)
|
19 |
+
if response.status_code == 200:
|
20 |
+
return response.content
|
21 |
+
else:
|
22 |
+
raise Exception(f"Failed to download image: {response.status_code}")
|
23 |
+
|
24 |
+
def send_to_webhook(prompt, image_content):
|
25 |
payload = {
|
26 |
"prompt": prompt,
|
27 |
+
"image": base64.b64encode(image_content).decode('utf-8')
|
28 |
}
|
29 |
try:
|
30 |
response = requests.post(WEBHOOK_URL, json=payload)
|
|
|
58 |
# ์ด๋ฏธ์ง URL ์์ฑ (์ค์ ์๋ฒ URL๋ก ๋ณ๊ฒฝ ํ์)
|
59 |
image_url = f"http://211.233.58.202:7960/file={image_path}"
|
60 |
|
61 |
+
# ์ด๋ฏธ์ง ๋ค์ด๋ก๋
|
62 |
+
image_content = download_image(image_url)
|
63 |
+
|
64 |
# ์นํ
์ผ๋ก ๋ฐ์ดํฐ ์ ์ก
|
65 |
+
send_to_webhook(message, image_content)
|
66 |
|
67 |
return image_url
|
68 |
else:
|
|
|
71 |
logging.error("Error during API request: %s", str(e))
|
72 |
return "Failed to generate image due to an error."
|
73 |
|
|
|
|
|
74 |
css = """
|
75 |
footer {
|
76 |
visibility: hidden;
|