Spaces:
Build error
Build error
Update simple_app.py
Browse files- simple_app.py +18 -56
simple_app.py
CHANGED
@@ -184,19 +184,6 @@ def infer(prompt, video_size, frame_num, progress=gr.Progress(track_tqdm=True)):
|
|
184 |
raise Exception("Error executing command")
|
185 |
|
186 |
|
187 |
-
# 创建一个信息面板,告知用户处理时间
|
188 |
-
def create_info_block():
|
189 |
-
return gr.Markdown("""
|
190 |
-
# Wan 2.1 T2V Model Information
|
191 |
-
|
192 |
-
**Processing Time Expectations:**
|
193 |
-
- 10-30 frames: ~2-5 minutes
|
194 |
-
- 40-60 frames: ~5-10 minutes
|
195 |
-
- 81 frames: ~10-15 minutes
|
196 |
-
|
197 |
-
Processing time depends on your GPU model and current system load.
|
198 |
-
""")
|
199 |
-
|
200 |
with gr.Blocks() as demo:
|
201 |
with gr.Column():
|
202 |
gr.Markdown("# Wan 2.1 1.3B")
|
@@ -215,53 +202,28 @@ with gr.Blocks() as demo:
|
|
215 |
</div>
|
216 |
"""
|
217 |
)
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
value=SIZE_OPTIONS[0], # 默认选择第一个分辨率
|
233 |
-
label="Video Size (Resolution)",
|
234 |
-
)
|
235 |
-
frame_num_slider = gr.Slider(
|
236 |
-
minimum=FRAME_NUM_OPTIONS[0], # 最小帧数
|
237 |
-
maximum=FRAME_NUM_OPTIONS[-1], # 最大帧数
|
238 |
-
value=30, # 设置一个合理的默认帧数,避免处理时间过长
|
239 |
-
step=10, # 增加步长,更容易选择
|
240 |
-
label="Frame Number (Video Length)",
|
241 |
-
)
|
242 |
|
243 |
-
submit_btn = gr.Button("
|
244 |
-
|
245 |
-
with gr.Column():
|
246 |
-
video_res = gr.Video(label="Generated Video")
|
247 |
-
with gr.Column():
|
248 |
-
gallery = gr.Gallery(label="Preview Frames", show_label=True, elem_id="gallery").style(grid=3, height="auto")
|
249 |
|
250 |
submit_btn.click(
|
251 |
fn=infer,
|
252 |
-
inputs=[prompt, video_size_dropdown, frame_num_slider],
|
253 |
outputs=[video_res],
|
254 |
-
api_name="generate" # 添加API名称,方便调用
|
255 |
)
|
256 |
|
257 |
-
|
258 |
-
demo.queue(
|
259 |
-
concurrency_count=1, # 视频生成计算密集,一次只处理一个请求
|
260 |
-
max_size=20, # 队列最大容量
|
261 |
-
status_update_rate=10, # 状态更新频率(秒)
|
262 |
-
default_concurrency_limit=1 # 默认并发限制
|
263 |
-
).launch(
|
264 |
-
share=False, # 不公开分享
|
265 |
-
show_error=True, # 显示详细错误信息
|
266 |
-
show_api=False # 不显示API文档
|
267 |
-
)
|
|
|
184 |
raise Exception("Error executing command")
|
185 |
|
186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
with gr.Blocks() as demo:
|
188 |
with gr.Column():
|
189 |
gr.Markdown("# Wan 2.1 1.3B")
|
|
|
202 |
</div>
|
203 |
"""
|
204 |
)
|
205 |
+
prompt = gr.Textbox(label="Prompt")
|
206 |
+
|
207 |
+
video_size_dropdown = gr.Dropdown(
|
208 |
+
choices=SIZE_OPTIONS,
|
209 |
+
value=SIZE_OPTIONS[0], # 默认选择第一个分辨率
|
210 |
+
label="Video Size (Resolution)",
|
211 |
+
)
|
212 |
+
frame_num_slider = gr.Slider(
|
213 |
+
minimum=FRAME_NUM_OPTIONS[0], # 最小帧数
|
214 |
+
maximum=FRAME_NUM_OPTIONS[-1], # 最大帧数
|
215 |
+
value=FRAME_NUM_OPTIONS[2], # 默认帧数 (例如,选择列表的第三个)
|
216 |
+
step=1, # 步长为 1
|
217 |
+
label="Frame Number (Video Length)",
|
218 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
|
220 |
+
submit_btn = gr.Button("Submit")
|
221 |
+
video_res = gr.Video(label="Generated Video")
|
|
|
|
|
|
|
|
|
222 |
|
223 |
submit_btn.click(
|
224 |
fn=infer,
|
225 |
+
inputs=[prompt, video_size_dropdown, frame_num_slider], # inputs 添加 video_size_dropdown, frame_num_slider
|
226 |
outputs=[video_res],
|
|
|
227 |
)
|
228 |
|
229 |
+
demo.queue().launch(share=False, show_error=True, show_api=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|