Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -105,6 +105,12 @@ FPS, FRAMES_PER_CHUNK, LATENTS_PER_CHUNK = 24, 17, 5
|
|
| 105 |
# 15.083 s, and is refused.
|
| 106 |
MIN_UI_DURATION, MAX_UI_DURATION = 2, 14
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
SCHEDULES = {
|
| 109 |
"linear_quadratic · PlagueKind": "linear_quadratic",
|
| 110 |
"sgm_uniform": "sgm_uniform",
|
|
@@ -511,6 +517,7 @@ def _generate(
|
|
| 511 |
maximize_gpu,
|
| 512 |
video_shift,
|
| 513 |
audio_shift,
|
|
|
|
| 514 |
):
|
| 515 |
"""The only thing on GPU time: the denoise loop, the two decoders and the workflow's post chain.
|
| 516 |
The mp4 is muxed here rather than in the caller: a `@spaces.GPU` return crosses a process boundary by pickling,
|
|
@@ -548,7 +555,7 @@ def _generate(
|
|
| 548 |
requested_steps = steps if custom_schedule else steps + 1
|
| 549 |
|
| 550 |
started = time.time()
|
| 551 |
-
with pk.use_schedule(PIPE, steps, schedule, video_shift, audio_shift):
|
| 552 |
state = PIPE(
|
| 553 |
prompt_embeds=prompt_embeds.to("cuda"),
|
| 554 |
text_token_tags=text_token_tags,
|
|
@@ -616,6 +623,7 @@ def generate(
|
|
| 616 |
maximize_gpu=False,
|
| 617 |
video_shift=DEFAULT_VIDEO_SHIFT,
|
| 618 |
audio_shift=DEFAULT_AUDIO_SHIFT,
|
|
|
|
| 619 |
progress=gr.Progress(track_tqdm=True),
|
| 620 |
):
|
| 621 |
"""One request through the PlagueKind graph. Every parameter but the prompt carries the default its UI
|
|
@@ -677,6 +685,7 @@ def generate(
|
|
| 677 |
bool(maximize_gpu),
|
| 678 |
float(video_shift),
|
| 679 |
float(audio_shift),
|
|
|
|
| 680 |
)
|
| 681 |
# The same call `spaces` will book the worker with, so the report can show the fit against the measurement.
|
| 682 |
booked_seconds = get_duration(*call)
|
|
@@ -803,6 +812,12 @@ with gr.Blocks(title="PlagueKind · MiniMax-H3") as demo:
|
|
| 803 |
value=DEFAULT_STEPS,
|
| 804 |
info="PlagueKind: 15-20 on the linear_quadratic grid.",
|
| 805 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 806 |
schedule = gr.Dropdown(
|
| 807 |
label="Sigma schedule",
|
| 808 |
choices=list(SCHEDULES),
|
|
@@ -937,6 +952,7 @@ with gr.Blocks(title="PlagueKind · MiniMax-H3") as demo:
|
|
| 937 |
maximize_gpu,
|
| 938 |
video_shift,
|
| 939 |
audio_shift,
|
|
|
|
| 940 |
]
|
| 941 |
|
| 942 |
run.click(generate, controls, [video, report], api_name="generate")
|
|
|
|
| 105 |
# 15.083 s, and is refused.
|
| 106 |
MIN_UI_DURATION, MAX_UI_DURATION = 2, 14
|
| 107 |
|
| 108 |
+
SAMPLERS = {
|
| 109 |
+
"euler": "euler",
|
| 110 |
+
"euler ancestral": "euler_ancestral",
|
| 111 |
+
}
|
| 112 |
+
DEFAULT_SAMPLER = "euler"
|
| 113 |
+
|
| 114 |
SCHEDULES = {
|
| 115 |
"linear_quadratic · PlagueKind": "linear_quadratic",
|
| 116 |
"sgm_uniform": "sgm_uniform",
|
|
|
|
| 517 |
maximize_gpu,
|
| 518 |
video_shift,
|
| 519 |
audio_shift,
|
| 520 |
+
sampler,
|
| 521 |
):
|
| 522 |
"""The only thing on GPU time: the denoise loop, the two decoders and the workflow's post chain.
|
| 523 |
The mp4 is muxed here rather than in the caller: a `@spaces.GPU` return crosses a process boundary by pickling,
|
|
|
|
| 555 |
requested_steps = steps if custom_schedule else steps + 1
|
| 556 |
|
| 557 |
started = time.time()
|
| 558 |
+
with pk.use_schedule(PIPE, steps, schedule, video_shift, audio_shift, sampler_name=sampler, seed=int(seed)):
|
| 559 |
state = PIPE(
|
| 560 |
prompt_embeds=prompt_embeds.to("cuda"),
|
| 561 |
text_token_tags=text_token_tags,
|
|
|
|
| 623 |
maximize_gpu=False,
|
| 624 |
video_shift=DEFAULT_VIDEO_SHIFT,
|
| 625 |
audio_shift=DEFAULT_AUDIO_SHIFT,
|
| 626 |
+
sampler=DEFAULT_SAMPLER,
|
| 627 |
progress=gr.Progress(track_tqdm=True),
|
| 628 |
):
|
| 629 |
"""One request through the PlagueKind graph. Every parameter but the prompt carries the default its UI
|
|
|
|
| 685 |
bool(maximize_gpu),
|
| 686 |
float(video_shift),
|
| 687 |
float(audio_shift),
|
| 688 |
+
SAMPLERS.get(sampler, "euler"),
|
| 689 |
)
|
| 690 |
# The same call `spaces` will book the worker with, so the report can show the fit against the measurement.
|
| 691 |
booked_seconds = get_duration(*call)
|
|
|
|
| 812 |
value=DEFAULT_STEPS,
|
| 813 |
info="PlagueKind: 15-20 on the linear_quadratic grid.",
|
| 814 |
)
|
| 815 |
+
sampler = gr.Dropdown(
|
| 816 |
+
label="Sampler",
|
| 817 |
+
choices=list(SAMPLERS),
|
| 818 |
+
value=DEFAULT_SAMPLER,
|
| 819 |
+
info="`euler ancestral` re-injects noise each step — expect seed to matter more.",
|
| 820 |
+
)
|
| 821 |
schedule = gr.Dropdown(
|
| 822 |
label="Sigma schedule",
|
| 823 |
choices=list(SCHEDULES),
|
|
|
|
| 952 |
maximize_gpu,
|
| 953 |
video_shift,
|
| 954 |
audio_shift,
|
| 955 |
+
sampler,
|
| 956 |
]
|
| 957 |
|
| 958 |
run.click(generate, controls, [video, report], api_name="generate")
|