From ca8ff073f940552bbffbd44f61efebf970c479ab Mon Sep 17 00:00:00 2001 From: FizzleDorf <1fizzledorf@gmail.com> Date: Sat, 23 Mar 2024 03:08:56 -0400 Subject: [PATCH] added neg output to SDXL schedule nodes --- BatchFuncs.py | 18 ++++++++++----- ScheduledNodes.py | 58 ++++++++++++++++++++++++++++++++++------------- 2 files changed, 54 insertions(+), 22 deletions(-) diff --git a/BatchFuncs.py b/BatchFuncs.py index b90e395..fffdd7a 100644 --- a/BatchFuncs.py +++ b/BatchFuncs.py @@ -292,13 +292,19 @@ def BatchInterpolatePromptsSDXL(animation_promptsG, animation_promptsL, max_fram # simple array for strength values weight_series = [np.nan] * max_frames - # in case there is only one keyed promt, set all prompts to that prompt - if len(sorted_prompts_G) - 1 == 0: - for i in range(0, len(cur_prompt_series_G) - 1): - current_prompt_G = sorted_prompts_G[0][1] - cur_prompt_series_G[i] = str(pre_text_G) + " " + str(current_prompt_G) + " " + str(app_text_G) - nxt_prompt_series_G[i] = str(pre_text_G) + " " + str(current_prompt_G) + " " + str(app_text_G) + def constructPrompt(sorted_prompts, cur_prompt, nxt_prompt, pre_text, app_text): + if len(sorted_prompts) - 1 == 0: + for i in range(0, len(sorted_prompts) - 1): + current_prompt = sorted_prompts[0][1] + cur_prompt[i] = str(pre_text) + " " + str(current_prompt) + " " + str(app_text) + nxt_prompt[i] = str(pre_text) + " " + str(current_prompt) + " " + str(app_text) + return cur_prompt, nxt_prompt + # in case there is only one keyed promt, set all prompts to that prompt + cur_prompt_series_G, nxt_prompt_series_G = constructPrompt(sorted_prompts_G, cur_prompt_series_G, nxt_prompt_series_G, pre_text_G, app_text_G) + cur_prompt_series_L, nxt_prompt_series_L = constructPrompt(sorted_prompts_G, cur_prompt_series_G, + nxt_prompt_series_G, pre_text_G, app_text_G) + print("Debug: ", cur_prompt_series_G, nxt_prompt_series_G) if len(sorted_prompts_L) - 1 == 0: for i in range(0, len(cur_prompt_series_L) - 1): current_prompt_L = sorted_prompts_L[0][1] diff --git a/ScheduledNodes.py b/ScheduledNodes.py index 3b7acc5..d35bdfd 100644 --- a/ScheduledNodes.py +++ b/ScheduledNodes.py @@ -281,7 +281,8 @@ class BatchPromptScheduleEncodeSDXL: "pw_c": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}), #"forceInput": True }), "pw_d": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}), #"forceInput": True }), }} - RETURN_TYPES = ("CONDITIONING",) + RETURN_TYPES = ("CONDITIONING", "CONDITIONING",) + RETURN_NAMES = ("POS", "NEG",) FUNCTION = "animate" CATEGORY = "FizzNodes 📅🅕🅝/BatchScheduleNodes" @@ -293,12 +294,19 @@ class BatchPromptScheduleEncodeSDXL: inputTextL = re.sub(r',\s*}', '}', inputTextL) animation_promptsG = json.loads(inputTextG.strip()) animation_promptsL = json.loads(inputTextL.strip()) - c, n, w = BatchInterpolatePromptsSDXL(animation_promptsG, animation_promptsL, max_frames, clip, app_text_G, - app_text_L, pre_text_G, pre_text_L, pw_a, pw_b, pw_c, pw_d, width, height, - crop_w, crop_h, target_width, target_height, print_output, ) - pc = BatchPoolAnimConditioningSDXL(c,n,w) + posG, negG = batch_split_weighted_subprompts(animation_promptsG, pre_text_G, app_text_G) + posL, negL = batch_split_weighted_subprompts(animation_promptsL, pre_text_L, app_text_L) + pc, pn, pw = BatchInterpolatePromptsSDXL(posG, posL, max_frames, clip, app_text_G, app_text_L, pre_text_G, + pre_text_L, pw_a, pw_b, pw_c, pw_d, width, height, crop_w, crop_h, + target_width, target_height, print_output, ) + p = BatchPoolAnimConditioningSDXL(pc, pn, pw) - return (pc,) + nc, nn, nw = BatchInterpolatePromptsSDXL(negG, negL, max_frames, clip, app_text_G, + app_text_L, pre_text_G, pre_text_L, pw_a, pw_b, pw_c, pw_d, width, + height, crop_w, crop_h, target_width, target_height, print_output, ) + n = BatchPoolAnimConditioningSDXL(nc, nn, nw) + + return (p,n,) class BatchPromptScheduleEncodeSDXLLatentInput: @classmethod @@ -323,7 +331,8 @@ class BatchPromptScheduleEncodeSDXLLatentInput: "pw_c": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}), #"forceInput": True }), "pw_d": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}), #"forceInput": True }), }} - RETURN_TYPES = ("CONDITIONING", "LATENT",) + RETURN_TYPES = ("CONDITIONING", "CONDITIONING", "LATENT",) + RETURN_NAMES = ("POS", "NEG",) FUNCTION = "animate" CATEGORY = "FizzNodes 📅🅕🅝/BatchScheduleNodes" @@ -336,12 +345,19 @@ class BatchPromptScheduleEncodeSDXLLatentInput: inputTextL = re.sub(r',\s*}', '}', inputTextL) animation_promptsG = json.loads(inputTextG.strip()) animation_promptsL = json.loads(inputTextL.strip()) - c, n, w = BatchInterpolatePromptsSDXL(animation_promptsG, animation_promptsL, max_frames, clip, app_text_G, - app_text_L, pre_text_G, pre_text_L, pw_a, pw_b, pw_c, pw_d, width, height, - crop_w, crop_h, target_width, target_height, print_output, ) - pc = BatchPoolAnimConditioningSDXL(c, n, w) + posG, negG = batch_split_weighted_subprompts(animation_promptsG, pre_text_G, app_text_G) + posL, negL = batch_split_weighted_subprompts(animation_promptsL, pre_text_L, app_text_L) + pc, pn, pw = BatchInterpolatePromptsSDXL(posG, posL, max_frames, clip, app_text_G, app_text_L, pre_text_G, + pre_text_L, pw_a, pw_b, pw_c, pw_d, width, height, crop_w, crop_h, + target_width, target_height, print_output, ) + p = BatchPoolAnimConditioningSDXL(pc, pn, pw) - return (pc,) + nc, nn, nw = BatchInterpolatePromptsSDXL(negG, negL, max_frames, clip, app_text_G, + app_text_L, pre_text_G, pre_text_L, pw_a, pw_b, pw_c, pw_d, width, + height, crop_w, crop_h, target_width, target_height, print_output, ) + n = BatchPoolAnimConditioningSDXL(nc, nn, nw) + + return (p,n,num_latents,) class PromptScheduleEncodeSDXL: @classmethod @@ -367,7 +383,8 @@ class PromptScheduleEncodeSDXL: "pw_c": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}), #"forceInput": True }), "pw_d": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}), #"forceInput": True }), }} - RETURN_TYPES = ("CONDITIONING",) + RETURN_TYPES = ("CONDITIONING","CONDITIONING",) + RETURN_NAMES = ("POS", "NEG",) FUNCTION = "animate" CATEGORY = "FizzNodes 📅🅕🅝/ScheduleNodes" @@ -380,9 +397,18 @@ class PromptScheduleEncodeSDXL: inputTextL = re.sub(r',\s*}', '}', inputTextL) animation_promptsG = json.loads(inputTextG.strip()) animation_promptsL = json.loads(inputTextL.strip()) - c,n,w = BatchInterpolatePromptsSDXL(animation_promptsG, animation_promptsL, max_frames, clip, app_text_G, app_text_L, pre_text_G, pre_text_L, pw_a, pw_b, pw_c, pw_d, width, height, crop_w, crop_h, target_width, target_height, print_output,) - pc = addWeighted(c[current_frame], n[current_frame], w[current_frame]) - return (pc,) + posG, negG = batch_split_weighted_subprompts(animation_promptsG, pre_text_G, app_text_G) + posL, negL = batch_split_weighted_subprompts(animation_promptsL, pre_text_L, app_text_L) + + pc,pn,pw = BatchInterpolatePromptsSDXL(posG, posL, max_frames, clip, app_text_G, app_text_L, pre_text_G, pre_text_L, pw_a, pw_b, pw_c, pw_d, width, height, crop_w, crop_h, target_width, target_height, print_output,) + p = addWeighted(pc[current_frame], pn[current_frame], pw[current_frame]) + + nc, nn, nw = BatchInterpolatePromptsSDXL(negG, negL, max_frames, clip, app_text_G, + app_text_L, pre_text_G, pre_text_L, pw_a, pw_b, pw_c, pw_d, width, + height, crop_w, crop_h, target_width, target_height, print_output, ) + n = addWeighted(nc[current_frame], nn[current_frame], nw[current_frame]) + + return (p,n,) # This node schedules the prompt using separate nodes as the keyframes. # The values in the prompt are evaluated in NodeFlowEnd.