From b865ac8b24cd2302480a9c98cbc7e0f36b0eb7f8 Mon Sep 17 00:00:00 2001 From: Jaret Burkett Date: Fri, 4 Aug 2023 05:51:58 -0600 Subject: [PATCH] Various windows bug fixes --- jobs/process/GenerateProcess.py | 2 +- jobs/process/TrainSDRescaleProcess.py | 2 +- jobs/process/TrainSliderProcess.py | 2 +- requirements.txt | 1 - toolkit/config.py | 4 ++-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/jobs/process/GenerateProcess.py b/jobs/process/GenerateProcess.py index ff017839..696d6afa 100644 --- a/jobs/process/GenerateProcess.py +++ b/jobs/process/GenerateProcess.py @@ -35,7 +35,7 @@ class GenerateConfig: raise ValueError("Prompts must be set") if isinstance(self.prompts, str): if os.path.exists(self.prompts): - with open(self.prompts, 'r') as f: + with open(self.prompts, 'r', encoding='utf-8') as f: self.prompts = f.read().splitlines() self.prompts = [p.strip() for p in self.prompts if len(p.strip()) > 0] else: diff --git a/jobs/process/TrainSDRescaleProcess.py b/jobs/process/TrainSDRescaleProcess.py index e2c4d77c..bf77db11 100644 --- a/jobs/process/TrainSDRescaleProcess.py +++ b/jobs/process/TrainSDRescaleProcess.py @@ -87,7 +87,7 @@ class TrainSDRescaleProcess(BaseSDTrainProcess): self.print(f"Loading prompt file from {self.rescale_config.prompt_file}") # read line by line from file - with open(self.rescale_config.prompt_file, 'r') as f: + with open(self.rescale_config.prompt_file, 'r', encoding='utf-8') as f: self.prompt_txt_list = f.readlines() # clean empty lines self.prompt_txt_list = [line.strip() for line in self.prompt_txt_list if len(line.strip()) > 0] diff --git a/jobs/process/TrainSliderProcess.py b/jobs/process/TrainSliderProcess.py index cb012e60..ecc99542 100644 --- a/jobs/process/TrainSliderProcess.py +++ b/jobs/process/TrainSliderProcess.py @@ -119,7 +119,7 @@ class TrainSliderProcess(BaseSDTrainProcess): # read line by line from file if self.slider_config.prompt_file: - with open(self.slider_config.prompt_file, 'r') as f: + with open(self.slider_config.prompt_file, 'r', encoding='utf-8') as f: self.prompt_txt_list = f.readlines() # clean empty lines self.prompt_txt_list = [line.strip() for line in self.prompt_txt_list if len(line.strip()) > 0] diff --git a/requirements.txt b/requirements.txt index c1938431..ca041732 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,6 @@ diffusers transformers lycoris_lora flatten_json -accelerator pyyaml oyaml tensorboard diff --git a/toolkit/config.py b/toolkit/config.py index 602e04ae..7a421a00 100644 --- a/toolkit/config.py +++ b/toolkit/config.py @@ -70,10 +70,10 @@ def get_config(config_file_path, name=None): # if we found it, check if it is a json or yaml file if real_config_path.endswith('.json') or real_config_path.endswith('.jsonc'): - with open(real_config_path, 'r') as f: + with open(real_config_path, 'r', encoding='utf-8') as f: config = json.load(f, object_pairs_hook=OrderedDict) elif real_config_path.endswith('.yaml') or real_config_path.endswith('.yml'): - with open(real_config_path, 'r') as f: + with open(real_config_path, 'r', encoding='utf-8') as f: config = yaml.load(f, Loader=fixed_loader) else: raise ValueError(f"Config file {config_file_path} must be a json or yaml file")