dagloop5 commited on
Commit
8b0f7dd
·
verified ·
1 Parent(s): 90d9504

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -5
app.py CHANGED
@@ -45,7 +45,7 @@ LORA_FILES = {
45
  os.environ.get("H3_LORA_I_REPO", "alibaba-pai/MiniMax-H3-Acc-LoRAs"),
46
  os.environ.get("H3_LORA_I_FILE", "MiniMax-H3-FL2VA-Acc-8Step.safetensors"),
47
  ),
48
- "loraa": (LORA_REPO, os.environ.get("H3_LORA_A_FILE", "minimax-h3_fl2v_general_helper_3xd.safetensors")),
49
  "lorab": (LORA_REPO, os.environ.get("H3_LORA_B_FILE", "TCI_MiniMax_H3.safetensors")),
50
  "lorac": (LORA_REPO, os.environ.get("H3_LORA_C_FILE", "HM-AIO-V2.5.safetensors")),
51
  "lorad": (LORA_REPO, os.environ.get("H3_LORA_D_FILE", "Furry enhancer Video H3 V2.54.safetensors")),
@@ -69,7 +69,7 @@ LORA_FILES = {
69
  # the status line's failure list. Keep these two dicts' keys in sync when adding a LoRA.
70
  LORA_LABELS = {
71
  "lora1": "MiniMax-H3-FL2VA-Acc-8Step",
72
- "loraa": "General Enhancer",
73
  "lorab": "TCI",
74
  "lorac": "HM-AIO", # hmmotion
75
  "lorad": "Anthro Realism",
@@ -442,7 +442,7 @@ def load_models() -> str | None:
442
  import torch
443
  from diffusers import ComponentsManager
444
 
445
- from h3_split_blocks import MiniMaxH3GeneratorBlocks
446
 
447
  lower_duration_floor()
448
  raise_duration_ceiling()
@@ -732,6 +732,10 @@ def _generate(
732
  video_shift,
733
  audio_shift,
734
  proj_cache,
 
 
 
 
735
  sampler,
736
  total_steps,
737
  stage_from,
@@ -820,6 +824,19 @@ def _generate(
820
  if resume_video_latents is not None
821
  else {}
822
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
823
  if given_video is not None:
824
  # Momentum: keyframe-free, so no `image`/`last_image` at all — the carried clip already
825
  # determines the opening frames more directly than a keyframe could.
@@ -849,6 +866,7 @@ def _generate(
849
  output_type="pt",
850
  generator=torch.Generator("cpu").manual_seed(int(seed)),
851
  **resume_kwargs,
 
852
  )
853
 
854
  denoised = time.time() - started
@@ -934,6 +952,10 @@ def generate(
934
  semantic_bridge_magnitude_match="per_token",
935
  semantic_bridge_adapter="semantic_bridge_v1",
936
  proj_cache=True,
 
 
 
 
937
  progress=gr.Progress(track_tqdm=True),
938
  *,
939
  advance: bool = False,
@@ -1084,6 +1106,10 @@ def generate(
1084
  float(video_shift),
1085
  float(audio_shift),
1086
  bool(proj_cache),
 
 
 
 
1087
  SAMPLERS.get(sampler, "euler"),
1088
  int(target_steps) if stage_enabled else None,
1089
  steps_done if advance else 0,
@@ -1494,9 +1520,9 @@ with gr.Blocks(title="PlagueKind · MiniMax-H3") as demo:
1494
  )
1495
  with gr.Accordion("Custom LoRAs", open=False):
1496
  lora_a_strength = gr.Slider(
1497
- label="General Enhancer LoRA",
1498
  minimum=0.0,
1499
- maximum=2.0,
1500
  step=0.05,
1501
  value=DEFAULT_LORA_A_STRENGTH,
1502
  )
@@ -1626,6 +1652,25 @@ with gr.Blocks(title="PlagueKind · MiniMax-H3") as demo:
1626
  "bunny_action_logic_v1: action/combat, character-action ownership in multi-character scenes.",
1627
  )
1628
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1629
  with gr.Accordion("Chunked Generation", open=False, visible=False):
1630
  gr.Markdown(
1631
  "Splits a longer product into independent, full-quality chunks joined afterward — each "
@@ -1731,6 +1776,10 @@ with gr.Blocks(title="PlagueKind · MiniMax-H3") as demo:
1731
  semantic_bridge_magnitude_match,
1732
  semantic_bridge_adapter,
1733
  proj_cache,
 
 
 
 
1734
  ]
1735
 
1736
  # `functools.partial` binds `advance`/`chunk_advance` by keyword regardless of their position in `generate`'s
 
45
  os.environ.get("H3_LORA_I_REPO", "alibaba-pai/MiniMax-H3-Acc-LoRAs"),
46
  os.environ.get("H3_LORA_I_FILE", "MiniMax-H3-FL2VA-Acc-8Step.safetensors"),
47
  ),
48
+ "loraa": (LORA_REPO, os.environ.get("H3_LORA_A_FILE", "SLIDER_LG_H3.safetensors")),
49
  "lorab": (LORA_REPO, os.environ.get("H3_LORA_B_FILE", "TCI_MiniMax_H3.safetensors")),
50
  "lorac": (LORA_REPO, os.environ.get("H3_LORA_C_FILE", "HM-AIO-V2.5.safetensors")),
51
  "lorad": (LORA_REPO, os.environ.get("H3_LORA_D_FILE", "Furry enhancer Video H3 V2.54.safetensors")),
 
69
  # the status line's failure list. Keep these two dicts' keys in sync when adding a LoRA.
70
  LORA_LABELS = {
71
  "lora1": "MiniMax-H3-FL2VA-Acc-8Step",
72
+ "loraa": "Fluid Enhancer",
73
  "lorab": "TCI",
74
  "lorac": "HM-AIO", # hmmotion
75
  "lorad": "Anthro Realism",
 
442
  import torch
443
  from diffusers import ComponentsManager
444
 
445
+ from h3_keyframe_control import MiniMaxH3KeyframeGeneratorBlocks as MiniMaxH3GeneratorBlocks
446
 
447
  lower_duration_floor()
448
  raise_duration_ceiling()
 
732
  video_shift,
733
  audio_shift,
734
  proj_cache,
735
+ first_frame_at,
736
+ last_frame_at,
737
+ first_frame_strength,
738
+ last_frame_strength,
739
  sampler,
740
  total_steps,
741
  stage_from,
 
824
  if resume_video_latents is not None
825
  else {}
826
  )
827
+ present = [
828
+ (first_frame_at, first_frame_strength, first_frame),
829
+ (last_frame_at, last_frame_strength, last_frame),
830
+ ]
831
+ present = [(f, s) for f, s, img in present if img is not None]
832
+ keyframe_kwargs = (
833
+ {
834
+ "keyframe_frames": tuple(f for f, _ in present),
835
+ "keyframe_strengths": tuple(s for _, s in present),
836
+ }
837
+ if present
838
+ else {}
839
+ )
840
  if given_video is not None:
841
  # Momentum: keyframe-free, so no `image`/`last_image` at all — the carried clip already
842
  # determines the opening frames more directly than a keyframe could.
 
866
  output_type="pt",
867
  generator=torch.Generator("cpu").manual_seed(int(seed)),
868
  **resume_kwargs,
869
+ **keyframe_kwargs,
870
  )
871
 
872
  denoised = time.time() - started
 
952
  semantic_bridge_magnitude_match="per_token",
953
  semantic_bridge_adapter="semantic_bridge_v1",
954
  proj_cache=True,
955
+ first_frame_at=0,
956
+ last_frame_at=361,
957
+ first_frame_strength=0.999,
958
+ last_frame_strength=0.999,
959
  progress=gr.Progress(track_tqdm=True),
960
  *,
961
  advance: bool = False,
 
1106
  float(video_shift),
1107
  float(audio_shift),
1108
  bool(proj_cache),
1109
+ int(first_frame_at),
1110
+ int(last_frame_at),
1111
+ float(first_frame_strength),
1112
+ float(last_frame_strength),
1113
  SAMPLERS.get(sampler, "euler"),
1114
  int(target_steps) if stage_enabled else None,
1115
  steps_done if advance else 0,
 
1520
  )
1521
  with gr.Accordion("Custom LoRAs", open=False):
1522
  lora_a_strength = gr.Slider(
1523
+ label="Fluid Enhancer LoRA",
1524
  minimum=0.0,
1525
+ maximum=5.0,
1526
  step=0.05,
1527
  value=DEFAULT_LORA_A_STRENGTH,
1528
  )
 
1652
  "bunny_action_logic_v1: action/combat, character-action ownership in multi-character scenes.",
1653
  )
1654
 
1655
+ with gr.Accordion("Keyframe Injection", open=False):
1656
+ gr.Markdown(
1657
+ "Which pixel frame each keyframe is injected at, and how strongly. Defaults are the stock "
1658
+ "first/last behavior. Other positions were not trained for and may or may not work."
1659
+ )
1660
+ first_frame_at = gr.Slider(
1661
+ label="First image: injection frame", minimum=0, maximum=361, step=1, value=0
1662
+ )
1663
+ last_frame_at = gr.Slider(
1664
+ label="Last image: injection frame (max = end of video)",
1665
+ minimum=0, maximum=361, step=1, value=361,
1666
+ )
1667
+ first_frame_strength = gr.Slider(
1668
+ label="First image: strength", minimum=0.0, maximum=0.999, step=0.001, value=0.999
1669
+ )
1670
+ last_frame_strength = gr.Slider(
1671
+ label="Last image: strength", minimum=0.0, maximum=0.999, step=0.001, value=0.999
1672
+ )
1673
+
1674
  with gr.Accordion("Chunked Generation", open=False, visible=False):
1675
  gr.Markdown(
1676
  "Splits a longer product into independent, full-quality chunks joined afterward — each "
 
1776
  semantic_bridge_magnitude_match,
1777
  semantic_bridge_adapter,
1778
  proj_cache,
1779
+ first_frame_at,
1780
+ last_frame_at,
1781
+ first_frame_strength,
1782
+ last_frame_strength,
1783
  ]
1784
 
1785
  # `functools.partial` binds `advance`/`chunk_advance` by keyword regardless of their position in `generate`'s