Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -81,16 +81,16 @@ def generate_image(prompt, base="写实风格", motion="", step=8, progress=gr.P
|
|
81 |
|
82 |
# Gradio Interface
|
83 |
with gr.Blocks(css="style.css") as demo:
|
84 |
-
#
|
85 |
-
with gr.
|
86 |
-
gr.HTML("<h1><center
|
87 |
username = gr.Textbox(label="用户名")
|
88 |
password = gr.Textbox(label="密码", type="password")
|
89 |
login_button = gr.Button("登录")
|
90 |
login_msg = gr.Textbox(label="登录状态", interactive=False)
|
91 |
|
92 |
# 主界面
|
93 |
-
with gr.
|
94 |
gr.HTML(
|
95 |
"<h1><center>officechat即时视频生成系统</center></h1>" +
|
96 |
"<p><center><span style='color: red;'>如果生成效果不理想,可以将步数从4调整到8。</span></center></p>" +
|
@@ -171,22 +171,24 @@ with gr.Blocks(css="style.css") as demo:
|
|
171 |
cache_examples="lazy",
|
172 |
)
|
173 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
# 登录逻辑
|
175 |
def handle_login(username, password):
|
176 |
success, message = login(username, password)
|
177 |
if success:
|
178 |
-
|
179 |
-
|
180 |
-
return message, gr.update(selected="视频生成")
|
181 |
-
return message, gr.update(selected="登录")
|
182 |
|
183 |
login_button.click(
|
184 |
fn=handle_login,
|
185 |
inputs=[username, password],
|
186 |
-
outputs=[login_msg,
|
187 |
)
|
188 |
|
189 |
-
# 设置初始状态
|
190 |
-
video_tab.visible = False
|
191 |
-
|
192 |
demo.queue().launch()
|
|
|
81 |
|
82 |
# Gradio Interface
|
83 |
with gr.Blocks(css="style.css") as demo:
|
84 |
+
# 创建两个界面容器
|
85 |
+
with gr.Group(visible=True) as login_container:
|
86 |
+
gr.HTML("<h1><center>视频生成系统登录</center></h1>")
|
87 |
username = gr.Textbox(label="用户名")
|
88 |
password = gr.Textbox(label="密码", type="password")
|
89 |
login_button = gr.Button("登录")
|
90 |
login_msg = gr.Textbox(label="登录状态", interactive=False)
|
91 |
|
92 |
# 主界面
|
93 |
+
with gr.Group(visible=False) as main_container:
|
94 |
gr.HTML(
|
95 |
"<h1><center>officechat即时视频生成系统</center></h1>" +
|
96 |
"<p><center><span style='color: red;'>如果生成效果不理想,可以将步数从4调整到8。</span></center></p>" +
|
|
|
171 |
cache_examples="lazy",
|
172 |
)
|
173 |
|
174 |
+
# 生成按钮事件
|
175 |
+
submit.click(
|
176 |
+
fn=generate_image,
|
177 |
+
inputs=[prompt, select_base, select_motion, select_step],
|
178 |
+
outputs=[video]
|
179 |
+
)
|
180 |
+
|
181 |
# 登录逻辑
|
182 |
def handle_login(username, password):
|
183 |
success, message = login(username, password)
|
184 |
if success:
|
185 |
+
return message, gr.update(visible=False), gr.update(visible=True)
|
186 |
+
return message, gr.update(visible=True), gr.update(visible=False)
|
|
|
|
|
187 |
|
188 |
login_button.click(
|
189 |
fn=handle_login,
|
190 |
inputs=[username, password],
|
191 |
+
outputs=[login_msg, login_container, main_container]
|
192 |
)
|
193 |
|
|
|
|
|
|
|
194 |
demo.queue().launch()
|