Update unet_patcher.py

This commit is contained in:
lllyasviel
2024-02-03 22:54:42 -08:00
parent c11490d560
commit dc082be7f9

View File

@@ -103,6 +103,28 @@ class UnetPatcher(ModelPatcher):
return
def add_alphas_cumprod_modifier(self, modifier, ensure_uniqueness=False):
"""
For some reasons, this function only works in A1111's Script.process_batch(self, p, *args, **kwargs)
For example, below is a worked modification:
class ExampleScript(scripts.Script):
def process_batch(self, p, *args, **kwargs):
unet = p.sd_model.forge_objects.unet
def modifier(x):
return x ** 0.5
unet.add_alphas_cumprod_modifier(modifier)
return
This add_alphas_cumprod_modifier is the only patch option that should be used in process_batch()
All other patch options should be called in process_before_every_sampling()
"""
self.append_model_option('alphas_cumprod_modifiers', modifier, ensure_uniqueness)
return