Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,9 +42,9 @@ GPU_SIZE = os.environ.get("H3_GPU_SIZE", "xlarge")
|
|
| 42 |
# default, which reproduces the official weights exactly. Confirmed diffusers-native key naming (not ComfyUI,
|
| 43 |
# not pruned-AdaLN) via `xal2077/PinkCherry_MiniMax-H3-Demo`'s own working `load_state_dict(strict=True)` call
|
| 44 |
# against an earlier release of the same lineage.
|
| 45 |
-
CUSTOM_TRANSFORMER_REPO = os.environ.get("H3_CUSTOM_TRANSFORMER_REPO", "
|
| 46 |
CUSTOM_TRANSFORMER_FILE = os.environ.get(
|
| 47 |
-
"H3_CUSTOM_TRANSFORMER_FILE", "
|
| 48 |
)
|
| 49 |
|
| 50 |
LORA_REPO = os.environ.get("H3_LORA_REPO", "dagloop5/LoRA")
|
|
@@ -511,6 +511,22 @@ def load_models() -> str | None:
|
|
| 511 |
with safe_open(custom_path, framework="pt") as handle:
|
| 512 |
raw = {k: handle.get_tensor(k) for k in handle.keys()}
|
| 513 |
converted = _convert_full_checkpoint(raw, base_shapes)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 514 |
custom_transformer.load_state_dict(converted, strict=True, assign=True)
|
| 515 |
|
| 516 |
# `rope.inv_freq` is a *non-persistent* buffer (`persistent=False` in `MiniMaxH3RotaryPosEmbed`) —
|
|
|
|
| 42 |
# default, which reproduces the official weights exactly. Confirmed diffusers-native key naming (not ComfyUI,
|
| 43 |
# not pruned-AdaLN) via `xal2077/PinkCherry_MiniMax-H3-Demo`'s own working `load_state_dict(strict=True)` call
|
| 44 |
# against an earlier release of the same lineage.
|
| 45 |
+
CUSTOM_TRANSFORMER_REPO = os.environ.get("H3_CUSTOM_TRANSFORMER_REPO", "SexGod1979/PinkCherry_MiniMax-H3")
|
| 46 |
CUSTOM_TRANSFORMER_FILE = os.environ.get(
|
| 47 |
+
"H3_CUSTOM_TRANSFORMER_FILE", "v1-final-fl2va/PinkCherry_v1_bf16_fla2va_H3.safetensors"
|
| 48 |
)
|
| 49 |
|
| 50 |
LORA_REPO = os.environ.get("H3_LORA_REPO", "dagloop5/LoRA")
|
|
|
|
| 511 |
with safe_open(custom_path, framework="pt") as handle:
|
| 512 |
raw = {k: handle.get_tensor(k) for k in handle.keys()}
|
| 513 |
converted = _convert_full_checkpoint(raw, base_shapes)
|
| 514 |
+
if os.environ.get("H3_DEBUG_COMPARE", "0") == "1":
|
| 515 |
+
from huggingface_hub import hf_hub_download as _dl
|
| 516 |
+
import json as _json
|
| 517 |
+
|
| 518 |
+
index_path = _dl(MODEL_REPO, "transformer/diffusion_pytorch_model.safetensors.index.json")
|
| 519 |
+
with open(index_path) as handle:
|
| 520 |
+
index = _json.load(handle)
|
| 521 |
+
probe_key = "transformer_blocks.0.norm1.weight"
|
| 522 |
+
shard_name = index["weight_map"][probe_key]
|
| 523 |
+
shard_path = _dl(MODEL_REPO, f"transformer/{shard_name}")
|
| 524 |
+
with safe_open(shard_path, framework="pt") as official_handle:
|
| 525 |
+
official_tensor = official_handle.get_tensor(probe_key)
|
| 526 |
+
converted_tensor = converted[probe_key]
|
| 527 |
+
print(f"[debug-compare] official {probe_key}: mean={official_tensor.float().mean():.6f} std={official_tensor.float().std():.6f} first5={official_tensor.flatten()[:5].tolist()}", flush=True)
|
| 528 |
+
print(f"[debug-compare] converted {probe_key}: mean={converted_tensor.float().mean():.6f} std={converted_tensor.float().std():.6f} first5={converted_tensor.flatten()[:5].tolist()}", flush=True)
|
| 529 |
+
print(f"[debug-compare] allclose: {torch.allclose(official_tensor, converted_tensor)}", flush=True)
|
| 530 |
custom_transformer.load_state_dict(converted, strict=True, assign=True)
|
| 531 |
|
| 532 |
# `rope.inv_freq` is a *non-persistent* buffer (`persistent=False` in `MiniMaxH3RotaryPosEmbed`) —
|