Update app.py
Browse files437 unmodified lines4384394404414424439 unmodified lines45345445545645745845946046113 unmodified lines4754764774784794804818 unmodified lines49049149249349449595 unmodified lines59159259359459559652 unmodified lines649650651652653654120 unmodified lines77577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583620 unmodified lines85785885986086186286386486586618 unmodified lines885886887888889890437 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"))def get_duration(9 unmodified linessharpen,multiplier,seed,*a,**k,):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 linesreturn max(60, int((denoise + decode + post) * _MARGIN) + _PLACEMENT_ALLOWANCE)@spaces.GPU(duration=140, size=GPU_SIZE)def _generate(prompt_embeds,text_token_tags,8 unmodified linesmultiplier,seed,lora_strengths,):"""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 lineslora_e_strength=DEFAULT_LORA_E_STRENGTH,lora_f_strength=DEFAULT_LORA_F_STRENGTH,lora_g_strength=DEFAULT_LORA_G_STRENGTH,progress=gr.Progress(track_tqdm=True),):"""One request through the PlagueKind graph. Every parameter but the prompt carries the default its UI52 unmodified linesmultiplier,int(seed),lora_strengths,)# 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 linesvalue=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 linesvalue=False,info="Rewrite the prompt on the conditioner Space first, MiniMax's Context-IR style.",)with gr.Column():video = gr.Video(label="Video + soundtrack")report = gr.Markdown()first_frame.upload(_fit_keyframe, [first_frame, canvas], [first_frame, canvas])last_frame.upload(_fit_keyframe, [last_frame, canvas], [last_frame, canvas])18 unmodified lineslora_e_strength,lora_f_strength,lora_g_strength,]run.click(generate, controls, [video, report], api_name="generate")437 unmodified lines4384394404414424434444454464479 unmodified lines45745845946046146246346446546646746846947013 unmodified lines4844854864874884894908 unmodified lines49950050150250350450595 unmodified lines60160260360460560660752 unmodified lines660661662663664665666120 unmodified lines78778878979079179220 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 linessharpen,multiplier,seed,lora_strengths,maximize_gpu,*a,**k,):if maximize_gpu:return MAXIMIZE_GPU_DURATIONheight, 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 linesreturn max(60, int((denoise + decode + post) * _MARGIN) + _PLACEMENT_ALLOWANCE)@spaces.GPU(duration=get_duration, size=GPU_SIZE)def _generate(prompt_embeds,text_token_tags,8 unmodified linesmultiplier,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 lineslora_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 linesmultiplier,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 linesvalue=DEFAULT_STEPS,info="PlagueKind: 15-20 on the linear_quadratic grid.",)schedule = gr.Dropdown(label="Sigma schedule",choices=list(SCHEDULES),20 unmodified linesvalue=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 lineslora_e_strength,lora_f_strength,lora_g_strength,maximize_gpu,]run.click(generate, controls, [video, report], api_name="generate")
app.py+76-57