feat: add remove_performance_lora method

This commit is contained in:
Manuel Schmid 2024-05-30 00:11:07 +02:00
parent 3ef663c5b7
commit 4127fa410b
No known key found for this signature in database
GPG Key ID: 32C4F7569B40B84B
1 changed files with 17 additions and 0 deletions

View File

@ -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)