From 75b8718ed4ff56a807e0a1be63acbe9f4a6def10 Mon Sep 17 00:00:00 2001 From: lvmin Date: Sun, 10 Sep 2023 00:35:25 -0700 Subject: [PATCH] speed up --- fooocus_version.py | 2 +- modules/async_worker.py | 23 +++++++++++++---------- modules/sdxl_styles.py | 2 ++ update_log.md | 4 ++++ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/fooocus_version.py b/fooocus_version.py index 7c4c4c06..543540dd 100644 --- a/fooocus_version.py +++ b/fooocus_version.py @@ -1 +1 @@ -version = '1.0.50' +version = '1.0.51' diff --git a/modules/async_worker.py b/modules/async_worker.py index ab546288..51cd2db5 100644 --- a/modules/async_worker.py +++ b/modules/async_worker.py @@ -53,15 +53,15 @@ def worker(): pipeline.refresh_refiner_model(refiner_model_name) pipeline.refresh_loras(loras) - outputs.append(['preview', (5, 'Encoding negative text ...', None)]) - n_txt = apply_style_negative(style_selction, negative_prompt) - n_cond = pipeline.process_prompt(n_txt) - tasks = [] if raw_mode: + outputs.append(['preview', (5, 'Encoding negative text ...', None)]) + n_txt = apply_style_negative(style_selction, negative_prompt) + n_cond = pipeline.process_prompt(n_txt) outputs.append(['preview', (9, 'Encoding positive text ...', None)]) p_txt = apply_style_positive(style_selction, prompt) p_cond = pipeline.process_prompt(p_txt) + for i in range(image_number): tasks.append(dict( prompt=prompt, @@ -74,24 +74,27 @@ def worker(): )) else: for i in range(image_number): - outputs.append(['preview', (9, f'Preparing positive text #{i + 1} ...', None)]) + outputs.append(['preview', (5, f'Preparing positive text #{i + 1} ...', None)]) current_seed = seed + i - p_txt = pipeline.expand_txt(prompt, current_seed) - print(f'Expanded positive prompt: {p_txt}') - + print(f'Expanded positive prompt: \n\n{p_txt}\n\n') p_txt = apply_style_positive(style_selction, p_txt) tasks.append(dict( prompt=prompt, negative_prompt=negative_prompt, seed=current_seed, - n_cond=n_cond, real_positive_prompt=p_txt, - real_negative_prompt=n_txt )) + + outputs.append(['preview', (9, 'Encoding negative text ...', None)]) + n_txt = apply_style_negative(style_selction, negative_prompt) + n_cond = pipeline.process_prompt(n_txt) + for i, t in enumerate(tasks): outputs.append(['preview', (12, f'Encoding positive text #{i + 1} ...', None)]) t['p_cond'] = pipeline.process_prompt(t['real_positive_prompt']) + t['real_negative_prompt'] = n_txt + t['n_cond'] = n_cond if performance_selction == 'Speed': steps = 30 diff --git a/modules/sdxl_styles.py b/modules/sdxl_styles.py index 520f5383..3026cb13 100644 --- a/modules/sdxl_styles.py +++ b/modules/sdxl_styles.py @@ -968,5 +968,7 @@ def apply_style_negative(style, txt): p, n = styles.get(style, default_style) if n == '': return txt + elif txt == '': + return n else: return n + ', ' + txt diff --git a/update_log.md b/update_log.md index 9266efc9..6b63138f 100644 --- a/update_log.md +++ b/update_log.md @@ -1,3 +1,7 @@ +### 1.0.51 + +* Speed up Prompt Expansion a bit. + ### 1.0.50 * Prompt expansion and a "Raw mode" to turn it off (similar to Midjourney's "raw").