Skip to content

Commit

Permalink
Support loading some checkpoint files with nested dicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Dec 11, 2024
1 parent 44db978 commit 7a7efe8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion comfy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ def load_torch_file(ckpt, safe_load=False, device=None):
if "state_dict" in pl_sd:
sd = pl_sd["state_dict"]
else:
sd = pl_sd
if len(pl_sd) == 1:
key = list(pl_sd.keys())[0]
sd = pl_sd[key]
if not isinstance(sd, dict):
sd = pl_sd
else:
sd = pl_sd
return sd

def save_torch_file(sd, ckpt, metadata=None):
Expand Down

0 comments on commit 7a7efe8

Please sign in to comment.