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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -254,6 +254,13 @@ def _convert_diffusion_model_lora(raw: dict, base_shapes: dict, swap_fc1: bool)
254
  # we never fetch, not as tensors), so these fall to the same `alpha = rank` default every other module gets.
255
  native_ab = re.compile(r"^(.+)\.(lora_[AB])\.\w+\.weight$")
256
 
 
 
 
 
 
 
 
257
  # Family B (Kohya-style): `lora_unet_blocks_N_TARGET.(lora_down|lora_up|alpha)` — covers SB and Fluid
258
  # Enhancer. `lora_down`/`lora_up` are the same A/B convention under a different name.
259
  kohya_ab = re.compile(
@@ -275,6 +282,12 @@ def _convert_diffusion_model_lora(raw: dict, base_shapes: dict, swap_fc1: bool)
275
  elif name.startswith("blocks."):
276
  name = "transformer_blocks." + name[len("blocks."):]
277
  name = name.replace("final_layer.adaln_proj.linear", "norm_out.linear")
 
 
 
 
 
 
278
  name = name.replace(".attn.out_proj", ".attn.to_out.0")
279
  name = name.replace(".mlp.fc2", ".ff.net.2")
280
  name = name.replace(".mlp.fc1", ".ff.net.0.proj")
@@ -336,6 +349,17 @@ def _convert_diffusion_model_lora(raw: dict, base_shapes: dict, swap_fc1: bool)
336
  print(f"[lora-convert] '{module_base}' isn't a real target — skipping", flush=True)
337
  continue
338
 
 
 
 
 
 
 
 
 
 
 
 
339
  match = standard_ab.match(key)
340
  if match:
341
  raw_base, ab = match.groups()
@@ -1417,6 +1441,7 @@ with gr.Blocks(title="PlagueKind · MiniMax-H3") as demo:
1417
  value=DEFAULT_INTERPOLATION,
1418
  info="MiniMax-H3 generates 24 fps; FILM synthesizes the frames in between.",
1419
  )
 
1420
  upsample = gr.Checkbox(
1421
  label="Upsample prompt",
1422
  value=False,
 
254
  # we never fetch, not as tensors), so these fall to the same `alpha = rank` default every other module gets.
255
  native_ab = re.compile(r"^(.+)\.(lora_[AB])\.\w+\.weight$")
256
 
257
+ # Family D: already-diffusers-native base names, but with Kohya's `lora_down`/`lora_up` suffixes and no
258
+ # `.weight` — confirmed against `lora1`'s own debug dump (`transformer_blocks.0.attn.to_k.lora_down`,
259
+ # `transformer_blocks.0.adaln_proj.linear.lora_down`). Distinct from `native_ab` above (needs an adapter-name
260
+ # segment plus `.weight`) and from `kohya_ab` below (needs the fused `lora_unet_blocks_N_TARGET` prefix). No
261
+ # qkv-splitting needed either way: these base names already have separate `to_q`/`to_k`/`to_v`.
262
+ native_kohya_suffix_ab = re.compile(r"^(?:diffusion_model\.)?(.+)\.(lora_down|lora_up)$")
263
+
264
  # Family B (Kohya-style): `lora_unet_blocks_N_TARGET.(lora_down|lora_up|alpha)` — covers SB and Fluid
265
  # Enhancer. `lora_down`/`lora_up` are the same A/B convention under a different name.
266
  kohya_ab = re.compile(
 
282
  elif name.startswith("blocks."):
283
  name = "transformer_blocks." + name[len("blocks."):]
284
  name = name.replace("final_layer.adaln_proj.linear", "norm_out.linear")
285
+ name = name.replace("final_layer.video_out", "proj_out")
286
+ name = name.replace("final_layer.audio_out", "audio_proj_out")
287
+ name = name.replace("final_layer.norm", "norm_out.norm")
288
+ name = name.replace("video_patch_proj", "proj_in")
289
+ name = name.replace("audio_patch_proj", "audio_proj_in")
290
+ name = name.replace("condition_proj", "context_embedder")
291
  name = name.replace(".attn.out_proj", ".attn.to_out.0")
292
  name = name.replace(".mlp.fc2", ".ff.net.2")
293
  name = name.replace(".mlp.fc1", ".ff.net.0.proj")
 
349
  print(f"[lora-convert] '{module_base}' isn't a real target — skipping", flush=True)
350
  continue
351
 
352
+ match = native_kohya_suffix_ab.match(key)
353
+ if match:
354
+ raw_base, direction = match.groups()
355
+ module_base = rename_base(raw_base) # covers the final_layer.*/patch_proj/condition_proj renames too
356
+ ab = "lora_A" if direction == "lora_down" else "lora_B"
357
+ if f"{module_base}.weight" in base_shapes:
358
+ out[f"{LORA_KEY_PREFIX}.{module_base}.{ab}.weight"] = tensor
359
+ else:
360
+ print(f"[lora-convert] '{raw_base}' renamed to '{module_base}', which isn't a real target — skipping", flush=True)
361
+ continue
362
+
363
  match = standard_ab.match(key)
364
  if match:
365
  raw_base, ab = match.groups()
 
1441
  value=DEFAULT_INTERPOLATION,
1442
  info="MiniMax-H3 generates 24 fps; FILM synthesizes the frames in between.",
1443
  )
1444
+ seed = gr.Number(label="Seed", value=42, precision=0)
1445
  upsample = gr.Checkbox(
1446
  label="Upsample prompt",
1447
  value=False,