dagloop5 commited on
Commit
dc2d62d
·
verified ·
1 Parent(s): 093c76e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +57 -21
app.py CHANGED
@@ -37,20 +37,30 @@ ATTENTION = os.environ.get("H3_ATTENTION", "_native_cudnn").lower()
37
  GPU_SIZE = os.environ.get("H3_GPU_SIZE", "xlarge")
38
 
39
  LORA_REPO = os.environ.get("H3_LORA_REPO", "dagloop5/LoRA")
 
 
40
  LORA_FILES = {
41
- "lora1": os.environ.get("H3_LORA_1_FILE", "minimax_h3_turbo_v4_step600_ema.safetensors"),
42
- "loraa": os.environ.get("H3_LORA_A_FILE", "Mylo_lora_epoch31.safetensors"),
43
- "lorab": os.environ.get("H3_LORA_B_FILE", "VBVR_H3_attn_only.safetensors"),
44
- "lorac": os.environ.get("H3_LORA_C_FILE", "AIO_V2.safetensors"),
45
- "lorad": os.environ.get("H3_LORA_D_FILE", "Furry enhancer Video H3 V2.54.safetensors"),
46
- "lorae": os.environ.get("H3_LORA_E_FILE", "sb_H3_i2v_v1.1.safetensors"),
47
- "loraf": os.environ.get("H3_LORA_F_FILE", "moawxx_000002000.safetensors"),
48
- "lorag": os.environ.get("H3_LORA_G_FILE", "H3_ref2va_shot_v1_fp16.safetensors"),
 
 
 
 
 
 
 
 
49
  }
50
  # Display names, keyed the same as LORA_FILES — used in the UI slider labels, the per-request report line, and
51
  # the status line's failure list. Keep these two dicts' keys in sync when adding a LoRA.
52
  LORA_LABELS = {
53
- "lora1": "Distilled LoRA",
54
  "loraa": "Anthro Enhancer",
55
  "lorab": "Reasoning Enhancer",
56
  "lorac": "HM-AIO", # hmmotion
@@ -58,6 +68,8 @@ LORA_LABELS = {
58
  "lorae": "SB",
59
  "loraf": "Moaxx", # moawxx
60
  "lorag": "Fluid Enhancer",
 
 
61
  }
62
  DEFAULT_LORA_1_STRENGTH = 0.0
63
  DEFAULT_LORA_A_STRENGTH = 0.0
@@ -67,6 +79,8 @@ DEFAULT_LORA_D_STRENGTH = 0.0
67
  DEFAULT_LORA_E_STRENGTH = 0.0
68
  DEFAULT_LORA_F_STRENGTH = 0.0
69
  DEFAULT_LORA_G_STRENGTH = 0.0
 
 
70
  # Per-LoRA, not global: different training pipelines can store SwiGLU's fc1 gate/value halves in either order,
71
  # and one flag can only be right for however many of the 8 files happen to agree. `lora1` (the Distilled/Turbo
72
  # LoRA) is confirmed needing the swap by InstantX's official conversion of the same lineage
@@ -363,9 +377,9 @@ def load_models() -> str | None:
363
  from huggingface_hub import hf_hub_download
364
  from safetensors import safe_open
365
 
366
- for filename in LORA_FILES.values():
367
  try:
368
- path = hf_hub_download(LORA_REPO, filename)
369
  with safe_open(path, framework="pt") as handle:
370
  keys = sorted(handle.keys())
371
  print(f"[lora-debug] {filename}: {len(keys)} keys", flush=True)
@@ -404,9 +418,9 @@ def load_models() -> str | None:
404
  # `_convert_diffusion_model_lora` for why this can't be read fresh per-file.
405
  base_shapes = {k: tuple(v.shape) for k, v in pipe.transformer.state_dict().items()}
406
  failures = []
407
- for name, filename in LORA_FILES.items():
408
  try:
409
- path = hf_hub_download(LORA_REPO, filename)
410
  with safe_open(path, framework="pt") as handle:
411
  raw = {k: handle.get_tensor(k) for k in handle.keys()}
412
  converted, network_alphas = _convert_diffusion_model_lora(
@@ -683,6 +697,8 @@ def generate(
683
  seed=42,
684
  upsample=False,
685
  lora_1_strength=DEFAULT_LORA_1_STRENGTH,
 
 
686
  lora_a_strength=DEFAULT_LORA_A_STRENGTH,
687
  lora_b_strength=DEFAULT_LORA_B_STRENGTH,
688
  lora_c_strength=DEFAULT_LORA_C_STRENGTH,
@@ -735,7 +751,7 @@ def generate(
735
 
736
  # Every UI LoRA slider gets packed into one dict here — this is the only place a new LoRA's slider value
737
  # needs wiring in; `_generate`, `set_adapters`, and the report line below are all keyed off this dict.
738
- 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)}
739
 
740
  progress(0.1, desc=f"Denoising {int(steps)} steps at {width}x{height}, {num_frames} frames ...")
741
  call = (
@@ -938,13 +954,31 @@ with gr.Blocks(title="PlagueKind · MiniMax-H3") as demo:
938
  with gr.Column():
939
  video = gr.Video(label="Video + soundtrack")
940
  report = gr.Markdown()
941
- lora_1_strength = gr.Slider(
942
- label="Distilled LoRA",
943
- minimum=0.0,
944
- maximum=2.0,
945
- step=0.05,
946
- value=DEFAULT_LORA_1_STRENGTH,
947
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
948
  with gr.Accordion("Custom LoRAs", open=False):
949
  lora_a_strength = gr.Slider(
950
  label="Anthro Enhancer LoRA",
@@ -1012,6 +1046,8 @@ with gr.Blocks(title="PlagueKind · MiniMax-H3") as demo:
1012
  seed,
1013
  upsample,
1014
  lora_1_strength,
 
 
1015
  lora_a_strength,
1016
  lora_b_strength,
1017
  lora_c_strength,
 
37
  GPU_SIZE = os.environ.get("H3_GPU_SIZE", "xlarge")
38
 
39
  LORA_REPO = os.environ.get("H3_LORA_REPO", "dagloop5/LoRA")
40
+ # Each entry is (repo, filename) so a LoRA can come from any repo, not just LORA_REPO — the two Lightx2v files
41
+ # live in lightx2v/Minimax-h3-Turbo, not dagloop5/LoRA.
42
  LORA_FILES = {
43
+ "lora1": (LORA_REPO, os.environ.get("H3_LORA_1_FILE", "minimax_h3_turbo_v4_step600_ema.safetensors")),
44
+ "loraa": (LORA_REPO, os.environ.get("H3_LORA_A_FILE", "Mylo_lora_epoch31.safetensors")),
45
+ "lorab": (LORA_REPO, os.environ.get("H3_LORA_B_FILE", "VBVR_H3_attn_only.safetensors")),
46
+ "lorac": (LORA_REPO, os.environ.get("H3_LORA_C_FILE", "AIO_V2.safetensors")),
47
+ "lorad": (LORA_REPO, os.environ.get("H3_LORA_D_FILE", "Furry enhancer Video H3 V2.54.safetensors")),
48
+ "lorae": (LORA_REPO, os.environ.get("H3_LORA_E_FILE", "sb_H3_i2v_v1.1.safetensors")),
49
+ "loraf": (LORA_REPO, os.environ.get("H3_LORA_F_FILE", "moawxx_000002000.safetensors")),
50
+ "lorag": (LORA_REPO, os.environ.get("H3_LORA_G_FILE", "H3_ref2va_shot_v1_fp16.safetensors")),
51
+ "lorah": (
52
+ os.environ.get("H3_LORA_H_REPO", "lightx2v/Minimax-h3-Turbo"),
53
+ os.environ.get("H3_LORA_H_FILE", "minimax_h3_fl2v_turbo_4step_v1.1_768p_bf16.safetensors"),
54
+ ),
55
+ "lorai": (
56
+ os.environ.get("H3_LORA_I_REPO", "lightx2v/Minimax-h3-Turbo"),
57
+ os.environ.get("H3_LORA_I_FILE", "minimax_h3_fl2v_turbo_8step_v1.0_bf16.safetensors"),
58
+ ),
59
  }
60
  # Display names, keyed the same as LORA_FILES — used in the UI slider labels, the per-request report line, and
61
  # the status line's failure list. Keep these two dicts' keys in sync when adding a LoRA.
62
  LORA_LABELS = {
63
+ "lora1": "Larryvrh-MiniMax-H3 Turbo LoRA",
64
  "loraa": "Anthro Enhancer",
65
  "lorab": "Reasoning Enhancer",
66
  "lorac": "HM-AIO", # hmmotion
 
68
  "lorae": "SB",
69
  "loraf": "Moaxx", # moawxx
70
  "lorag": "Fluid Enhancer",
71
+ "lorah": "Lightx2v-Minimax-H3 Turbo 768p LoRA",
72
+ "lorai": "Lightx2v-Minimax-H3 Turbo 8-step LoRA",
73
  }
74
  DEFAULT_LORA_1_STRENGTH = 0.0
75
  DEFAULT_LORA_A_STRENGTH = 0.0
 
79
  DEFAULT_LORA_E_STRENGTH = 0.0
80
  DEFAULT_LORA_F_STRENGTH = 0.0
81
  DEFAULT_LORA_G_STRENGTH = 0.0
82
+ DEFAULT_LORA_H_STRENGTH = 0.0
83
+ DEFAULT_LORA_I_STRENGTH = 0.0
84
  # Per-LoRA, not global: different training pipelines can store SwiGLU's fc1 gate/value halves in either order,
85
  # and one flag can only be right for however many of the 8 files happen to agree. `lora1` (the Distilled/Turbo
86
  # LoRA) is confirmed needing the swap by InstantX's official conversion of the same lineage
 
377
  from huggingface_hub import hf_hub_download
378
  from safetensors import safe_open
379
 
380
+ for repo, filename in LORA_FILES.values():
381
  try:
382
+ path = hf_hub_download(repo, filename)
383
  with safe_open(path, framework="pt") as handle:
384
  keys = sorted(handle.keys())
385
  print(f"[lora-debug] {filename}: {len(keys)} keys", flush=True)
 
418
  # `_convert_diffusion_model_lora` for why this can't be read fresh per-file.
419
  base_shapes = {k: tuple(v.shape) for k, v in pipe.transformer.state_dict().items()}
420
  failures = []
421
+ for name, (repo, filename) in LORA_FILES.items():
422
  try:
423
+ path = hf_hub_download(repo, filename)
424
  with safe_open(path, framework="pt") as handle:
425
  raw = {k: handle.get_tensor(k) for k in handle.keys()}
426
  converted, network_alphas = _convert_diffusion_model_lora(
 
697
  seed=42,
698
  upsample=False,
699
  lora_1_strength=DEFAULT_LORA_1_STRENGTH,
700
+ lora_h_strength=DEFAULT_LORA_H_STRENGTH,
701
+ lora_i_strength=DEFAULT_LORA_I_STRENGTH,
702
  lora_a_strength=DEFAULT_LORA_A_STRENGTH,
703
  lora_b_strength=DEFAULT_LORA_B_STRENGTH,
704
  lora_c_strength=DEFAULT_LORA_C_STRENGTH,
 
751
 
752
  # Every UI LoRA slider gets packed into one dict here — this is the only place a new LoRA's slider value
753
  # needs wiring in; `_generate`, `set_adapters`, and the report line below are all keyed off this dict.
754
+ 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)}
755
 
756
  progress(0.1, desc=f"Denoising {int(steps)} steps at {width}x{height}, {num_frames} frames ...")
757
  call = (
 
954
  with gr.Column():
955
  video = gr.Video(label="Video + soundtrack")
956
  report = gr.Markdown()
957
+ with gr.Accordion("Distilled / Turbo LoRAs", open=False):
958
+ lora_1_strength = gr.Slider(
959
+ label="Larryvrh-MiniMax-H3 Turbo LoRA",
960
+ minimum=0.0,
961
+ maximum=2.0,
962
+ step=0.05,
963
+ value=DEFAULT_LORA_1_STRENGTH,
964
+ info="Video/Audio Shift = 6/3",
965
+ )
966
+ lora_h_strength = gr.Slider(
967
+ label="Lightx2v-Minimax-H3 Turbo 768p LoRA",
968
+ minimum=0.0,
969
+ maximum=2.0,
970
+ step=0.05,
971
+ value=DEFAULT_LORA_H_STRENGTH,
972
+ info="Video/Audio Shift = 6/3",
973
+ )
974
+ lora_i_strength = gr.Slider(
975
+ label="Lightx2v-Minimax-H3 Turbo 8-step LoRA",
976
+ minimum=0.0,
977
+ maximum=2.0,
978
+ step=0.05,
979
+ value=DEFAULT_LORA_I_STRENGTH,
980
+ info="Video/Audio Shift = 12/3",
981
+ )
982
  with gr.Accordion("Custom LoRAs", open=False):
983
  lora_a_strength = gr.Slider(
984
  label="Anthro Enhancer LoRA",
 
1046
  seed,
1047
  upsample,
1048
  lora_1_strength,
1049
+ lora_h_strength,
1050
+ lora_i_strength,
1051
  lora_a_strength,
1052
  lora_b_strength,
1053
  lora_c_strength,