Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,8 +10,8 @@ logging.basicConfig(level=logging.INFO)
|
|
10 |
api_client = Client("http://211.233.58.202:7960/")
|
11 |
|
12 |
def respond(message):
|
13 |
-
if message.endswith(
|
14 |
-
return message
|
15 |
|
16 |
logging.info("Received message: %s", message)
|
17 |
|
@@ -31,15 +31,15 @@ def respond(message):
|
|
31 |
|
32 |
# 결과 확인 및 처리
|
33 |
if isinstance(result, dict) and 'url' in result:
|
34 |
-
return
|
35 |
elif isinstance(result, tuple):
|
36 |
logging.error("Unexpected tuple response: %s", result)
|
37 |
-
return
|
38 |
else:
|
39 |
raise ValueError("Unexpected API response format")
|
40 |
except Exception as e:
|
41 |
logging.error("Error during API request: %s", str(e))
|
42 |
-
return
|
43 |
|
44 |
css = """
|
45 |
footer {
|
@@ -73,10 +73,7 @@ examples = [
|
|
73 |
demo = gr.Interface(
|
74 |
fn=respond,
|
75 |
inputs=gr.Textbox(label="Enter your prompt for image generation"),
|
76 |
-
outputs=
|
77 |
-
gr.Textbox(label="Prompt"),
|
78 |
-
gr.Image(label="Generated Image")
|
79 |
-
],
|
80 |
examples=examples,
|
81 |
theme="Nymbo/Nymbo_Theme",
|
82 |
css=css,
|
|
|
10 |
api_client = Client("http://211.233.58.202:7960/")
|
11 |
|
12 |
def respond(message):
|
13 |
+
if message.endswith('.webp'):
|
14 |
+
return message # 이미지 파일명만 반환
|
15 |
|
16 |
logging.info("Received message: %s", message)
|
17 |
|
|
|
31 |
|
32 |
# 결과 확인 및 처리
|
33 |
if isinstance(result, dict) and 'url' in result:
|
34 |
+
return result['url']
|
35 |
elif isinstance(result, tuple):
|
36 |
logging.error("Unexpected tuple response: %s", result)
|
37 |
+
return result[0]
|
38 |
else:
|
39 |
raise ValueError("Unexpected API response format")
|
40 |
except Exception as e:
|
41 |
logging.error("Error during API request: %s", str(e))
|
42 |
+
return "Failed to generate image due to an error."
|
43 |
|
44 |
css = """
|
45 |
footer {
|
|
|
73 |
demo = gr.Interface(
|
74 |
fn=respond,
|
75 |
inputs=gr.Textbox(label="Enter your prompt for image generation"),
|
76 |
+
outputs=gr.Image(label="Generated Image"),
|
|
|
|
|
|
|
77 |
examples=examples,
|
78 |
theme="Nymbo/Nymbo_Theme",
|
79 |
css=css,
|