Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -415,6 +415,7 @@ def get_inference_duration(
|
|
| 415 |
frame_multiplier,
|
| 416 |
quality,
|
| 417 |
duration_seconds,
|
|
|
|
| 418 |
progress
|
| 419 |
):
|
| 420 |
BASE_FRAMES_HEIGHT_WIDTH = 81 * 832 * 624
|
|
@@ -425,7 +426,7 @@ def get_inference_duration(
|
|
| 425 |
gen_time = int(steps) * step_duration
|
| 426 |
|
| 427 |
if guidance_scale > 1:
|
| 428 |
-
gen_time = gen_time * 1.
|
| 429 |
|
| 430 |
frame_factor = frame_multiplier // FIXED_FPS
|
| 431 |
if frame_factor > 1:
|
|
@@ -433,7 +434,11 @@ def get_inference_duration(
|
|
| 433 |
inter_time = (total_out_frames * 0.02)
|
| 434 |
gen_time += inter_time
|
| 435 |
|
| 436 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 437 |
|
| 438 |
|
| 439 |
@spaces.GPU(duration=get_inference_duration)
|
|
@@ -452,6 +457,7 @@ def run_inference(
|
|
| 452 |
frame_multiplier,
|
| 453 |
quality,
|
| 454 |
duration_seconds,
|
|
|
|
| 455 |
progress=gr.Progress(track_tqdm=True),
|
| 456 |
):
|
| 457 |
scheduler_class = SCHEDULER_MAP.get(scheduler_name)
|
|
@@ -528,6 +534,7 @@ def generate_video(
|
|
| 528 |
scheduler="UniPCMultistep",
|
| 529 |
flow_shift=6.0,
|
| 530 |
frame_multiplier=16,
|
|
|
|
| 531 |
video_component=True,
|
| 532 |
progress=gr.Progress(track_tqdm=True),
|
| 533 |
):
|
|
@@ -602,6 +609,7 @@ def generate_video(
|
|
| 602 |
frame_multiplier,
|
| 603 |
quality,
|
| 604 |
duration_seconds,
|
|
|
|
| 605 |
progress,
|
| 606 |
)
|
| 607 |
print(f"GPU complete: {task_n}")
|
|
@@ -639,6 +647,11 @@ with gr.Blocks(delete_cache=(3600, 10800)) as demo:
|
|
| 639 |
label="Video Fluidity (Frames per Second)",
|
| 640 |
info="Extra frames will be generated using flow estimation, which estimates motion between frames to make the video smoother."
|
| 641 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 642 |
with gr.Accordion("Advanced Settings", open=False):
|
| 643 |
last_image_component = gr.Image(type="pil", label="Last Image (Optional)", sources=["upload", "clipboard"])
|
| 644 |
negative_prompt_input = gr.Textbox(label="Negative Prompt", value=default_negative_prompt, info="Used if any Guidance Scale > 1.", lines=3)
|
|
@@ -681,6 +694,7 @@ with gr.Blocks(delete_cache=(3600, 10800)) as demo:
|
|
| 681 |
negative_prompt_input, duration_seconds_input,
|
| 682 |
guidance_scale_input, guidance_scale_2_input, seed_input, randomize_seed_checkbox,
|
| 683 |
quality_slider, scheduler_dropdown, flow_shift_slider, frame_multi,
|
|
|
|
| 684 |
play_result_video
|
| 685 |
]
|
| 686 |
|
|
|
|
| 415 |
frame_multiplier,
|
| 416 |
quality,
|
| 417 |
duration_seconds,
|
| 418 |
+
safe_mode,
|
| 419 |
progress
|
| 420 |
):
|
| 421 |
BASE_FRAMES_HEIGHT_WIDTH = 81 * 832 * 624
|
|
|
|
| 426 |
gen_time = int(steps) * step_duration
|
| 427 |
|
| 428 |
if guidance_scale > 1:
|
| 429 |
+
gen_time = gen_time * 1.9
|
| 430 |
|
| 431 |
frame_factor = frame_multiplier // FIXED_FPS
|
| 432 |
if frame_factor > 1:
|
|
|
|
| 434 |
inter_time = (total_out_frames * 0.02)
|
| 435 |
gen_time += inter_time
|
| 436 |
|
| 437 |
+
total_time = 15 + gen_time
|
| 438 |
+
if safe_mode:
|
| 439 |
+
total_time = total_time * 1.20
|
| 440 |
+
|
| 441 |
+
return total_time
|
| 442 |
|
| 443 |
|
| 444 |
@spaces.GPU(duration=get_inference_duration)
|
|
|
|
| 457 |
frame_multiplier,
|
| 458 |
quality,
|
| 459 |
duration_seconds,
|
| 460 |
+
safe_mode=False,
|
| 461 |
progress=gr.Progress(track_tqdm=True),
|
| 462 |
):
|
| 463 |
scheduler_class = SCHEDULER_MAP.get(scheduler_name)
|
|
|
|
| 534 |
scheduler="UniPCMultistep",
|
| 535 |
flow_shift=6.0,
|
| 536 |
frame_multiplier=16,
|
| 537 |
+
safe_mode=False,
|
| 538 |
video_component=True,
|
| 539 |
progress=gr.Progress(track_tqdm=True),
|
| 540 |
):
|
|
|
|
| 609 |
frame_multiplier,
|
| 610 |
quality,
|
| 611 |
duration_seconds,
|
| 612 |
+
safe_mode,
|
| 613 |
progress,
|
| 614 |
)
|
| 615 |
print(f"GPU complete: {task_n}")
|
|
|
|
| 647 |
label="Video Fluidity (Frames per Second)",
|
| 648 |
info="Extra frames will be generated using flow estimation, which estimates motion between frames to make the video smoother."
|
| 649 |
)
|
| 650 |
+
safe_mode_checkbox = gr.Checkbox(
|
| 651 |
+
label="🛠️ Safe Mode",
|
| 652 |
+
value=False,
|
| 653 |
+
info="Requests 20% extra processing time to try to prevent unfinished tasks when the server is busy."
|
| 654 |
+
)
|
| 655 |
with gr.Accordion("Advanced Settings", open=False):
|
| 656 |
last_image_component = gr.Image(type="pil", label="Last Image (Optional)", sources=["upload", "clipboard"])
|
| 657 |
negative_prompt_input = gr.Textbox(label="Negative Prompt", value=default_negative_prompt, info="Used if any Guidance Scale > 1.", lines=3)
|
|
|
|
| 694 |
negative_prompt_input, duration_seconds_input,
|
| 695 |
guidance_scale_input, guidance_scale_2_input, seed_input, randomize_seed_checkbox,
|
| 696 |
quality_slider, scheduler_dropdown, flow_shift_slider, frame_multi,
|
| 697 |
+
safe_mode_checkbox,
|
| 698 |
play_result_video
|
| 699 |
]
|
| 700 |
|