Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -39,37 +39,51 @@ pipe.to("cuda")
|
|
39 |
from huggingface_hub import hf_hub_download
|
40 |
import torch
|
41 |
|
|
|
|
|
|
|
42 |
# Load FusionX enhancement LoRAs
|
43 |
lora_adapters = []
|
44 |
lora_weights = []
|
45 |
|
46 |
-
#
|
47 |
-
def
|
48 |
-
print("\n
|
49 |
-
for
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
print(f"{k}: {v.shape}")
|
52 |
-
|
53 |
-
|
54 |
|
55 |
-
#
|
56 |
-
|
57 |
-
print_model_keys(pipe.text_encoder, show_values=True)
|
58 |
-
print_model_keys(pipe.vae, show_values=True)
|
59 |
|
60 |
-
# Download LoRA file
|
61 |
lora_path = hf_hub_download(repo_id=LORA_REPO_ID, filename=LORA_FILENAME)
|
62 |
|
63 |
-
#
|
64 |
-
|
65 |
-
try:
|
66 |
-
lora_checkpoint = torch.load(lora_path, map_location="cpu")
|
67 |
-
for k, v in lora_checkpoint.items():
|
68 |
-
print(f"{k}: {v.shape}")
|
69 |
-
except Exception as e:
|
70 |
-
print(f"❌ Failed to load LoRA file for key inspection: {e}")
|
71 |
|
72 |
-
# Load and
|
73 |
try:
|
74 |
pipe.load_lora_weights(lora_path, adapter_name="main")
|
75 |
pipe.set_adapters(["main"], adapter_weights=[1.0])
|
|
|
39 |
from huggingface_hub import hf_hub_download
|
40 |
import torch
|
41 |
|
42 |
+
from huggingface_hub import hf_hub_download
|
43 |
+
import torch
|
44 |
+
|
45 |
# Load FusionX enhancement LoRAs
|
46 |
lora_adapters = []
|
47 |
lora_weights = []
|
48 |
|
49 |
+
# Print all named parameters (safely) from any pipeline
|
50 |
+
def print_named_params(module, module_name=""):
|
51 |
+
print(f"\n🔍 Parameters in {module_name or 'pipeline'}:")
|
52 |
+
for name, param in module.named_parameters():
|
53 |
+
print(f"{name}: {param.shape}")
|
54 |
+
|
55 |
+
# Try printing known submodules in the pipeline
|
56 |
+
def print_all_pipeline_keys(pipe):
|
57 |
+
print("🧠 Exploring pipeline structure:")
|
58 |
+
for attr in dir(pipe):
|
59 |
+
if not attr.startswith("_"):
|
60 |
+
try:
|
61 |
+
obj = getattr(pipe, attr)
|
62 |
+
if isinstance(obj, torch.nn.Module):
|
63 |
+
print_named_params(obj, attr)
|
64 |
+
except Exception as e:
|
65 |
+
print(f"⚠️ Could not inspect {attr}: {e}")
|
66 |
+
|
67 |
+
# Print LoRA file contents
|
68 |
+
def print_lora_checkpoint_keys(path):
|
69 |
+
try:
|
70 |
+
lora_checkpoint = torch.load(path, map_location="cpu")
|
71 |
+
print("\n📦 LoRA Checkpoint Keys:")
|
72 |
+
for k, v in lora_checkpoint.items():
|
73 |
print(f"{k}: {v.shape}")
|
74 |
+
except Exception as e:
|
75 |
+
print(f"❌ Failed to load LoRA for inspection: {e}")
|
76 |
|
77 |
+
# Step 1: Explore the pipeline model structure
|
78 |
+
print_all_pipeline_keys(pipe)
|
|
|
|
|
79 |
|
80 |
+
# Step 2: Download LoRA file
|
81 |
lora_path = hf_hub_download(repo_id=LORA_REPO_ID, filename=LORA_FILENAME)
|
82 |
|
83 |
+
# Step 3: Print LoRA checkpoint keys
|
84 |
+
print_lora_checkpoint_keys(lora_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
+
# Step 4: Load and apply the LoRA
|
87 |
try:
|
88 |
pipe.load_lora_weights(lora_path, adapter_name="main")
|
89 |
pipe.set_adapters(["main"], adapter_weights=[1.0])
|