Update app.py
Browse files36 unmodified lines37383940414243444546474849505152535455561 unmodified line5859606162633 unmodified lines676869707172290 unmodified lines36336436536636736836937037132 unmodified lines404405406407408409410411412270 unmodified lines68368468568668768846 unmodified lines735736737738739740741196 unmodified lines93893994094194294394494594694794894995061 unmodified lines10121013101410151016101736 unmodified linesGPU_SIZE = os.environ.get("H3_GPU_SIZE", "xlarge")LORA_REPO = os.environ.get("H3_LORA_REPO", "dagloop5/LoRA")LORA_FILES = {"lora1": os.environ.get("H3_LORA_1_FILE", "minimax_h3_turbo_v4_step600_ema.safetensors"),"loraa": os.environ.get("H3_LORA_A_FILE", "Mylo_lora_epoch31.safetensors"),"lorab": os.environ.get("H3_LORA_B_FILE", "VBVR_H3_attn_only.safetensors"),"lorac": os.environ.get("H3_LORA_C_FILE", "AIO_V2.safetensors"),"lorad": os.environ.get("H3_LORA_D_FILE", "Furry enhancer Video H3 V2.54.safetensors"),"lorae": os.environ.get("H3_LORA_E_FILE", "sb_H3_i2v_v1.1.safetensors"),"loraf": os.environ.get("H3_LORA_F_FILE", "moawxx_000002000.safetensors"),"lorag": os.environ.get("H3_LORA_G_FILE", "H3_ref2va_shot_v1_fp16.safetensors"),}# Display names, keyed the same as LORA_FILES — used in the UI slider labels, the per-request report line, and# the status line's failure list. Keep these two dicts' keys in sync when adding a LoRA.LORA_LABELS = {"lora1": "Distilled LoRA","loraa": "Anthro Enhancer","lorab": "Reasoning Enhancer","lorac": "HM-AIO", # hmmotion1 unmodified line"lorae": "SB","loraf": "Moaxx", # moawxx"lorag": "Fluid Enhancer",}DEFAULT_LORA_1_STRENGTH = 0.0DEFAULT_LORA_A_STRENGTH = 0.03 unmodified linesDEFAULT_LORA_E_STRENGTH = 0.0DEFAULT_LORA_F_STRENGTH = 0.0DEFAULT_LORA_G_STRENGTH = 0.0# Per-LoRA, not global: different training pipelines can store SwiGLU's fc1 gate/value halves in either order,# and one flag can only be right for however many of the 8 files happen to agree. `lora1` (the Distilled/Turbo# LoRA) is confirmed needing the swap by InstantX's official conversion of the same lineage290 unmodified linesfrom huggingface_hub import hf_hub_downloadfrom safetensors import safe_openfor filename in LORA_FILES.values():try:path = hf_hub_download(LORA_REPO, filename)with safe_open(path, framework="pt") as handle:keys = sorted(handle.keys())print(f"[lora-debug] {filename}: {len(keys)} keys", flush=True)32 unmodified lines# `_convert_diffusion_model_lora` for why this can't be read fresh per-file.base_shapes = {k: tuple(v.shape) for k, v in pipe.transformer.state_dict().items()}failures = []for name, filename in LORA_FILES.items():try:path = hf_hub_download(LORA_REPO, filename)with safe_open(path, framework="pt") as handle:raw = {k: handle.get_tensor(k) for k in handle.keys()}converted, network_alphas = _convert_diffusion_model_lora(270 unmodified linesseed=42,upsample=False,lora_1_strength=DEFAULT_LORA_1_STRENGTH,lora_a_strength=DEFAULT_LORA_A_STRENGTH,lora_b_strength=DEFAULT_LORA_B_STRENGTH,lora_c_strength=DEFAULT_LORA_C_STRENGTH,46 unmodified lines# Every UI LoRA slider gets packed into one dict here — this is the only place a new LoRA's slider value# needs wiring in; `_generate`, `set_adapters`, and the report line below are all keyed off this dict.lora_strengths = {"lora1": float(lora_1_strength), "loraa": float(lora_a_strength), "lorab": float(lora_b_strength), "lorac": float(lora_c_strength), "lorad": float(lora_d_strength), "lorae": float(lora_e_strength), "loraf": float(lora_f_strength), "lorag": float(lora_g_strength)}progress(0.1, desc=f"Denoising {int(steps)} steps at {width}x{height}, {num_frames} frames ...")call = (196 unmodified lineswith 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",61 unmodified linesseed,upsample,lora_1_strength,lora_a_strength,lora_b_strength,lora_c_strength,36 unmodified lines3738394041424344454647484950515253545556575859606162636465661 unmodified line68697071727374753 unmodified lines7980818283848586290 unmodified lines37737837938038138238338438532 unmodified lines418419420421422423424425426270 unmodified lines69769869970070170270370446 unmodified lines751752753754755756757196 unmodified lines95495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398461 unmodified lines1046104710481049105010511052105336 unmodified linesGPU_SIZE = os.environ.get("H3_GPU_SIZE", "xlarge")LORA_REPO = os.environ.get("H3_LORA_REPO", "dagloop5/LoRA")# Each entry is (repo, filename) so a LoRA can come from any repo, not just LORA_REPO — the two Lightx2v files# live in lightx2v/Minimax-h3-Turbo, not dagloop5/LoRA.LORA_FILES = {"lora1": (LORA_REPO, os.environ.get("H3_LORA_1_FILE", "minimax_h3_turbo_v4_step600_ema.safetensors")),"loraa": (LORA_REPO, os.environ.get("H3_LORA_A_FILE", "Mylo_lora_epoch31.safetensors")),"lorab": (LORA_REPO, os.environ.get("H3_LORA_B_FILE", "VBVR_H3_attn_only.safetensors")),"lorac": (LORA_REPO, os.environ.get("H3_LORA_C_FILE", "AIO_V2.safetensors")),"lorad": (LORA_REPO, os.environ.get("H3_LORA_D_FILE", "Furry enhancer Video H3 V2.54.safetensors")),"lorae": (LORA_REPO, os.environ.get("H3_LORA_E_FILE", "sb_H3_i2v_v1.1.safetensors")),"loraf": (LORA_REPO, os.environ.get("H3_LORA_F_FILE", "moawxx_000002000.safetensors")),"lorag": (LORA_REPO, os.environ.get("H3_LORA_G_FILE", "H3_ref2va_shot_v1_fp16.safetensors")),"lorah": (os.environ.get("H3_LORA_H_REPO", "lightx2v/Minimax-h3-Turbo"),os.environ.get("H3_LORA_H_FILE", "minimax_h3_fl2v_turbo_4step_v1.1_768p_bf16.safetensors"),),"lorai": (os.environ.get("H3_LORA_I_REPO", "lightx2v/Minimax-h3-Turbo"),os.environ.get("H3_LORA_I_FILE", "minimax_h3_fl2v_turbo_8step_v1.0_bf16.safetensors"),),}# Display names, keyed the same as LORA_FILES — used in the UI slider labels, the per-request report line, and# the status line's failure list. Keep these two dicts' keys in sync when adding a LoRA.LORA_LABELS = {"lora1": "Larryvrh-MiniMax-H3 Turbo LoRA","loraa": "Anthro Enhancer","lorab": "Reasoning Enhancer","lorac": "HM-AIO", # hmmotion1 unmodified line"lorae": "SB","loraf": "Moaxx", # moawxx"lorag": "Fluid Enhancer","lorah": "Lightx2v-Minimax-H3 Turbo 768p LoRA","lorai": "Lightx2v-Minimax-H3 Turbo 8-step LoRA",}DEFAULT_LORA_1_STRENGTH = 0.0DEFAULT_LORA_A_STRENGTH = 0.03 unmodified linesDEFAULT_LORA_E_STRENGTH = 0.0DEFAULT_LORA_F_STRENGTH = 0.0DEFAULT_LORA_G_STRENGTH = 0.0DEFAULT_LORA_H_STRENGTH = 0.0DEFAULT_LORA_I_STRENGTH = 0.0# Per-LoRA, not global: different training pipelines can store SwiGLU's fc1 gate/value halves in either order,# and one flag can only be right for however many of the 8 files happen to agree. `lora1` (the Distilled/Turbo# LoRA) is confirmed needing the swap by InstantX's official conversion of the same lineage290 unmodified linesfrom huggingface_hub import hf_hub_downloadfrom safetensors import safe_openfor repo, filename in LORA_FILES.values():try:path = hf_hub_download(repo, filename)with safe_open(path, framework="pt") as handle:keys = sorted(handle.keys())print(f"[lora-debug] {filename}: {len(keys)} keys", flush=True)32 unmodified lines# `_convert_diffusion_model_lora` for why this can't be read fresh per-file.base_shapes = {k: tuple(v.shape) for k, v in pipe.transformer.state_dict().items()}failures = []for name, (repo, filename) in LORA_FILES.items():try:path = hf_hub_download(repo, filename)with safe_open(path, framework="pt") as handle:raw = {k: handle.get_tensor(k) for k in handle.keys()}converted, network_alphas = _convert_diffusion_model_lora(270 unmodified linesseed=42,upsample=False,lora_1_strength=DEFAULT_LORA_1_STRENGTH,lora_h_strength=DEFAULT_LORA_H_STRENGTH,lora_i_strength=DEFAULT_LORA_I_STRENGTH,lora_a_strength=DEFAULT_LORA_A_STRENGTH,lora_b_strength=DEFAULT_LORA_B_STRENGTH,lora_c_strength=DEFAULT_LORA_C_STRENGTH,46 unmodified lines# Every UI LoRA slider gets packed into one dict here — this is the only place a new LoRA's slider value# needs wiring in; `_generate`, `set_adapters`, and the report line below are all keyed off this dict.lora_strengths = {"lora1": float(lora_1_strength), "lorah": float(lora_h_strength), "lorai": float(lora_i_strength), "loraa": float(lora_a_strength), "lorab": float(lora_b_strength), "lorac": float(lora_c_strength), "lorad": float(lora_d_strength), "lorae": float(lora_e_strength), "loraf": float(lora_f_strength), "lorag": float(lora_g_strength)}progress(0.1, desc=f"Denoising {int(steps)} steps at {width}x{height}, {num_frames} frames ...")call = (196 unmodified lineswith gr.Column():video = gr.Video(label="Video + soundtrack")report = gr.Markdown()with gr.Accordion("Distilled / Turbo LoRAs", open=False):lora_1_strength = gr.Slider(label="Larryvrh-MiniMax-H3 Turbo LoRA",minimum=0.0,maximum=2.0,step=0.05,value=DEFAULT_LORA_1_STRENGTH,info="Video/Audio Shift = 6/3",)lora_h_strength = gr.Slider(label="Lightx2v-Minimax-H3 Turbo 768p LoRA",minimum=0.0,maximum=2.0,step=0.05,value=DEFAULT_LORA_H_STRENGTH,info="Video/Audio Shift = 6/3",)lora_i_strength = gr.Slider(label="Lightx2v-Minimax-H3 Turbo 8-step LoRA",minimum=0.0,maximum=2.0,step=0.05,value=DEFAULT_LORA_I_STRENGTH,info="Video/Audio Shift = 12/3",)with gr.Accordion("Custom LoRAs", open=False):lora_a_strength = gr.Slider(label="Anthro Enhancer LoRA",61 unmodified linesseed,upsample,lora_1_strength,lora_h_strength,lora_i_strength,lora_a_strength,lora_b_strength,lora_c_strength,
app.py+57-21