Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -100,6 +100,10 @@ FPS, FRAMES_PER_CHUNK, LATENTS_PER_CHUNK = 24, 17, 5
|
|
| 100 |
# 15.083 s, and is refused. 14 is the last whole second that survives the snap.
|
| 101 |
MAX_UI_DURATION = 14
|
| 102 |
MIN_DURATION = 2
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
# A reference video shorter than 2 s gives the model almost no motion to read.
|
| 104 |
MIN_REFERENCE_VIDEO, MAX_REFERENCE_VIDEO = 2.0, 15.0
|
| 105 |
# `MINIMAX_H3_MAX_REFERENCE_IMAGES`. The slots are built up front and revealed one at a time, because a demo asking
|
|
@@ -1271,6 +1275,14 @@ def generate(
|
|
| 1271 |
# route's artifact; the runner's ffprobe gate should see audio_stream_count=0 before accepting the take.
|
| 1272 |
encode_video(frames, fps=FPS, output_path=path, audio=None)
|
| 1273 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1274 |
print(
|
| 1275 |
f"[ref2va] {[kind for kind, _ in references]} · `{width}x{height}`, {num_frames} frames "
|
| 1276 |
f"({num_frames / FPS:.3f} s), {int(steps)} steps · conditioner {condition_seconds:.0f}s "
|
|
@@ -1280,7 +1292,7 @@ def generate(
|
|
| 1280 |
f"{' · LoRA ' + ', '.join(lora_labels) if lora_labels else ''}",
|
| 1281 |
flush=True,
|
| 1282 |
)
|
| 1283 |
-
return path, refined, gr.update(visible=bool(refined))
|
| 1284 |
|
| 1285 |
|
| 1286 |
def p15b_preflight() -> dict:
|
|
@@ -1742,6 +1754,13 @@ with gr.Blocks(title="MiniMax-H3 Reference Custom Lora") as demo:
|
|
| 1742 |
|
| 1743 |
with gr.Column():
|
| 1744 |
result = gr.Video(label="Видео со звуком")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1745 |
# An output, so it can be revealed only for a request that asked for a rewrite.
|
| 1746 |
with gr.Accordion("Расширенный промпт", open=False, visible=False) as upsampled_panel:
|
| 1747 |
upsampled = gr.Textbox(show_label=False, lines=8, interactive=False)
|
|
@@ -1819,7 +1838,7 @@ with gr.Blocks(title="MiniMax-H3 Reference Custom Lora") as demo:
|
|
| 1819 |
)
|
| 1820 |
run.click(
|
| 1821 |
apply_short_clip, [short_clip, duration], effective_duration, api_name=False
|
| 1822 |
-
).then(generate, request, [result, upsampled, upsampled_panel], api_name=False)
|
| 1823 |
|
| 1824 |
# P15B v02 has exactly two public endpoints. They deliberately use File components rather than Image components:
|
| 1825 |
# Gradio 6 uploads arrive as FileData, and the runner must preserve this exact reference order.
|
|
|
|
| 100 |
# 15.083 s, and is refused. 14 is the last whole second that survives the snap.
|
| 101 |
MAX_UI_DURATION = 14
|
| 102 |
MIN_DURATION = 2
|
| 103 |
+
# The model's absolute floor is LATENTS_PER_CHUNK frames (5 @ 17*0+5). At that length the encoded mp4 is technically
|
| 104 |
+
# valid but short enough that gr.Video / mobile WebView frequently fail to display it, so we also surface the raw
|
| 105 |
+
# frames as stills whenever the take is at or under this threshold.
|
| 106 |
+
SHORT_CLIP_GALLERY_FRAME_THRESHOLD = LATENTS_PER_CHUNK
|
| 107 |
# A reference video shorter than 2 s gives the model almost no motion to read.
|
| 108 |
MIN_REFERENCE_VIDEO, MAX_REFERENCE_VIDEO = 2.0, 15.0
|
| 109 |
# `MINIMAX_H3_MAX_REFERENCE_IMAGES`. The slots are built up front and revealed one at a time, because a demo asking
|
|
|
|
| 1275 |
# route's artifact; the runner's ffprobe gate should see audio_stream_count=0 before accepting the take.
|
| 1276 |
encode_video(frames, fps=FPS, output_path=path, audio=None)
|
| 1277 |
|
| 1278 |
+
# Below the practical playback floor, hand back the raw stills too, since the mp4 itself is frequently
|
| 1279 |
+
# rejected or shown blank by the video element even though encoding succeeded.
|
| 1280 |
+
gallery_update = (
|
| 1281 |
+
gr.update(value=[frame.cpu().numpy() for frame in frames], visible=True)
|
| 1282 |
+
if num_frames <= SHORT_CLIP_GALLERY_FRAME_THRESHOLD
|
| 1283 |
+
else gr.update(value=None, visible=False)
|
| 1284 |
+
)
|
| 1285 |
+
|
| 1286 |
print(
|
| 1287 |
f"[ref2va] {[kind for kind, _ in references]} · `{width}x{height}`, {num_frames} frames "
|
| 1288 |
f"({num_frames / FPS:.3f} s), {int(steps)} steps · conditioner {condition_seconds:.0f}s "
|
|
|
|
| 1292 |
f"{' · LoRA ' + ', '.join(lora_labels) if lora_labels else ''}",
|
| 1293 |
flush=True,
|
| 1294 |
)
|
| 1295 |
+
return path, refined, gr.update(visible=bool(refined)), gallery_update
|
| 1296 |
|
| 1297 |
|
| 1298 |
def p15b_preflight() -> dict:
|
|
|
|
| 1754 |
|
| 1755 |
with gr.Column():
|
| 1756 |
result = gr.Video(label="Видео со звуком")
|
| 1757 |
+
# Short clips (5 frames / 0.2 s) are technically valid mp4s but many players (gr.Video, mobile WebView)
|
| 1758 |
+
# fail to open a file that short — the "Ошибка в отображении материала" symptom. Rather than touch the
|
| 1759 |
+
# denoising or the mp4 encoding, we additionally hand back the raw frames as stills whenever the take is
|
| 1760 |
+
# at or under that floor, so there's always something visible even if the video player chokes.
|
| 1761 |
+
frames_gallery = gr.Gallery(
|
| 1762 |
+
label="Кадры (короткое видео)", visible=False, columns=5, height="auto"
|
| 1763 |
+
)
|
| 1764 |
# An output, so it can be revealed only for a request that asked for a rewrite.
|
| 1765 |
with gr.Accordion("Расширенный промпт", open=False, visible=False) as upsampled_panel:
|
| 1766 |
upsampled = gr.Textbox(show_label=False, lines=8, interactive=False)
|
|
|
|
| 1838 |
)
|
| 1839 |
run.click(
|
| 1840 |
apply_short_clip, [short_clip, duration], effective_duration, api_name=False
|
| 1841 |
+
).then(generate, request, [result, upsampled, upsampled_panel, frames_gallery], api_name=False)
|
| 1842 |
|
| 1843 |
# P15B v02 has exactly two public endpoints. They deliberately use File components rather than Image components:
|
| 1844 |
# Gradio 6 uploads arrive as FileData, and the runner must preserve this exact reference order.
|