diff --git a/0001-patch-in-support-for-distributed-extension.patch b/0001-patch-in-support-for-distributed-extension.patch deleted file mode 100644 index 5010d29..0000000 --- a/0001-patch-in-support-for-distributed-extension.patch +++ /dev/null @@ -1,86 +0,0 @@ -From 6f19ead7d391655077d7aafea01ed3979cd4e24d Mon Sep 17 00:00:00 2001 -From: papuSpartan <30642826+papuSpartan@users.noreply.github.com> -Date: Sun, 21 May 2023 18:10:43 -0500 -Subject: [PATCH] update patch - ---- - modules/img2img.py | 2 ++ - modules/script_callbacks.py | 14 ++++++++++++++ - modules/txt2img.py | 2 ++ - 3 files changed, 18 insertions(+) - -diff --git a/modules/img2img.py b/modules/img2img.py -index d704bf90..d817de90 100644 ---- a/modules/img2img.py -+++ b/modules/img2img.py -@@ -11,6 +11,7 @@ import modules.shared as shared - import modules.processing as processing - from modules.ui import plaintext_to_html - import modules.scripts -+from modules import script_callbacks - - - def process_batch(p, input_dir, output_dir, inpaint_mask_dir, args): -@@ -178,6 +179,7 @@ def img2img(id_task: str, mode: int, prompt: str, negative_prompt: str, prompt_s - processed = process_images(p) - - p.close() -+ script_callbacks.after_batch_processed_callback(processed=processed, options=p) - - shared.total_tqdm.clear() - -diff --git a/modules/script_callbacks.py b/modules/script_callbacks.py -index 40f388a5..e7c5f6fb 100644 ---- a/modules/script_callbacks.py -+++ b/modules/script_callbacks.py -@@ -109,6 +109,7 @@ callback_map = dict( - callbacks_infotext_pasted=[], - callbacks_script_unloaded=[], - callbacks_before_ui=[], -+ callbacks_after_batch_processed=[], - callbacks_on_reload=[], - callbacks_list_optimizers=[], - ) -@@ -142,6 +143,19 @@ def model_loaded_callback(sd_model): - except Exception: - report_exception(c, 'model_loaded_callback') - -+def after_batch_processed_callback(processed, options): -+ for c in callback_map['callbacks_after_batch_processed']: -+ try: -+ return c.callback(processed, options) -+ except Exception: -+ report_exception(c, 'after_batch_processed_callback') -+ -+def on_after_batch_processed(callback): -+ """register a function to be called right after a batch is processed""" -+ -+ add_callback(callback_map['callbacks_after_batch_processed'], callback) -+ -+ - - def ui_tabs_callback(): - res = [] -diff --git a/modules/txt2img.py b/modules/txt2img.py -index 2e7d202d..a655c3d7 100644 ---- a/modules/txt2img.py -+++ b/modules/txt2img.py -@@ -4,6 +4,7 @@ from modules.generation_parameters_copypaste import create_override_settings_dic - from modules.shared import opts, cmd_opts - import modules.shared as shared - from modules.ui import plaintext_to_html -+from modules import script_callbacks - - - -@@ -56,6 +57,7 @@ def txt2img(id_task: str, prompt: str, negative_prompt: str, prompt_styles, step - if processed is None: - processed = processing.process_images(p) - -+ script_callbacks.after_batch_processed_callback(processed=processed, options=p) - p.close() - - shared.total_tqdm.clear() --- -2.40.0.windows.1 - diff --git a/README.md b/README.md index 29866cd..ee4aba9 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,8 @@ In practice, this means being able to tell a bunch of machines to generate image **Contributions and feedback are much appreciated!** ## Installation -**DISCLAIMER - I do NOT recommend casual users use this yet unless you are okay with the possibility of severe instability** On the master instance: -- Apply the patch for the [dev branch of sdwui](https://github.com/AUTOMATIC1111/stable-diffusion-webui/tree/dev) which is up to date with at least [commit 3366e49](https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/3366e494a1147e570d8527eea19da88edb3a1e0c) - - In your sdwui installation folder: `git apply --ignore-whitespace extensions/stable-diffusion-webui-distributed/0001-patch-in-support-for-distributed-extension.patch` - - Go to the "Extensions" tab and then swap to the "Install from URL" tab - Paste https://github.com/papuSpartan/stable-diffusion-webui-distributed.git into "URL for extension's git repository" and click install - Ensure that you have setup your `COMMANDLINE_ARGS` include the necessary info on your remote machines. Ex: diff --git a/scripts/extension.py b/scripts/extension.py index e062405..eafbf33 100644 --- a/scripts/extension.py +++ b/scripts/extension.py @@ -7,7 +7,7 @@ import io import json import re import gradio -from modules import scripts, script_callbacks +from modules import scripts from modules import processing from threading import Thread from PIL import Image @@ -238,7 +238,6 @@ class Script(scripts.Script): """ worker.response = None - Script.unregister_callbacks() return @staticmethod @@ -271,9 +270,6 @@ class Script(scripts.Script): if cmd_opts.distributed_remotes is None: raise RuntimeError("Distributed - No remotes passed. (Try using `--distributed-remotes`?)") - # register gallery callback - script_callbacks.on_after_batch_processed(Script.add_to_gallery) - Script.initialize(initial_payload=p) # encapsulating the request object within a txt2imgreq object is deprecated and no longer works @@ -293,6 +289,7 @@ class Script(scripts.Script): "sd_vae": vae } + # start generating images assigned to remote machines sync = False # should only really to sync once per job Script.world.optimize_jobs(payload) # optimize work assignment before dispatching for job in Script.world.jobs: @@ -315,12 +312,9 @@ class Script(scripts.Script): # if master batch size was changed again due to optimization change it to the updated value p.batch_size = Script.world.get_master_batch_size() Script.master_start = time.time() - # return processing.process_images(p, *args) - @staticmethod - def unregister_callbacks(): - script_callbacks.remove_current_script_callbacks() + # generate images assigned to local machine + processed = processing.process_images(p, *args) + Script.add_to_gallery(processed, p) - -# not actually called when user selects a different script in the ui dropdown -script_callbacks.on_script_unloaded(Script.unregister_callbacks) + return processed