Skip to content

Commit

Permalink
get_key_patches now works without unloading the model.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Sep 17, 2024
1 parent 56e8f5e commit 0849c80
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions comfy/model_patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,21 @@ def add_patches(self, patches, strength_patch=1.0, strength_model=1.0):
return list(p)

def get_key_patches(self, filter_prefix=None):
comfy.model_management.unload_model_clones(self)
model_sd = self.model_state_dict()
p = {}
for k in model_sd:
if filter_prefix is not None:
if not k.startswith(filter_prefix):
continue
bk = self.backup.get(k, None)
if bk is not None:
weight = bk.weight
else:
weight = model_sd[k]
if k in self.patches:
p[k] = [model_sd[k]] + self.patches[k]
p[k] = [weight] + self.patches[k]
else:
p[k] = (model_sd[k],)
p[k] = (weight,)
return p

def model_state_dict(self, filter_prefix=None):
Expand Down

0 comments on commit 0849c80

Please sign in to comment.