From 47de3fb007f5b2b33d1c1d1ed1c52742ef913e3c Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Fri, 17 Feb 2023 14:41:02 -0500 Subject: [PATCH 1/3] correct display of 'add_difference' method when three models defined - due to typo, the add_difference method was being displayed as "['add_difference']" --- ldm/invoke/merge_diffusers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ldm/invoke/merge_diffusers.py b/ldm/invoke/merge_diffusers.py index f5da927b9a..2e817f5e0a 100644 --- a/ldm/invoke/merge_diffusers.py +++ b/ldm/invoke/merge_diffusers.py @@ -323,7 +323,7 @@ class mergeModelsForm(npyscreen.FormMultiPageAction): self.merged_model_name.value = merged_model_name if selected_model3 > 0: - self.merge_method.values = (["add_difference"],) + self.merge_method.values = ['add_difference'] self.merged_model_name.value += f"+{models[selected_model3]}" else: self.merge_method.values = self.interpolations From 4888d0d83235df1cd044e84f67ba48187308206a Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Fri, 17 Feb 2023 14:46:26 -0500 Subject: [PATCH 2/3] fix slider and interpolations - fix alpha slider to show values from 0.01 to 0.99 - fix interpolation list to show 'difference' method for 3 models, - and weighted_sum, sigmoid and inverse_sigmoid methods for 2 --- ldm/invoke/merge_diffusers.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ldm/invoke/merge_diffusers.py b/ldm/invoke/merge_diffusers.py index 2e817f5e0a..08720133c4 100644 --- a/ldm/invoke/merge_diffusers.py +++ b/ldm/invoke/merge_diffusers.py @@ -173,7 +173,6 @@ def _parse_args() -> Namespace: # ------------------------- GUI HERE ------------------------- class FloatSlider(npyscreen.Slider): - # this is supposed to adjust display precision, but doesn't def translate_value(self): stri = "%3.2f / %3.2f" % (self.value, self.out_of) l = (len(str(self.out_of))) * 2 + 4 @@ -186,7 +185,7 @@ class FloatTitleSlider(npyscreen.TitleText): class mergeModelsForm(npyscreen.FormMultiPageAction): - interpolations = ["weighted_sum", "sigmoid", "inv_sigmoid", "add_difference"] + interpolations = ["weighted_sum", "sigmoid", "inv_sigmoid"] def __init__(self, parentApp, name): self.parentApp = parentApp @@ -305,8 +304,8 @@ class mergeModelsForm(npyscreen.FormMultiPageAction): self.alpha = self.add_widget_intelligent( FloatTitleSlider, name="Weight (alpha) to assign to second and third models:", - out_of=1, - step=0.05, + out_of=1.0, + step=0.01, lowest=0, value=0.5, labelColor="CONTROL", From f129393a2eea15ccdc1f0b74f8c9a7781357e0c4 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Fri, 17 Feb 2023 15:42:06 -0500 Subject: [PATCH 3/3] document add_difference on-screen --- ldm/invoke/merge_diffusers.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ldm/invoke/merge_diffusers.py b/ldm/invoke/merge_diffusers.py index 08720133c4..1c8a2c63bb 100644 --- a/ldm/invoke/merge_diffusers.py +++ b/ldm/invoke/merge_diffusers.py @@ -79,8 +79,8 @@ def merge_diffusion_models_and_commit( merged_model_name = name for new model alpha - The interpolation parameter. Ranges from 0 to 1. It affects the ratio in which the checkpoints are merged. A 0.8 alpha would mean that the first model checkpoints would affect the final result far less than an alpha of 0.2 - interp - The interpolation method to use for the merging. Supports "sigmoid", "inv_sigmoid", "add_difference" and None. - Passing None uses the default interpolation which is weighted sum interpolation. For merging three checkpoints, only "add_difference" is supported. + interp - The interpolation method to use for the merging. Supports "weighted_average", "sigmoid", "inv_sigmoid", "add_difference" and None. + Passing None uses the default interpolation which is weighted sum interpolation. For merging three checkpoints, only "add_difference" is supported. Add_difference is A+(B-C). force - Whether to ignore mismatch in model_config.json for the current models. Defaults to False. **kwargs - the default DiffusionPipeline.get_config_dict kwargs: @@ -322,7 +322,7 @@ class mergeModelsForm(npyscreen.FormMultiPageAction): self.merged_model_name.value = merged_model_name if selected_model3 > 0: - self.merge_method.values = ['add_difference'] + self.merge_method.values = ['add_difference ( A+(B-C) )'] self.merged_model_name.value += f"+{models[selected_model3]}" else: self.merge_method.values = self.interpolations @@ -348,11 +348,14 @@ class mergeModelsForm(npyscreen.FormMultiPageAction): ] if self.model3.value[0] > 0: models.append(model_names[self.model3.value[0] - 1]) + interp='add_difference' + else: + interp=self.interpolations[self.merge_method.value[0]] args = dict( models=models, alpha=self.alpha.value, - interp=self.interpolations[self.merge_method.value[0]], + interp=interp, force=self.force.value, merged_model_name=self.merged_model_name.value, ) @@ -416,7 +419,8 @@ def run_gui(args: Namespace): mergeapp.run() args = mergeapp.merge_arguments - merge_diffusion_models_and_commit(**args) + print(f'DEBUG: {args}') + #merge_diffusion_models_and_commit(**args) print(f'>> Models merged into new model: "{args["merged_model_name"]}".')