Update unet_patcher.py

This commit is contained in:
lllyasviel 2024-02-03 23:03:21 -08:00
parent dc082be7f9
commit 8be7b347aa

View File

@ -112,13 +112,15 @@ class UnetPatcher(ModelPatcher):
class ExampleScript(scripts.Script): class ExampleScript(scripts.Script):
def process_batch(self, p, *args, **kwargs): def process_batch(self, p, *args, **kwargs):
unet = p.sd_model.forge_objects.unet unet = p.sd_model.forge_objects.unet.clone()
def modifier(x): def modifier(x):
return x ** 0.5 return x ** 0.5
unet.add_alphas_cumprod_modifier(modifier) unet.add_alphas_cumprod_modifier(modifier)
return p.sd_model.forge_objects.unet = unet
return
This add_alphas_cumprod_modifier is the only patch option that should be used in process_batch() 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() All other patch options should be called in process_before_every_sampling()