From 92a01a3890d86f10973fe0f18a79b1d50e5d3b83 Mon Sep 17 00:00:00 2001 From: bmaltais Date: Thu, 9 May 2024 13:20:20 -0400 Subject: [PATCH] Fix issue with tensorboard --- kohya_gui/basic_caption_gui.py | 2 +- kohya_gui/blip_caption_gui.py | 2 +- kohya_gui/class_tensorboard.py | 2 +- kohya_gui/common_gui.py | 2 +- kohya_gui/convert_lcm_gui.py | 2 +- kohya_gui/convert_model_gui.py | 2 +- kohya_gui/dreambooth_gui.py | 2 +- kohya_gui/extract_lora_from_dylora_gui.py | 2 +- kohya_gui/extract_lora_gui.py | 2 +- kohya_gui/extract_lycoris_locon_gui.py | 2 +- kohya_gui/finetune_gui.py | 6 +++--- kohya_gui/git_caption_gui.py | 2 +- kohya_gui/group_images_gui.py | 2 +- kohya_gui/lora_gui.py | 2 +- kohya_gui/merge_lora_gui.py | 2 +- kohya_gui/merge_lycoris_gui.py | 2 +- kohya_gui/resize_lora_gui.py | 2 +- kohya_gui/svd_merge_lora_gui.py | 2 +- kohya_gui/textual_inversion_gui.py | 2 +- kohya_gui/verify_lora_gui.py | 2 +- kohya_gui/wd14_caption_gui.py | 2 +- 21 files changed, 23 insertions(+), 23 deletions(-) diff --git a/kohya_gui/basic_caption_gui.py b/kohya_gui/basic_caption_gui.py index 99b32cdac..d352954a1 100644 --- a/kohya_gui/basic_caption_gui.py +++ b/kohya_gui/basic_caption_gui.py @@ -85,7 +85,7 @@ def caption_images( log.info(f"Executing command: {command_to_run}") # Set the environment variable for the Python path - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Run the command in the sd-scripts folder context subprocess.run(run_cmd, env=env, shell=False) diff --git a/kohya_gui/blip_caption_gui.py b/kohya_gui/blip_caption_gui.py index a710acc6a..058a8dea6 100644 --- a/kohya_gui/blip_caption_gui.py +++ b/kohya_gui/blip_caption_gui.py @@ -87,7 +87,7 @@ def caption_images( ) # Set up the environment - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Reconstruct the safe command string for display command_to_run = " ".join(run_cmd) diff --git a/kohya_gui/class_tensorboard.py b/kohya_gui/class_tensorboard.py index 2f2be2b72..b9a9a9c4b 100644 --- a/kohya_gui/class_tensorboard.py +++ b/kohya_gui/class_tensorboard.py @@ -73,7 +73,7 @@ def start_tensorboard(self, logging_dir=None): self.log.info("Starting TensorBoard on port {}".format(self.tensorboard_port)) try: - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() self.tensorboard_proc = subprocess.Popen(run_cmd, env=env) except Exception as e: self.log.error("Failed to start Tensorboard:", e) diff --git a/kohya_gui/common_gui.py b/kohya_gui/common_gui.py index 0252ff118..8fb9b180c 100644 --- a/kohya_gui/common_gui.py +++ b/kohya_gui/common_gui.py @@ -1485,7 +1485,7 @@ def validate_args_setting(input_string): ) return False -def setup_environment(scriptdir: str): +def setup_environment(): env = os.environ.copy() env["PYTHONPATH"] = ( fr"{scriptdir}{os.pathsep}{scriptdir}/sd-scripts{os.pathsep}{env.get('PYTHONPATH', '')}" diff --git a/kohya_gui/convert_lcm_gui.py b/kohya_gui/convert_lcm_gui.py index 8f71902bc..1c7e77162 100644 --- a/kohya_gui/convert_lcm_gui.py +++ b/kohya_gui/convert_lcm_gui.py @@ -62,7 +62,7 @@ def convert_lcm( run_cmd.append("--ssd-1b") # Set up the environment - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Reconstruct the safe command string for display command_to_run = " ".join(run_cmd) diff --git a/kohya_gui/convert_model_gui.py b/kohya_gui/convert_model_gui.py index 93ce4fe01..be76127a5 100644 --- a/kohya_gui/convert_model_gui.py +++ b/kohya_gui/convert_model_gui.py @@ -99,7 +99,7 @@ def convert_model( # Log the command log.info(" ".join(run_cmd)) - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Run the command subprocess.run(run_cmd, env=env, shell=False) diff --git a/kohya_gui/dreambooth_gui.py b/kohya_gui/dreambooth_gui.py index ae4c8efa6..62cab8bd1 100644 --- a/kohya_gui/dreambooth_gui.py +++ b/kohya_gui/dreambooth_gui.py @@ -899,7 +899,7 @@ def train_model( # log.info(run_cmd) - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Run the command diff --git a/kohya_gui/extract_lora_from_dylora_gui.py b/kohya_gui/extract_lora_from_dylora_gui.py index 63f91ba3c..0e06fe0c3 100644 --- a/kohya_gui/extract_lora_from_dylora_gui.py +++ b/kohya_gui/extract_lora_from_dylora_gui.py @@ -59,7 +59,7 @@ def extract_dylora( str(unit), ] - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Reconstruct the safe command string for display command_to_run = " ".join(run_cmd) diff --git a/kohya_gui/extract_lora_gui.py b/kohya_gui/extract_lora_gui.py index 886bff05c..62b12fd9f 100644 --- a/kohya_gui/extract_lora_gui.py +++ b/kohya_gui/extract_lora_gui.py @@ -109,7 +109,7 @@ def extract_lora( run_cmd.append("--load_tuned_model_to") run_cmd.append(load_tuned_model_to) - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Reconstruct the safe command string for display command_to_run = " ".join(run_cmd) diff --git a/kohya_gui/extract_lycoris_locon_gui.py b/kohya_gui/extract_lycoris_locon_gui.py index 5805a7acb..a33a8ece1 100644 --- a/kohya_gui/extract_lycoris_locon_gui.py +++ b/kohya_gui/extract_lycoris_locon_gui.py @@ -123,7 +123,7 @@ def extract_lycoris_locon( run_cmd.append(fr"{db_model}") run_cmd.append(fr"{output_name}") - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Reconstruct the safe command string for display command_to_run = " ".join(run_cmd) diff --git a/kohya_gui/finetune_gui.py b/kohya_gui/finetune_gui.py index ee7ed4cb1..7bc95f9aa 100644 --- a/kohya_gui/finetune_gui.py +++ b/kohya_gui/finetune_gui.py @@ -639,7 +639,7 @@ def train_model( log.info(" ".join(run_cmd)) # Prepare environment variables - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # create images buckets if generate_image_buckets: @@ -677,7 +677,7 @@ def train_model( log.info(" ".join(run_cmd)) # Copy and modify environment variables - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Execute the command if not just for printing if not print_only: @@ -953,7 +953,7 @@ def train_model( # log.info(run_cmd) - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Run the command executor.execute_command(run_cmd=run_cmd, env=env) diff --git a/kohya_gui/git_caption_gui.py b/kohya_gui/git_caption_gui.py index 335aed1ff..f1b1003ee 100644 --- a/kohya_gui/git_caption_gui.py +++ b/kohya_gui/git_caption_gui.py @@ -58,7 +58,7 @@ def caption_images( # Add the directory containing the training data run_cmd.append(fr"{train_data_dir}") - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Reconstruct the safe command string for display command_to_run = " ".join(run_cmd) diff --git a/kohya_gui/group_images_gui.py b/kohya_gui/group_images_gui.py index 404e23a81..af83446b2 100644 --- a/kohya_gui/group_images_gui.py +++ b/kohya_gui/group_images_gui.py @@ -51,7 +51,7 @@ def group_images( run_cmd.append("--caption_ext") run_cmd.append(caption_ext) - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Reconstruct the safe command string for display command_to_run = " ".join(run_cmd) diff --git a/kohya_gui/lora_gui.py b/kohya_gui/lora_gui.py index 4ecc48913..06653f668 100644 --- a/kohya_gui/lora_gui.py +++ b/kohya_gui/lora_gui.py @@ -1282,7 +1282,7 @@ def train_model( ) # log.info(run_cmd) - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Run the command diff --git a/kohya_gui/merge_lora_gui.py b/kohya_gui/merge_lora_gui.py index 789c26865..a3337c4cf 100644 --- a/kohya_gui/merge_lora_gui.py +++ b/kohya_gui/merge_lora_gui.py @@ -451,7 +451,7 @@ def merge_lora( map(str, valid_ratios) ) # Convert ratios to strings and include them as separate arguments - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Reconstruct the safe command string for display command_to_run = " ".join(run_cmd) diff --git a/kohya_gui/merge_lycoris_gui.py b/kohya_gui/merge_lycoris_gui.py index a6e132584..2fde5e958 100644 --- a/kohya_gui/merge_lycoris_gui.py +++ b/kohya_gui/merge_lycoris_gui.py @@ -59,7 +59,7 @@ def merge_lycoris( run_cmd.append("--is_v2") # Copy and update the environment variables - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Reconstruct the safe command string for display command_to_run = " ".join(run_cmd) diff --git a/kohya_gui/resize_lora_gui.py b/kohya_gui/resize_lora_gui.py index 7baaedf87..b4836d6a7 100644 --- a/kohya_gui/resize_lora_gui.py +++ b/kohya_gui/resize_lora_gui.py @@ -90,7 +90,7 @@ def resize_lora( if verbose: run_cmd.append("--verbose") - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Reconstruct the safe command string for display command_to_run = " ".join(run_cmd) diff --git a/kohya_gui/svd_merge_lora_gui.py b/kohya_gui/svd_merge_lora_gui.py index 706845f68..519fd5f5d 100644 --- a/kohya_gui/svd_merge_lora_gui.py +++ b/kohya_gui/svd_merge_lora_gui.py @@ -95,7 +95,7 @@ def add_model(model_path, ratio): # Log the command log.info(" ".join(run_cmd)) - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Run the command subprocess.run(run_cmd, env=env) diff --git a/kohya_gui/textual_inversion_gui.py b/kohya_gui/textual_inversion_gui.py index 47d24a81a..0740fa5ab 100644 --- a/kohya_gui/textual_inversion_gui.py +++ b/kohya_gui/textual_inversion_gui.py @@ -916,7 +916,7 @@ def train_model( exclusion=["file_path", "save_as", "headless", "print_only"], ) - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Run the command diff --git a/kohya_gui/verify_lora_gui.py b/kohya_gui/verify_lora_gui.py index 888c88292..f50aca2ba 100644 --- a/kohya_gui/verify_lora_gui.py +++ b/kohya_gui/verify_lora_gui.py @@ -46,7 +46,7 @@ def verify_lora( log.info(f"Executing command: {command_to_run}") # Set the environment variable for the Python path - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Run the command using subprocess.Popen for asynchronous handling process = subprocess.Popen( diff --git a/kohya_gui/wd14_caption_gui.py b/kohya_gui/wd14_caption_gui.py index ba18195ef..3456f70be 100644 --- a/kohya_gui/wd14_caption_gui.py +++ b/kohya_gui/wd14_caption_gui.py @@ -117,7 +117,7 @@ def caption_images( # Add the directory containing the training data run_cmd.append(rf"{train_data_dir}") - env = setup_environment(scriptdir=scriptdir) + env = setup_environment() # Reconstruct the safe command string for display command_to_run = " ".join(run_cmd)