From 4127fa410b3efff48e59915c2b575d2a768f7c00 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Thu, 30 May 2024 00:11:07 +0200 Subject: [PATCH] feat: add remove_performance_lora method --- modules/util.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/modules/util.py b/modules/util.py index 8317dd50..3f712214 100644 --- a/modules/util.py +++ b/modules/util.py @@ -16,6 +16,7 @@ from PIL import Image import modules.config import modules.sdxl_styles +from modules.flags import Performance LANCZOS = (Image.Resampling.LANCZOS if hasattr(Image, 'Resampling') else Image.LANCZOS) @@ -440,6 +441,22 @@ def parse_lora_references_from_prompt(prompt: str, loras: List[Tuple[AnyStr, flo return updated_loras[:loras_limit], cleaned_prompt +def remove_performance_lora(filenames: list, performance: Performance | None): + loras_without_performance = filenames.copy() + + if performance is None: + return loras_without_performance + + performance_lora = performance.lora_filename() + + for filename in filenames: + path = Path(filename) + if performance_lora == path.name: + loras_without_performance.remove(filename) + + return loras_without_performance + + def cleanup_prompt(prompt): prompt = re.sub(' +', ' ', prompt) prompt = re.sub(',+', ',', prompt)