diff --git a/installer.py b/installer.py index b4f9d0a2a..71c200f29 100644 --- a/installer.py +++ b/installer.py @@ -957,10 +957,14 @@ def git_reset(): log.warning('Running GIT reset') global quick_allowed # pylint: disable=global-statement quick_allowed = False - git('merge --abort') + git('add .') + git('stash') + git('merge --abort', folder=None, ignore=True) git('fetch --all') git('reset --hard origin/master') git('checkout master') + git('submodule update --init --recursive') + git('submodule sync --recursive') log.info('GIT reset complete') diff --git a/modules/images.py b/modules/images.py index 1c930b212..0842dfa37 100644 --- a/modules/images.py +++ b/modules/images.py @@ -9,6 +9,7 @@ import string import hashlib import queue import threading +from pathlib import Path from collections import namedtuple import pytz import numpy as np @@ -266,58 +267,48 @@ def resize_image(resize_mode, im, width, height, upscaler_name=None, output_type return res -invalid_filename_chars = '<>:"/\\|?*\n' -invalid_filename_prefix = ' ' -invalid_filename_postfix = ' .' re_nonletters = re.compile(r'[\s' + string.punctuation + ']+') re_pattern = re.compile(r"(.*?)(?:\[([^\[\]]+)\]|$)") re_pattern_arg = re.compile(r"(.*)<([^>]*)>$") -max_filename_part_length = 128 +# re_attention = re.compile(r'\((\w+):\d+(\.\d+)?\)') +re_attention = re.compile(r'[\(*\[*](\w+)(:\d+(\.\d+))?[\)*\]*]|') +re_network = re.compile(r'\<\w+:(\w+)(:\d+(\.\d+))?\>|') +re_brackets = re.compile(r'[\([{})\]]') + NOTHING = object() -def sanitize_filename_part(text, replace_spaces=True): - if text is None: - return None - text = os.path.basename(text) - if replace_spaces: - text = text.replace(' ', '_') - text = text.replace('#', '_') - text = text.translate({ord(x): '_' for x in invalid_filename_chars}) - text = text.lstrip(invalid_filename_prefix)[:max_filename_part_length] - text = text.rstrip(invalid_filename_postfix) - return text - - class FilenameGenerator: replacements = { + 'width': lambda self: self.image.width, + 'height': lambda self: self.image.height, 'batch_number': lambda self: self.batch_number, 'iter_number': lambda self: self.iter_number, - 'cfg': lambda self: self.p and self.p.cfg_scale, - 'clip_skip': lambda self: self.p and self.p.clip_skip, + 'num': lambda self: NOTHING if self.p.n_iter == 1 and self.p.batch_size == 1 else self.p.iteration * self.p.batch_size + self.p.batch_index + 1, + 'generation_number': lambda self: NOTHING if self.p.n_iter == 1 and self.p.batch_size == 1 else self.p.iteration * self.p.batch_size + self.p.batch_index + 1, 'date': lambda self: datetime.datetime.now().strftime('%Y-%m-%d'), 'datetime': lambda self, *args: self.datetime(*args), # accepts formats: [datetime], [datetime], [datetime