Update app.py
Browse files426 unmodified lines427428429430431432263 unmodified lines69669769869970070132 unmodified lines734735736737738739148 unmodified lines888889890891892893143 unmodified lines103710381039104010411042351 unmodified lines139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435136 unmodified lines157215731574157515761577157897 unmodified lines167616771678167916801681426 unmodified linesprint(f"[gen] loading {[c.name for c in blocks.expected_components]} from {MODEL_REPO} ...", flush=True)pipe = blocks.init_pipeline(MODEL_REPO, components_manager=manager, collection="h3")pipe.load_components(dtype=torch.bfloat16)pipe.transformer.set_attention_backend(ATTENTION)# --- Diagnostic: dump the LoRA files' key names/shapes and the transformer's own shapes to the Space263 unmodified linesmaximize_gpu,video_shift,audio_shift,sampler,total_steps,stage_from,32 unmodified lines}PIPE.transformer.set_adapters(list(active), weights=list(active.values()))if PLACEMENT == "lazy":PIPE.to("cuda")elif PLACEMENT == "pack":148 unmodified linessemantic_bridge_alpha=0.10,semantic_bridge_magnitude_match="per_token",semantic_bridge_adapter="semantic_bridge_v1",progress=gr.Progress(track_tqdm=True),*,advance: bool = False,143 unmodified linesbool(maximize_gpu),float(video_shift),float(audio_shift),SAMPLERS.get(sampler, "euler"),int(target_steps) if stage_enabled else None,steps_done if advance else 0,351 unmodified linesvalue=DEFAULT_INTERPOLATION,info="MiniMax-H3 generates 24 fps; FILM synthesizes the frames in between.",)seed = gr.Number(label="Seed", value=42, precision=0)upsample = gr.Checkbox(label="Upsample prompt",value=False,info="Rewrite the prompt on the conditioner Space first, MiniMax's Context-IR style.",)with gr.Accordion("Semantic Bridge", open=False):gr.Markdown("A small, independent adapter that nudges text conditioning toward better constraint ""adherence — left/right ordering, which hand holds what, material and reflection ""correctness — without touching the video transformer. Runs on the conditioner Space. ""Experimental; may help some prompts, do little on others.")semantic_bridge = gr.Checkbox(label="Enable Semantic Bridge", value=False)semantic_bridge_alpha = gr.Slider(label="alpha", minimum=0.0, maximum=1.0, step=0.01, value=0.10, visible=False)semantic_bridge_magnitude_match = gr.Dropdown(label="magnitude_match",choices=["per_token", "global", "none"],value="per_token",visible=False,)semantic_bridge_adapter = gr.Dropdown(label="adapter",choices=["semantic_bridge_v1", "bunny_action_logic_v1"],value="semantic_bridge_v1",visible=False,info="semantic_bridge_v1: broad (composition, spatial, materials). ""bunny_action_logic_v1: action/combat, character-action ownership in multi-character scenes.",)maximize_gpu = gr.Checkbox(label="Maximize Free Tier ZeroGPU (150 seconds)",value=False,info="Forces this request to book exactly 140s (plus 8s on the conditioner) for debugging purposes; does not prevent timeouts.",)with gr.Column():video = gr.Video(label="Video + soundtrack", elem_id="h3-generated-video")136 unmodified lines)advance_btn = gr.Button("Advance", variant="secondary", visible=False)with gr.Accordion("Chunked Generation", open=False):gr.Markdown("Splits a longer product into independent, full-quality chunks joined afterward — each ""press is a complete generation, not a partial one. The previous chunk's last frame carries "97 unmodified linessemantic_bridge_alpha,semantic_bridge_magnitude_match,semantic_bridge_adapter,]# `functools.partial` binds `advance`/`chunk_advance` by keyword regardless of their position in `generate`'s426 unmodified lines427428429430431432433434435436437438439440441442443263 unmodified lines70770870971071171271332 unmodified lines746747748749750751752753754755756757758759760148 unmodified lines909910911912913914915143 unmodified lines1059106010611062106310641065351 unmodified lines1417141814191420142114221423142414251426142714281429143014311432143314341435143614371438136 unmodified lines15751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160797 unmodified lines1705170617071708170917101711426 unmodified linesprint(f"[gen] loading {[c.name for c in blocks.expected_components]} from {MODEL_REPO} ...", flush=True)pipe = blocks.init_pipeline(MODEL_REPO, components_manager=manager, collection="h3")pipe.load_components(dtype=torch.bfloat16)import h3_eroseros_status = h3_eros.apply_eros(pipe.transformer)if eros_status:print(f"[gen] {eros_status}", flush=True)import h3_proj_cacheh3_proj_cache.patch(pipe.transformer)pipe.transformer.set_attention_backend(ATTENTION)# --- Diagnostic: dump the LoRA files' key names/shapes and the transformer's own shapes to the Space263 unmodified linesmaximize_gpu,video_shift,audio_shift,proj_cache,sampler,total_steps,stage_from,32 unmodified lines}PIPE.transformer.set_adapters(list(active), weights=list(active.values()))# Toggled per request, not patched per-call: `h3_proj_cache.patch` wrapped `forward` once in `load_models()`,# and this just flips the attribute that wrapped method checks. `MOMENTUM_PIPE.transformer` is the same# object as `PIPE.transformer` (see `load_models()`'s `update_components` call), so this covers the# momentum path too, regardless of which `active_pipe` ends up running below. Called unconditionally, same# reasoning as `set_adapters` above.import h3_proj_cacheh3_proj_cache.set_enabled(PIPE.transformer, proj_cache)if PLACEMENT == "lazy":PIPE.to("cuda")elif PLACEMENT == "pack":148 unmodified linessemantic_bridge_alpha=0.10,semantic_bridge_magnitude_match="per_token",semantic_bridge_adapter="semantic_bridge_v1",proj_cache=True,progress=gr.Progress(track_tqdm=True),*,advance: bool = False,143 unmodified linesbool(maximize_gpu),float(video_shift),float(audio_shift),bool(proj_cache),SAMPLERS.get(sampler, "euler"),int(target_steps) if stage_enabled else None,steps_done if advance else 0,351 unmodified linesvalue=DEFAULT_INTERPOLATION,info="MiniMax-H3 generates 24 fps; FILM synthesizes the frames in between.",)upsample = gr.Checkbox(label="Upsample prompt",value=False,info="Rewrite the prompt on the conditioner Space first, MiniMax's Context-IR style.",)maximize_gpu = gr.Checkbox(label="Maximize Free Tier ZeroGPU (150 seconds)",value=False,info="Forces this request to book exactly 140s (plus 8s on the conditioner) for debugging purposes; does not prevent timeouts.",)proj_cache = gr.Checkbox(label="Cache keyframe projection",value=True,info="Skips recomputing the unchanging keyframe rows' proj_in output on every denoising step. ""Lossless — same output either way. Turn off only if you suspect it of causing an issue.",)with gr.Column():video = gr.Video(label="Video + soundtrack", elem_id="h3-generated-video")136 unmodified lines)advance_btn = gr.Button("Advance", variant="secondary", visible=False)with gr.Accordion("Semantic Bridge", open=False):gr.Markdown("A small, independent adapter that nudges text conditioning toward better constraint ""adherence — left/right ordering, which hand holds what, material and reflection ""correctness — without touching the video transformer. Runs on the conditioner Space. ""Experimental; may help some prompts, do little on others.")semantic_bridge = gr.Checkbox(label="Enable Semantic Bridge", value=False)semantic_bridge_alpha = gr.Slider(label="alpha", minimum=0.0, maximum=1.0, step=0.01, value=0.10, visible=False)semantic_bridge_magnitude_match = gr.Dropdown(label="magnitude_match",choices=["per_token", "global", "none"],value="per_token",visible=False,)semantic_bridge_adapter = gr.Dropdown(label="adapter",choices=["semantic_bridge_v1", "bunny_action_logic_v1"],value="semantic_bridge_v1",visible=False,info="semantic_bridge_v1: broad (composition, spatial, materials). ""bunny_action_logic_v1: action/combat, character-action ownership in multi-character scenes.",)with gr.Accordion("Chunked Generation", open=False, visible=False):gr.Markdown("Splits a longer product into independent, full-quality chunks joined afterward — each ""press is a complete generation, not a partial one. The previous chunk's last frame carries "97 unmodified linessemantic_bridge_alpha,semantic_bridge_magnitude_match,semantic_bridge_adapter,proj_cache,]# `functools.partial` binds `advance`/`chunk_advance` by keyword regardless of their position in `generate`'s
app.py+57-27