From 9cdf2dd6e47ef11f595c028df7db07ca7df54f7b Mon Sep 17 00:00:00 2001 From: Jaret Burkett Date: Sat, 29 Jul 2023 13:39:57 -0600 Subject: [PATCH] Bug fixes --- jobs/process/BaseSDTrainProcess.py | 5 ++++- jobs/process/TrainSliderProcess.py | 15 ++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/jobs/process/BaseSDTrainProcess.py b/jobs/process/BaseSDTrainProcess.py index e4105ff8..c34d02e9 100644 --- a/jobs/process/BaseSDTrainProcess.py +++ b/jobs/process/BaseSDTrainProcess.py @@ -282,12 +282,15 @@ class BaseSDTrainProcess(BaseTrainProcess): # prepare meta save_meta = get_meta_for_safetensors(self.meta, self.job.name) if self.network is not None: + prev_multiplier = self.network.multiplier + self.network.multiplier = 1.0 # TODO handle dreambooth, fine tuning, etc self.network.save_weights( file_path, dtype=get_torch_dtype(self.save_config.dtype), metadata=save_meta ) + self.network.multiplier = prev_multiplier else: self.sd.save( file_path, @@ -639,7 +642,7 @@ class BaseSDTrainProcess(BaseTrainProcess): ### HOOK ### loss_dict = self.hook_train_loop() - if self.train_config.optimizer.startswith('dadaptation'): + if self.train_config.optimizer.lower().startswith('dadaptation'): learning_rate = ( optimizer.param_groups[0]["d"] * optimizer.param_groups[0]["lr"] diff --git a/jobs/process/TrainSliderProcess.py b/jobs/process/TrainSliderProcess.py index c7b89a2a..2b82bc7d 100644 --- a/jobs/process/TrainSliderProcess.py +++ b/jobs/process/TrainSliderProcess.py @@ -115,12 +115,12 @@ class TrainSliderProcess(BaseSDTrainProcess): cache[prompt] = self.sd.encode_prompt(prompt) for resolution in self.slider_config.resolutions: width, height = resolution - only_erase = len(target.positive.strip()) == 0 - only_enhance = len(target.negative.strip()) == 0 + erase_negative = len(target.positive.strip()) == 0 + enhance_positive = len(target.negative.strip()) == 0 - both = not only_erase and not only_enhance + both = not erase_negative and not enhance_positive - if only_erase and only_enhance: + if erase_negative and enhance_positive: raise ValueError("target must have at least one of positive or negative or both") # for slider we need to have an enhancer, an eraser, and then # an inverse with negative weights to balance the network @@ -128,7 +128,7 @@ class TrainSliderProcess(BaseSDTrainProcess): # we only perform actions of enhancing and erasing on the negative # todo work on way to do all of this in one shot - if both or only_erase: + if both or erase_negative: prompt_pairs += [ # erase standard EncodedPromptPair( @@ -143,7 +143,7 @@ class TrainSliderProcess(BaseSDTrainProcess): weight=target.weight ), ] - if both or only_enhance: + if both or enhance_positive: prompt_pairs += [ # enhance standard, swap pos neg EncodedPromptPair( @@ -158,7 +158,7 @@ class TrainSliderProcess(BaseSDTrainProcess): weight=target.weight ), ] - if both: + if both or enhance_positive: prompt_pairs += [ # erase inverted EncodedPromptPair( @@ -173,6 +173,7 @@ class TrainSliderProcess(BaseSDTrainProcess): weight=target.weight ), ] + if both or erase_negative: prompt_pairs += [ # enhance inverted EncodedPromptPair(