Make encode_from_tokens_scheduled call cleaner, rollback change in model_patcher.py for hook_patches_backup dict

This commit is contained in:
Jedrzej Kosinski 2024-11-01 02:01:45 -05:00
parent 489846905e
commit 16735c98e0
2 changed files with 8 additions and 6 deletions

View File

@ -971,7 +971,8 @@ class ModelPatcher:
if hook.hook_ref not in self.hook_patches:
weight_hooks_to_register.append(hook)
if len(weight_hooks_to_register) > 0:
self.hook_patches_backup = create_hook_patches_clone(self.hook_patches_backup)
# clone hook_patches to become backup so that any non-dynamic hooks will return to their original state
self.hook_patches_backup = create_hook_patches_clone(self.hook_patches)
for hook in weight_hooks_to_register:
hook.add_hook_patches(self, target, registered_hooks)
for callback in self.get_all_callbacks(CallbacksMP.ON_REGISTER_ALL_HOOK_PATCHES):

View File

@ -62,11 +62,12 @@ class CLIPTextEncode:
def encode(self, clip, text):
tokens = clip.tokenize(text)
if not clip.use_clip_schedule:
output = clip.encode_from_tokens(tokens, return_pooled=True, return_dict=True)
cond = output.pop("cond")
return ([[cond, output]], )
return (clip.encode_from_tokens_scheduled(tokens), )
if clip.use_clip_schedule:
return (clip.encode_from_tokens_scheduled(tokens), )
output = clip.encode_from_tokens(tokens, return_pooled=True, return_dict=True)
cond = output.pop("cond")
return ([[cond, output]], )
class ConditioningCombine:
@classmethod