Spaces:
Sleeping
Sleeping
sanbo
commited on
Commit
·
a8b1053
1
Parent(s):
5be1557
update sth. at 2024-11-15 19:02:05
Browse files
app.py
CHANGED
@@ -14,8 +14,12 @@ try:
|
|
14 |
|
15 |
# 图片生成模型 2 (FLUX)
|
16 |
client_image_2 = InferenceClient("black-forest-labs/FLUX.1-dev")
|
|
|
|
|
|
|
17 |
except Exception as e:
|
18 |
print(f"Error initializing clients: {e}")
|
|
|
19 |
|
20 |
# ---------- 文本聊天模块 ----------
|
21 |
def chat_with_model(messages):
|
@@ -54,7 +58,7 @@ def build_interface():
|
|
54 |
"""
|
55 |
with gr.Blocks() as demo:
|
56 |
# 服务状态显示区域
|
57 |
-
status_output = gr.Textbox(label="服务状态", value=
|
58 |
|
59 |
# 文本聊天模块
|
60 |
with gr.Tab("文本聊天"):
|
@@ -71,8 +75,8 @@ def build_interface():
|
|
71 |
# 图像生成模块
|
72 |
with gr.Tab("图像生成"):
|
73 |
image_prompt = gr.Textbox(label="图像提示词", placeholder="描述你想生成的图像")
|
74 |
-
image_output_1 = gr.Image(label="服务一生成的图像")
|
75 |
-
image_output_2 = gr.Image(label="服务二生成的图像")
|
76 |
image_button = gr.Button("生成图像")
|
77 |
|
78 |
# 处理图像生成请求
|
|
|
14 |
|
15 |
# 图片生成模型 2 (FLUX)
|
16 |
client_image_2 = InferenceClient("black-forest-labs/FLUX.1-dev")
|
17 |
+
|
18 |
+
# 更新状态为服务已启动
|
19 |
+
service_status = "服务已启动,您可以开始使用!"
|
20 |
except Exception as e:
|
21 |
print(f"Error initializing clients: {e}")
|
22 |
+
service_status = "服务初始化失败,请稍后再试。"
|
23 |
|
24 |
# ---------- 文本聊天模块 ----------
|
25 |
def chat_with_model(messages):
|
|
|
58 |
"""
|
59 |
with gr.Blocks() as demo:
|
60 |
# 服务状态显示区域
|
61 |
+
status_output = gr.Textbox(label="服务状态", value=service_status, interactive=False)
|
62 |
|
63 |
# 文本聊天模块
|
64 |
with gr.Tab("文本聊天"):
|
|
|
75 |
# 图像生成模块
|
76 |
with gr.Tab("图像生成"):
|
77 |
image_prompt = gr.Textbox(label="图像提示词", placeholder="描述你想生成的图像")
|
78 |
+
image_output_1 = gr.Image(label="服务一生成的图像", elem_id="image_1", interactive=True).style(width=320, height=320)
|
79 |
+
image_output_2 = gr.Image(label="服务二生成的图像", elem_id="image_2", interactive=True).style(width=320, height=320)
|
80 |
image_button = gr.Button("生成图像")
|
81 |
|
82 |
# 处理图像生成请求
|