Spaces:
Running on Zero
Running on Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,6 +19,8 @@ from functools import cache
|
|
| 19 |
import spaces
|
| 20 |
import gradio as gr
|
| 21 |
|
|
|
|
|
|
|
| 22 |
MODEL_REPO = os.environ.get("H3_MODEL_REPO", "MiniMaxAI/MiniMax-H3")
|
| 23 |
CONDITIONER_SPACE = os.environ.get("H3_CONDITIONER", "dagloop5/qwen3vl-conditioner")
|
| 24 |
# `pack` moves only `transformer_ref` onto the card at startup, the same way fl2va scopes this to its own
|
|
@@ -67,6 +69,29 @@ CANVASES = {
|
|
| 67 |
"1536x672 · 21:9 full": (672, 1536),
|
| 68 |
}
|
| 69 |
DEFAULT_CANVAS = "960x544 · 16:9 fast"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
FPS, FRAMES_PER_CHUNK, LATENTS_PER_CHUNK = 24, 17, 5
|
| 71 |
# It is the *snapped* frame count the ceiling has to hold for: 15 s is 360 frames, which rounds up to 362, i.e.
|
| 72 |
# 15.083 s, and is refused. 14 is the last whole second that survives the snap.
|
|
@@ -183,6 +208,8 @@ def get_duration(
|
|
| 183 |
PIPE = None
|
| 184 |
MANAGER = None
|
| 185 |
LOAD_ERROR: str | None = None
|
|
|
|
|
|
|
| 186 |
|
| 187 |
|
| 188 |
def load_models() -> str | None:
|
|
@@ -196,7 +223,7 @@ def load_models() -> str | None:
|
|
| 196 |
the 150 GB quota (`OSError: [Errno 28] No space left on device` out of `os.posix_fallocate`, mid-pack); the
|
| 197 |
~61.7 GB `transformer_ref` alone fits, same as fl2va's `transformer`.
|
| 198 |
"""
|
| 199 |
-
global PIPE, MANAGER, LOAD_ERROR
|
| 200 |
|
| 201 |
if PIPE is not None or LOAD_ERROR is not None:
|
| 202 |
return LOAD_ERROR
|
|
@@ -246,6 +273,15 @@ def load_models() -> str | None:
|
|
| 246 |
f"**Loading `{MODEL_REPO}` failed** after {time.time() - started:.0f}s: "
|
| 247 |
f"`{type(error).__name__}: {error}`"
|
| 248 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
return LOAD_ERROR
|
| 250 |
|
| 251 |
|
|
@@ -594,6 +630,24 @@ with gr.Blocks(title="MiniMax-H3 Reference Custom Lora") as demo:
|
|
| 594 |
label="Duration (s)", minimum=MIN_DURATION, maximum=MAX_UI_DURATION, step=1, value=5
|
| 595 |
)
|
| 596 |
steps = gr.Slider(label="Steps", minimum=MIN_STEPS, maximum=40, step=1, value=28)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 597 |
seed = gr.Number(label="Seed", value=42, precision=0)
|
| 598 |
|
| 599 |
with gr.Column():
|
|
|
|
| 19 |
import spaces
|
| 20 |
import gradio as gr
|
| 21 |
|
| 22 |
+
import pk_workflow as pk
|
| 23 |
+
|
| 24 |
MODEL_REPO = os.environ.get("H3_MODEL_REPO", "MiniMaxAI/MiniMax-H3")
|
| 25 |
CONDITIONER_SPACE = os.environ.get("H3_CONDITIONER", "dagloop5/qwen3vl-conditioner")
|
| 26 |
# `pack` moves only `transformer_ref` onto the card at startup, the same way fl2va scopes this to its own
|
|
|
|
| 69 |
"1536x672 · 21:9 full": (672, 1536),
|
| 70 |
}
|
| 71 |
DEFAULT_CANVAS = "960x544 · 16:9 fast"
|
| 72 |
+
|
| 73 |
+
# Only the three plain scheduler.step() samplers from the fl2va Space — the SDE-family and two-evaluation
|
| 74 |
+
# samplers (dpmpp_2m/3m_sde_gpu, dpmpp_2s_ancestral, dpmpp_sde_gpu, seeds_2) aren't ported here.
|
| 75 |
+
SAMPLERS = {
|
| 76 |
+
"euler": "euler",
|
| 77 |
+
"euler ancestral": "euler_ancestral",
|
| 78 |
+
"er_sde": "er_sde",
|
| 79 |
+
}
|
| 80 |
+
DEFAULT_SAMPLER = "euler"
|
| 81 |
+
|
| 82 |
+
SCHEDULES = {
|
| 83 |
+
"linear_quadratic · PlagueKind": "linear_quadratic",
|
| 84 |
+
"sgm_uniform": "sgm_uniform",
|
| 85 |
+
"simple": "simple",
|
| 86 |
+
"beta": "beta",
|
| 87 |
+
"ddim_uniform": "ddim_uniform",
|
| 88 |
+
"normal": "normal",
|
| 89 |
+
"native (pipeline default)": "native",
|
| 90 |
+
}
|
| 91 |
+
DEFAULT_SCHEDULE = "linear_quadratic · PlagueKind"
|
| 92 |
+
DEFAULT_VIDEO_SHIFT = 12.0
|
| 93 |
+
DEFAULT_AUDIO_SHIFT = 3.0
|
| 94 |
+
|
| 95 |
FPS, FRAMES_PER_CHUNK, LATENTS_PER_CHUNK = 24, 17, 5
|
| 96 |
# It is the *snapped* frame count the ceiling has to hold for: 15 s is 360 frames, which rounds up to 362, i.e.
|
| 97 |
# 15.083 s, and is refused. 14 is the last whole second that survives the snap.
|
|
|
|
| 208 |
PIPE = None
|
| 209 |
MANAGER = None
|
| 210 |
LOAD_ERROR: str | None = None
|
| 211 |
+
FILM = None
|
| 212 |
+
FILM_ERROR: str | None = None
|
| 213 |
|
| 214 |
|
| 215 |
def load_models() -> str | None:
|
|
|
|
| 223 |
the 150 GB quota (`OSError: [Errno 28] No space left on device` out of `os.posix_fallocate`, mid-pack); the
|
| 224 |
~61.7 GB `transformer_ref` alone fits, same as fl2va's `transformer`.
|
| 225 |
"""
|
| 226 |
+
global PIPE, MANAGER, LOAD_ERROR, FILM, FILM_ERROR
|
| 227 |
|
| 228 |
if PIPE is not None or LOAD_ERROR is not None:
|
| 229 |
return LOAD_ERROR
|
|
|
|
| 273 |
f"**Loading `{MODEL_REPO}` failed** after {time.time() - started:.0f}s: "
|
| 274 |
f"`{type(error).__name__}: {error}`"
|
| 275 |
)
|
| 276 |
+
|
| 277 |
+
# 69 MB of post-processing, and the demo is still a demo without it, so a failure here is not fatal.
|
| 278 |
+
try:
|
| 279 |
+
FILM = pk.load_film()
|
| 280 |
+
print("[ref2va] FILM loaded", flush=True)
|
| 281 |
+
except Exception as error:
|
| 282 |
+
FILM_ERROR = f"{type(error).__name__}: {error}"
|
| 283 |
+
print(f"[ref2va] FILM unavailable ({FILM_ERROR}); frame interpolation disabled", flush=True)
|
| 284 |
+
|
| 285 |
return LOAD_ERROR
|
| 286 |
|
| 287 |
|
|
|
|
| 630 |
label="Duration (s)", minimum=MIN_DURATION, maximum=MAX_UI_DURATION, step=1, value=5
|
| 631 |
)
|
| 632 |
steps = gr.Slider(label="Steps", minimum=MIN_STEPS, maximum=40, step=1, value=28)
|
| 633 |
+
sampler = gr.Dropdown(
|
| 634 |
+
label="Sampler",
|
| 635 |
+
choices=list(SAMPLERS),
|
| 636 |
+
value=DEFAULT_SAMPLER,
|
| 637 |
+
info="`euler ancestral` re-injects noise each step — expect seed to matter more.",
|
| 638 |
+
)
|
| 639 |
+
schedule = gr.Dropdown(
|
| 640 |
+
label="Sigma schedule",
|
| 641 |
+
choices=list(SCHEDULES),
|
| 642 |
+
value=DEFAULT_SCHEDULE,
|
| 643 |
+
info="`linear_quadratic` front-loads half the steps into the first 2.5% of the trajectory.",
|
| 644 |
+
)
|
| 645 |
+
video_shift = gr.Slider(
|
| 646 |
+
label="Video shift", minimum=0.5, maximum=50.0, step=0.5, value=DEFAULT_VIDEO_SHIFT
|
| 647 |
+
)
|
| 648 |
+
audio_shift = gr.Slider(
|
| 649 |
+
label="Audio shift", minimum=0.5, maximum=20.0, step=0.5, value=DEFAULT_AUDIO_SHIFT
|
| 650 |
+
)
|
| 651 |
seed = gr.Number(label="Seed", value=42, precision=0)
|
| 652 |
|
| 653 |
with gr.Column():
|