Spaces:
Sleeping
Sleeping
VictorKai1996NUS
commited on
Commit
•
52a6c7f
1
Parent(s):
540e7b2
Update app.py
Browse files
app.py
CHANGED
@@ -14,6 +14,9 @@ from videosys.models.cogvideo.pipeline import CogVideoPABConfig
|
|
14 |
import psutil
|
15 |
import GPUtil
|
16 |
|
|
|
|
|
|
|
17 |
|
18 |
|
19 |
logging.basicConfig(level=logging.INFO)
|
@@ -234,14 +237,29 @@ with gr.Blocks(css=css) as demo:
|
|
234 |
with gr.Row():
|
235 |
generate_button = gr.Button("🎬 Generate Video")
|
236 |
generate_button_vs = gr.Button("⚡️ Generate Video with VideoSys (Faster)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
with gr.Row(elem_classes="server-status"):
|
238 |
gr.Markdown("#### Server Status")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
with gr.Row():
|
240 |
-
|
241 |
-
memory_status = gr.Textbox(label="Memory", scale=1)
|
242 |
-
disk_status = gr.Textbox(label="Disk", scale=1)
|
243 |
-
gpu_status = gr.Textbox(label="GPU Memory", scale=1)
|
244 |
-
refresh_button = gr.Button("Refresh", scale=1, size="sm")
|
245 |
|
246 |
with gr.Column():
|
247 |
with gr.Row():
|
@@ -258,7 +276,18 @@ with gr.Blocks(css=css) as demo:
|
|
258 |
task_status = gr.Textbox(label="任务状态", visible=False)
|
259 |
|
260 |
|
261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
|
263 |
def generate_vanilla(prompt, num_inference_steps, guidance_scale, progress=gr.Progress(track_tqdm=True)):
|
264 |
engine = load_model()
|
@@ -267,7 +296,7 @@ with gr.Blocks(css=css) as demo:
|
|
267 |
elapsed_time = time() - t
|
268 |
video_update = gr.update(visible=True, value=video_path)
|
269 |
elapsed_time = gr.update(visible=True, value=f"{elapsed_time:.2f}s")
|
270 |
-
|
271 |
return video_path, video_update, elapsed_time
|
272 |
|
273 |
def generate_vs(prompt, num_inference_steps, guidance_scale, threshold, gap, progress=gr.Progress(track_tqdm=True)):
|
@@ -279,7 +308,7 @@ with gr.Blocks(css=css) as demo:
|
|
279 |
elapsed_time = time() - t
|
280 |
video_update = gr.update(visible=True, value=video_path)
|
281 |
elapsed_time = gr.update(visible=True, value=f"{elapsed_time:.2f}s")
|
282 |
-
|
283 |
return video_path, video_update, elapsed_time
|
284 |
|
285 |
def enhance_prompt_func(prompt):
|
@@ -315,17 +344,26 @@ with gr.Blocks(css=css) as demo:
|
|
315 |
status['disk'],
|
316 |
status['gpu_memory']
|
317 |
)
|
318 |
-
|
|
|
319 |
generate_button.click(
|
320 |
-
|
321 |
-
inputs=[prompt, num_inference_steps, guidance_scale],
|
322 |
-
outputs=[
|
|
|
|
|
|
|
|
|
323 |
)
|
324 |
-
|
325 |
generate_button_vs.click(
|
326 |
-
|
327 |
-
inputs=[prompt, num_inference_steps, guidance_scale, pab_threshold, pab_gap],
|
328 |
-
outputs=[
|
|
|
|
|
|
|
|
|
329 |
)
|
330 |
|
331 |
enhance_button.click(enhance_prompt_func, inputs=[prompt], outputs=[prompt])
|
|
|
14 |
import psutil
|
15 |
import GPUtil
|
16 |
|
17 |
+
import threading
|
18 |
+
task_running = threading.Event()
|
19 |
+
|
20 |
|
21 |
|
22 |
logging.basicConfig(level=logging.INFO)
|
|
|
237 |
with gr.Row():
|
238 |
generate_button = gr.Button("🎬 Generate Video")
|
239 |
generate_button_vs = gr.Button("⚡️ Generate Video with VideoSys (Faster)")
|
240 |
+
# with gr.Row(elem_classes="server-status"):
|
241 |
+
# gr.Markdown("#### Server Status")
|
242 |
+
# with gr.Row():
|
243 |
+
# cpu_status = gr.Textbox(label="CPU", scale=1)
|
244 |
+
# memory_status = gr.Textbox(label="Memory", scale=1)
|
245 |
+
# disk_status = gr.Textbox(label="Disk", scale=1)
|
246 |
+
# gpu_status = gr.Textbox(label="GPU Memory", scale=1)
|
247 |
+
# refresh_button = gr.Button("Refresh", scale=1, size="sm")
|
248 |
with gr.Row(elem_classes="server-status"):
|
249 |
gr.Markdown("#### Server Status")
|
250 |
+
with gr.Column():
|
251 |
+
with gr.Row():
|
252 |
+
with gr.Column(scale=1):
|
253 |
+
cpu_status = gr.Textbox(label="CPU")
|
254 |
+
with gr.Column(scale=1):
|
255 |
+
memory_status = gr.Textbox(label="Memory")
|
256 |
+
with gr.Row():
|
257 |
+
with gr.Column(scale=1):
|
258 |
+
disk_status = gr.Textbox(label="Disk")
|
259 |
+
with gr.Column(scale=1):
|
260 |
+
gpu_status = gr.Textbox(label="GPU Memory")
|
261 |
with gr.Row():
|
262 |
+
refresh_button = gr.Button("Refresh", scale=1, size="sm")
|
|
|
|
|
|
|
|
|
263 |
|
264 |
with gr.Column():
|
265 |
with gr.Row():
|
|
|
276 |
task_status = gr.Textbox(label="任务状态", visible=False)
|
277 |
|
278 |
|
279 |
+
|
280 |
+
|
281 |
+
def run_task(func, *args):
|
282 |
+
if task_running.is_set():
|
283 |
+
return None, gr.update(value="Please wait for another running end", visible=True), gr.update(visible=False)
|
284 |
+
|
285 |
+
task_running.set()
|
286 |
+
try:
|
287 |
+
result = func(*args)
|
288 |
+
return result, gr.update(visible=False), gr.update(visible=True)
|
289 |
+
finally:
|
290 |
+
task_running.clear()
|
291 |
|
292 |
def generate_vanilla(prompt, num_inference_steps, guidance_scale, progress=gr.Progress(track_tqdm=True)):
|
293 |
engine = load_model()
|
|
|
296 |
elapsed_time = time() - t
|
297 |
video_update = gr.update(visible=True, value=video_path)
|
298 |
elapsed_time = gr.update(visible=True, value=f"{elapsed_time:.2f}s")
|
299 |
+
|
300 |
return video_path, video_update, elapsed_time
|
301 |
|
302 |
def generate_vs(prompt, num_inference_steps, guidance_scale, threshold, gap, progress=gr.Progress(track_tqdm=True)):
|
|
|
308 |
elapsed_time = time() - t
|
309 |
video_update = gr.update(visible=True, value=video_path)
|
310 |
elapsed_time = gr.update(visible=True, value=f"{elapsed_time:.2f}s")
|
311 |
+
|
312 |
return video_path, video_update, elapsed_time
|
313 |
|
314 |
def enhance_prompt_func(prompt):
|
|
|
344 |
status['disk'],
|
345 |
status['gpu_memory']
|
346 |
)
|
347 |
+
|
348 |
+
|
349 |
generate_button.click(
|
350 |
+
run_task,
|
351 |
+
inputs=[gr.Textbox(value=str(generate_vanilla), visible=False), prompt, num_inference_steps, guidance_scale],
|
352 |
+
outputs=[
|
353 |
+
gr.Group([video_output, download_video_button, elapsed_time]),
|
354 |
+
task_status,
|
355 |
+
gr.Group([generate_button, generate_button_vs])
|
356 |
+
]
|
357 |
)
|
358 |
+
|
359 |
generate_button_vs.click(
|
360 |
+
run_task,
|
361 |
+
inputs=[gr.Textbox(value=str(generate_vs), visible=False), prompt, num_inference_steps, guidance_scale, pab_threshold, pab_gap],
|
362 |
+
outputs=[
|
363 |
+
gr.Group([video_output_vs, download_video_button_vs, elapsed_time_vs]),
|
364 |
+
task_status,
|
365 |
+
gr.Group([generate_button, generate_button_vs])
|
366 |
+
]
|
367 |
)
|
368 |
|
369 |
enhance_button.click(enhance_prompt_func, inputs=[prompt], outputs=[prompt])
|