From dc082be7f97a6c6cea3b57312ec42dc4c1e72d39 Mon Sep 17 00:00:00 2001 From: lllyasviel Date: Sat, 3 Feb 2024 22:54:42 -0800 Subject: [PATCH] Update unet_patcher.py --- modules_forge/unet_patcher.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules_forge/unet_patcher.py b/modules_forge/unet_patcher.py index 9e832d1c..e750e86a 100644 --- a/modules_forge/unet_patcher.py +++ b/modules_forge/unet_patcher.py @@ -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