From 0f266c48bda744f84020a7a9c0765adc56ec5e29 Mon Sep 17 00:00:00 2001 From: layerdiffusion <19834515+lllyasviel@users.noreply.github.com> Date: Sat, 17 Aug 2024 19:00:13 -0700 Subject: [PATCH] make clear_prompt_cache a function --- modules/processing.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/processing.py b/modules/processing.py index b20a8dad..eb7f3450 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -212,6 +212,12 @@ class StableDiffusionProcessing: latents_after_sampling = [] pixels_after_sampling = [] + def clear_prompt_cache(self): + self.cached_c = [None, None, None] + self.cached_uc = [None, None, None] + StableDiffusionProcessing.cached_c = [None, None, None] + StableDiffusionProcessing.cached_uc = [None, None, None] + def __post_init__(self): if self.sampler_index is not None: print("sampler_index argument for StableDiffusionProcessing does not do anything; use sampler_name", file=sys.stderr) @@ -792,10 +798,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed: memory_management.unload_all_models() if need_global_unload: - StableDiffusionProcessing.cached_c = [None, None, None] - StableDiffusionProcessing.cached_uc = [None, None, None] - p.cached_c = [None, None, None] - p.cached_uc = [None, None, None] + p.clear_prompt_cache() need_global_unload = False