mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-10 14:20:49 +08:00
Update utils.py
This commit is contained in:
parent
5fe4119d53
commit
88644341ca
@ -118,15 +118,15 @@ def state_dict_key_replace(state_dict, keys_to_replace):
|
|||||||
return state_dict
|
return state_dict
|
||||||
|
|
||||||
def state_dict_prefix_replace(state_dict, replace_prefix, filter_keys=False):
|
def state_dict_prefix_replace(state_dict, replace_prefix, filter_keys=False):
|
||||||
if not filter_keys:
|
if filter_keys:
|
||||||
return {}
|
out = {}
|
||||||
else:
|
|
||||||
out = state_dict
|
|
||||||
for old_prefix, new_prefix in replace_prefix.items():
|
for old_prefix, new_prefix in replace_prefix.items():
|
||||||
keys_to_replace = [key for key in state_dict if key.startswith(old_prefix)]
|
keys_to_replace = [key for key in state_dict if key.startswith(old_prefix)]
|
||||||
for key in keys_to_replace:
|
for key in keys_to_replace:
|
||||||
new_key = new_prefix + key[len(old_prefix):]
|
new_key = new_prefix + key[len(old_prefix):]
|
||||||
out[new_key] = state_dict.pop(key)
|
out[new_key] = state_dict.pop(key)
|
||||||
|
else:
|
||||||
|
out = state_dict
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user