From f49ff40f8f2b47fb5bdc015c1c16f4b4054c9a19 Mon Sep 17 00:00:00 2001 From: Johannes Stelzer Date: Mon, 20 Feb 2023 11:44:50 +0100 Subject: [PATCH] helper functions for crossfeeding --- latent_blending.py | 33 +++++++++++++++++++++++++++++++++ parameters.md | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/latent_blending.py b/latent_blending.py index 4352212..501239b 100644 --- a/latent_blending.py +++ b/latent_blending.py @@ -164,6 +164,39 @@ class LatentBlending(): self.guidance_scale = guidance_scale_effective self.sdh.guidance_scale = guidance_scale_effective + + def set_branch1_crossfeed(self, crossfeed_power, crossfeed_range, crossfeed_decay): + r""" + Sets the crossfeed parameters for the first branch to the last branch. + Args: + crossfeed_power: float [0,1] + Controls the level of cross-feeding between the first and last image branch. + crossfeed_range: float [0,1] + Sets the duration of active crossfeed during development. + crossfeed_decay: float [0,1] + Sets decay for branch1_crossfeed_power. Lower values make the decay stronger across the range. + """ + self.branch1_crossfeed_power = np.clip(crossfeed_power, 0, 1) + self.branch1_crossfeed_range = np.clip(crossfeed_range, 0, 1) + self.branch1_crossfeed_decay = np.clip(crossfeed_decay, 0, 1) + + + def set_parental_crossfeed(self, crossfeed_power, crossfeed_range, crossfeed_decay): + r""" + Sets the crossfeed parameters for all transition images (within the first and last branch). + Args: + crossfeed_power: float [0,1] + Controls the level of cross-feeding from the parental branches + crossfeed_range: float [0,1] + Sets the duration of active crossfeed during development. + crossfeed_decay: float [0,1] + Sets decay for branch1_crossfeed_power. Lower values make the decay stronger across the range. + """ + self.parental_crossfeed_power = np.clip(crossfeed_power, 0, 1) + self.parental_crossfeed_range = np.clip(crossfeed_range, 0, 1) + self.parental_crossfeed_power_decay = np.clip(crossfeed_decay, 0, 1) + + def set_prompt1(self, prompt: str): r""" Sets the first prompt (for the first keyframe) including text embeddings. diff --git a/parameters.md b/parameters.md index 95e231e..60ca01c 100644 --- a/parameters.md +++ b/parameters.md @@ -15,7 +15,7 @@ - The value x ranges from [0,1], and the crossfeeding is deactivated after x*num_inference_steps steps ## branch1_crossfeed_decay -- Sets decay for branch1_crossfeed_power. Lower values make the decay stronger across the range +- Sets decay for branch1_crossfeed_power. Lower values make the decay stronger across the range. - The value x ranges from [0,1], and the branch1_crossfeed_power is decreased until the end of the branch1_crossfeed_range to a value of x*branch1_crossfeed_power ## parental_crossfeed_power