From 4dc3bd8b67e7452c587b8f43c2c0b601d2b95ca9 Mon Sep 17 00:00:00 2001 From: MoonRide303 Date: Wed, 18 Oct 2023 08:05:45 +0200 Subject: [PATCH] Improved wildcards implementation (using same wildcard multiple times will now return different values) --- fooocus_version.py | 2 +- modules/sdxl_styles.py | 3 ++- update_log.md | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fooocus_version.py b/fooocus_version.py index ed14fcbe..28c56fa7 100644 --- a/fooocus_version.py +++ b/fooocus_version.py @@ -1 +1 @@ -version = '2.1.695' +version = '2.1.696' diff --git a/modules/sdxl_styles.py b/modules/sdxl_styles.py index e8b2ea69..b1b7da3c 100644 --- a/modules/sdxl_styles.py +++ b/modules/sdxl_styles.py @@ -100,11 +100,12 @@ def apply_style(style, positive): def apply_wildcards(wildcard_text, seed=None, directory=wildcards_path): placeholders = re.findall(r'__(\w+)__', wildcard_text) + rng = random.Random(seed) for placeholder in placeholders: try: words = open(os.path.join(directory, f'{placeholder}.txt'), encoding='utf-8').read().splitlines() words = [x for x in words if x != ''] - wildcard_text = wildcard_text.replace(f'__{placeholder}__', random.Random(seed).choice(words)) + wildcard_text = wildcard_text.replace(f'__{placeholder}__', rng.choice(words), 1) except IOError: print(f'Error: could not open wildcard file {placeholder}.txt, using as normal word.') wildcard_text = wildcard_text.replace(f'__{placeholder}__', placeholder) diff --git a/update_log.md b/update_log.md index 7afbc155..bc99f7aa 100644 --- a/update_log.md +++ b/update_log.md @@ -1,3 +1,7 @@ +# 2.1.696 + +* Improved wildcards implementation (using same wildcard multiple times will now return different values). + **(2023 Oct 18) Again, the feature updating of Fooocus will be paused for about two or three weeks because we have some other workloads - we will come back in early or mid November. However, you may still see updates if other collaborators are fixing bugs or solving problems.** # 2.1.695 (requested emergency bug fix)