Update app.py
Browse files437 unmodified lines4384394404414424434444454464479 unmodified lines45745845946046146246346446546646746846947013 unmodified lines4844854864784874884894908 unmodified lines49950050150250350450595 unmodified lines60160260360460560660752 unmodified lines660661662663664665666120 unmodified lines78778878977877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283379079179220 unmodified lines81381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388418 unmodified lines903904905906907908909437 unmodified lines# The ZeroGPU per-call ceiling. A booking above it is refused with `ZeroGPU illegal duration` once the request is# already in flight, so `generate` checks it up front and says which knob to turn instead._MAX_BOOKING = int(os.environ.get("H3_MAX_BOOKING", "1500"))# Free-tier testing mode: forces the main Space's booking to exactly this many seconds regardless of the actual# request. Paired with the conditioner Space's own fixed 8s booking (both xlarge), for a combined 148s against# the shared 150s free-tier ceiling.MAXIMIZE_GPU_DURATION = int(os.environ.get("H3_MAXIMIZE_GPU_DURATION", "140"))
def get_duration(9 unmodified lines sharpen, multiplier, seed, lora_strengths, maximize_gpu, *a, **k,): if maximize_gpu: return MAXIMIZE_GPU_DURATION
height, width, num_frames, steps = int(height), int(width), int(num_frames), int(steps) multiplier = max(1, int(multiplier)) latent_frames = (num_frames - LATENTS_PER_CHUNK) // FRAMES_PER_CHUNK * LATENTS_PER_CHUNK + 213 unmodified lines return max(60, int((denoise + decode + post) * _MARGIN) + _PLACEMENT_ALLOWANCE)
@spaces.GPU(duration=140, size=GPU_SIZE)@spaces.GPU(duration=get_duration, size=GPU_SIZE)def _generate( prompt_embeds, text_token_tags,8 unmodified lines multiplier, seed, lora_strengths, maximize_gpu,): """The only thing on GPU time: the denoise loop, the two decoders and the workflow's post chain. The mp4 is muxed here rather than in the caller: a `@spaces.GPU` return crosses a process boundary by pickling,95 unmodified lines lora_e_strength=DEFAULT_LORA_E_STRENGTH, lora_f_strength=DEFAULT_LORA_F_STRENGTH, lora_g_strength=DEFAULT_LORA_G_STRENGTH, maximize_gpu=False, progress=gr.Progress(track_tqdm=True),): """One request through the PlagueKind graph. Every parameter but the prompt carries the default its UI52 unmodified lines multiplier, int(seed), lora_strengths, bool(maximize_gpu), ) # The same call `spaces` will book the worker with, so the report can show the fit against the measurement. booked_seconds = get_duration(*call)120 unmodified lines value=DEFAULT_STEPS, info="PlagueKind: 15-20 on the linear_quadratic grid.", ) lora_1_strength = gr.Slider( label="Distilled LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_1_STRENGTH, ) lora_a_strength = gr.Slider( label="Anthro Enhancer LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_A_STRENGTH, ) lora_b_strength = gr.Slider( label="Reasoning Enhancer LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_B_STRENGTH, ) lora_c_strength = gr.Slider( label="HM-AIO LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_C_STRENGTH, ) lora_d_strength = gr.Slider( label="Anthro Realism LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_D_STRENGTH, ) lora_e_strength = gr.Slider( label="SB LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_E_STRENGTH, ) lora_f_strength = gr.Slider( label="Moaxx LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_F_STRENGTH, ) lora_g_strength = gr.Slider( label="Fluid Enhancer LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_G_STRENGTH, ) schedule = gr.Dropdown( label="Sigma schedule", choices=list(SCHEDULES),20 unmodified lines 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.", )
with gr.Column(): video = gr.Video(label="Video + soundtrack") report = gr.Markdown() lora_1_strength = gr.Slider( label="Distilled LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_1_STRENGTH, ) with gr.Accordion("Custom LoRAs", open=False): lora_a_strength = gr.Slider( label="Anthro Enhancer LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_A_STRENGTH, ) lora_b_strength = gr.Slider( label="Reasoning Enhancer LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_B_STRENGTH, ) lora_c_strength = gr.Slider( label="HM-AIO LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_C_STRENGTH, ) lora_d_strength = gr.Slider( label="Anthro Realism LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_D_STRENGTH, ) lora_e_strength = gr.Slider( label="SB LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_E_STRENGTH, ) lora_f_strength = gr.Slider( label="Moaxx LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_F_STRENGTH, ) lora_g_strength = gr.Slider( label="Fluid Enhancer LoRA", minimum=0.0, maximum=2.0, step=0.05, value=DEFAULT_LORA_G_STRENGTH, )
first_frame.upload(_fit_keyframe, [first_frame, canvas], [first_frame, canvas]) last_frame.upload(_fit_keyframe, [last_frame, canvas], [last_frame, canvas])18 unmodified lines lora_e_strength, lora_f_strength, lora_g_strength, maximize_gpu, ]
run.click(generate, controls, [video, report], api_name="generate")app.py+76-57