Update app.py
Browse files206 unmodified lines20720820921021121221321421521621721821922022167 unmodified lines289290291292293294295296297298299300301302303206 unmodified lines standard_ab = re.compile(r"^(?:diffusion_model\.)?(.+)\.(lora_[AB])\.weight$") standard_alpha = re.compile(r"^(?:diffusion_model\.)?(.+)\.alpha$")
# Family C: already-diffusers-native, PEFT's own serialization layout — `{module}.lora_A.<adapter>.weight`, # confirmed against the debug dump's `transformer_blocks.0.*`/`token_refiner.refiner_blocks.*` shapes: no # fused `qkv_proj` to split (`to_q`/`to_k`/`to_v` are already separate), no `mlp.fc1`/`fc2` to rename (already # `ff.net.0.proj`/`ff.net.2`). The `<adapter>` segment is whatever adapter name the file happened to be saved # under (e.g. "default") — discarded, since each file gets its own `adapter_name` here regardless. No `.alpha` # keys exist in this family either (PEFT's native format keeps `lora_alpha` in a sidecar `adapter_config.json` # we never fetch, not as tensors), so these fall to the same `alpha = rank` default every other module gets. native_ab = re.compile(r"^(.+)\.(lora_[AB])\.\w+\.weight$")
# Family B (Kohya-style): `lora_unet_blocks_N_TARGET.(lora_down|lora_up|alpha)` — covers SB and Fluid # Enhancer. `lora_down`/`lora_up` are the same A/B convention under a different name. kohya_ab = re.compile(67 unmodified lines # adapter's dtype to match the wrapped base layer's. tensor = raw_tensor.to(torch.bfloat16)
match = native_ab.match(key) if match: module_base, ab = match.groups() if f"{module_base}.weight" in base_shapes: out[f"{LORA_KEY_PREFIX}.{module_base}.{ab}.weight"] = tensor else: print(f"[lora-convert] '{module_base}' isn't a real target — skipping", flush=True) continue
match = standard_ab.match(key) if match: raw_base, ab = match.groups()app.py+18