Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,9 @@ import logging
|
|
3 |
import os
|
4 |
from io import BytesIO
|
5 |
from gradio_client import Client
|
|
|
6 |
import subprocess
|
|
|
7 |
# λ‘κΉ
μ€μ
|
8 |
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s:%(levelname)s:%(name)s: %(message)s', handlers=[logging.StreamHandler()])
|
9 |
|
@@ -54,17 +56,19 @@ class MyClient(discord.Client):
|
|
54 |
)
|
55 |
# μ΄λ―Έμ§ μμ± ν μ€λͺ
μ 곡 λ° λν
|
56 |
await initiate_conversation(prompt, message)
|
|
|
|
|
57 |
except Exception as e:
|
58 |
-
logging.error(f'μ΄λ―Έμ§ μμ± μ€ μ€λ₯ λ°μ: {e}')
|
59 |
-
await message.channel.send("
|
60 |
finally:
|
61 |
self.is_processing = False
|
62 |
|
63 |
async def generate_image(self, prompt):
|
64 |
if not prompt:
|
65 |
-
raise ValueError("
|
66 |
|
67 |
-
logging.debug(f"
|
68 |
|
69 |
try:
|
70 |
result = api_client.predict(
|
@@ -77,19 +81,19 @@ class MyClient(discord.Client):
|
|
77 |
num_inference_steps=28,
|
78 |
api_name="/infer_t2i"
|
79 |
)
|
80 |
-
logging.debug(f"API
|
81 |
|
82 |
if isinstance(result, tuple) and len(result) == 3:
|
83 |
image_path, used_seed, translated_prompt = result
|
84 |
-
logging.info(f"
|
85 |
-
logging.info(f"
|
86 |
-
logging.info(f"
|
87 |
|
88 |
return image_path, used_seed, translated_prompt
|
89 |
else:
|
90 |
-
raise ValueError("
|
91 |
-
except
|
92 |
-
logging.error(f"Gradio
|
93 |
raise RuntimeError(f"API μλ² μ€λ₯: {str(e)}. μλ² κ΄λ¦¬μμκ² λ¬ΈμνμΈμ.")
|
94 |
except Exception as e:
|
95 |
logging.error(f'API μμ² μ€ μ€λ₯ λ°μ: {e}', exc_info=True)
|
|
|
3 |
import os
|
4 |
from io import BytesIO
|
5 |
from gradio_client import Client
|
6 |
+
from gradio_client import exceptions as gradio_client_exceptions
|
7 |
import subprocess
|
8 |
+
|
9 |
# λ‘κΉ
μ€μ
|
10 |
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s:%(levelname)s:%(name)s: %(message)s', handlers=[logging.StreamHandler()])
|
11 |
|
|
|
56 |
)
|
57 |
# μ΄λ―Έμ§ μμ± ν μ€λͺ
μ 곡 λ° λν
|
58 |
await initiate_conversation(prompt, message)
|
59 |
+
except RuntimeError as e:
|
60 |
+
await message.channel.send(f"μ΄λ―Έμ§ μμ± μ€ μ€λ₯κ° λ°μνμ΅λλ€: {str(e)}")
|
61 |
except Exception as e:
|
62 |
+
logging.error(f'μ΄λ―Έμ§ μμ± μ€ μμμΉ λͺ»ν μ€λ₯ λ°μ: {e}')
|
63 |
+
await message.channel.send("μ΄λ―Έμ§ μμ± μ€ μμμΉ λͺ»ν μ€λ₯κ° λ°μνμ΅λλ€. λμ€μ λ€μ μλν΄μ£ΌμΈμ.")
|
64 |
finally:
|
65 |
self.is_processing = False
|
66 |
|
67 |
async def generate_image(self, prompt):
|
68 |
if not prompt:
|
69 |
+
raise ValueError("ν둬ννΈκ° λΉμ΄μκ±°λ Noneμ
λλ€")
|
70 |
|
71 |
+
logging.debug(f"APIμ μμ² μ μ‘ μ€. ν둬ννΈ: {prompt}")
|
72 |
|
73 |
try:
|
74 |
result = api_client.predict(
|
|
|
81 |
num_inference_steps=28,
|
82 |
api_name="/infer_t2i"
|
83 |
)
|
84 |
+
logging.debug(f"API μλ΅ μμ : {result}")
|
85 |
|
86 |
if isinstance(result, tuple) and len(result) == 3:
|
87 |
image_path, used_seed, translated_prompt = result
|
88 |
+
logging.info(f"μμ±λ μ΄λ―Έμ§ κ²½λ‘: {image_path}")
|
89 |
+
logging.info(f"μ¬μ©λ μλ: {used_seed}")
|
90 |
+
logging.info(f"λ²μλ ν둬ννΈ: {translated_prompt}")
|
91 |
|
92 |
return image_path, used_seed, translated_prompt
|
93 |
else:
|
94 |
+
raise ValueError("μμμΉ λͺ»ν API μλ΅ νμ")
|
95 |
+
except gradio_client_exceptions.AppError as e:
|
96 |
+
logging.error(f"Gradio μ± μ€λ₯: {e}")
|
97 |
raise RuntimeError(f"API μλ² μ€λ₯: {str(e)}. μλ² κ΄λ¦¬μμκ² λ¬ΈμνμΈμ.")
|
98 |
except Exception as e:
|
99 |
logging.error(f'API μμ² μ€ μ€λ₯ λ°μ: {e}', exc_info=True)
|