Merge pull request #102 from FizzleDorf/batch_fix

General fixes
This commit is contained in:
AnimAnon
2024-06-24 23:36:48 -04:00
committed by GitHub
3 changed files with 64 additions and 18 deletions
+17 -14
View File
@@ -444,9 +444,12 @@ def BatchInterpolatePromptsSDXL(animation_promptsG, animation_promptsL, clip, se
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, settings.pre_text_G, settings.app_text_G)
cur_prompt_series_L, nxt_prompt_series_L = constructPrompt(sorted_prompts_G, cur_prompt_series_G,
nxt_prompt_series_G, settings.pre_text_G, settings.app_text_G)
cur_prompt_series_G, nxt_prompt_series_G = constructPrompt(sorted_prompts_G, cur_prompt_series_G,
nxt_prompt_series_G, settings.pre_text_G,
settings.app_text_G)
cur_prompt_series_L, nxt_prompt_series_L = constructPrompt(sorted_prompts_L, cur_prompt_series_L,
nxt_prompt_series_L, settings.pre_text_L,
settings.app_text_L)
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]
@@ -487,8 +490,8 @@ def BatchInterpolatePromptsSDXL(animation_promptsG, animation_promptsL, clip, se
nxt_prompt_series_G[f] = ''
weight_series[f] = 0.0
cur_prompt_series_G[f] += (str(settings.pre_text_G) + " " + str(current_prompt_G) + " " + str(settings.app_text_G))
nxt_prompt_series_G[f] += (str(settings.pre_text_G) + " " + str(next_prompt_G) + " " + str(settings.app_text_G))
cur_prompt_series_G[f] += (str(current_prompt_G))
nxt_prompt_series_G[f] += (str(next_prompt_G))
weight_series[f] += current_weight
@@ -504,8 +507,8 @@ def BatchInterpolatePromptsSDXL(animation_promptsG, animation_promptsL, clip, se
nxt_prompt_series_G[f] = ''
weight_series[f] = current_weight
cur_prompt_series_G[f] += (str(settings.pre_text_G) + " " + str(current_prompt_G) + " " + str(settings.app_text_G))
nxt_prompt_series_G[f] += (str(settings.pre_text_G) + " " + str(next_prompt_G) + " " + str(settings.app_text_G))
cur_prompt_series_G[f] = (str(current_prompt_G))
nxt_prompt_series_G[f] = (str(next_prompt_G))
# Reset outside of loop for nan check
current_key = 0
@@ -540,8 +543,8 @@ def BatchInterpolatePromptsSDXL(animation_promptsG, animation_promptsL, clip, se
nxt_prompt_series_L[f] = ''
weight_series[f] = 0.0
cur_prompt_series_L[f] += (str(settings.pre_text_L) + " " + str(current_prompt_L) + " " + str(settings.app_text_L))
nxt_prompt_series_L[f] += (str(settings.pre_text_L) + " " + str(next_prompt_L) + " " + str(settings.app_text_L))
cur_prompt_series_L[f] += (str(current_prompt_L))
nxt_prompt_series_L[f] += (str(next_prompt_L))
weight_series[f] += current_weight
@@ -551,14 +554,13 @@ def BatchInterpolatePromptsSDXL(animation_promptsG, animation_promptsL, clip, se
# second loop to catch any nan runoff
for f in range(current_key, next_key):
next_weight = weight_step * (f - current_key)
# add the appropriate prompts and weights to their respective containers.
cur_prompt_series_L[f] = ''
nxt_prompt_series_L[f] = ''
weight_series[f] = current_weight
cur_prompt_series_L[f] += (str(settings.pre_text_L) + " " + str(current_prompt_L) + " " + str(settings.app_text_L))
nxt_prompt_series_L[f] += (str(settings.pre_text_L) + " " + str(next_prompt_L) + " " + str(settings.app_text_L))
cur_prompt_series_L[f] += (str(current_prompt_L))
nxt_prompt_series_L[f] += (str(next_prompt_L))
# Evaluate the current and next prompt's expressions
for i in range(0, settings.max_frames):
@@ -578,8 +580,9 @@ def BatchInterpolatePromptsSDXL(animation_promptsG, animation_promptsL, clip, se
if settings.print_output == True:
# Show the to/from prompts with evaluated expressions for transparency.
for i in range(0, settings.max_frames):
print("\n", "Max Frames: ", settings.max_frames, "\n", "Current Prompt G: ", cur_prompt_series_G[i],
print("\n", "Max Frames: ", settings.max_frames, "Curr Frame: ", i, "\n", "Current Prompt G: ",
cur_prompt_series_G[i],
"\n", "Current Prompt L: ", cur_prompt_series_L[i], "\n", "Next Prompt G: ", nxt_prompt_series_G[i],
"\n", "Next Prompt L : ", nxt_prompt_series_L[i], "\n"), "\n", "Current weight: ", weight_series[i]
"\n", "Next Prompt L : ", nxt_prompt_series_L[i], "\n", "Current weight: ", weight_series[i])
return current_conds, next_conds, weight_series
+41
View File
@@ -168,7 +168,48 @@ def batch_prompt_schedule_SDXL_latentInput(settings:ScheduleSettings,clip, laten
return (p, n, latents,)
def prompt_schedule_SD3(settings:ScheduleSettings,clip):
# modulus rollover when current frame exceeds max frames
settings.current_frame = settings.current_frame % settings.max_frames
# Clear whitespace and newlines from json
animation_prompts_G = process_input_text(settings.text_g)
animation_prompts_L = process_input_text(settings.text_l)
animation_prompts_T = process_input_text(settings.text_l)
# add pre_text and app_text then split the combined prompt into positive and negative prompts
posG, negG = batch_split_weighted_subprompts(animation_prompts_G, settings.pre_text_G, settings.app_text_G)
posL, negL = batch_split_weighted_subprompts(animation_prompts_L, settings.pre_text_L, settings.app_text_L)
posT, negT = batch_split_weighted_subprompts(animation_prompts_L, settings.pre_text_L, settings.app_text_L)
pc, pn, pw = BatchInterpolatePromptsSD3(posG, posL, clip, settings, )
nc, nn, nw = BatchInterpolatePromptsSD3(negG, negL, clip, settings, )
#apply composable diffusion to the current frame
p = addWeighted(pc[settings.current_frame], pn[settings.current_frame], pw[settings.current_frame])
n = addWeighted(nc[settings.current_frame], nn[settings.current_frame], nw[settings.current_frame])
return (p, n,)
def batch_prompt_schedule_SD3(settings:ScheduleSettings,clip):
# Clear whitespace and newlines from json
animation_prompts_G = process_input_text(settings.text_g)
animation_prompts_L = process_input_text(settings.text_l)
animation_prompts_T = process_input_text(settings.text_l)
# add pre_text and app_text then split the combined prompt into positive and negative prompts
posG, negG = batch_split_weighted_subprompts(animation_prompts_G, settings.pre_text_G, settings.app_text_G)
posL, negL = batch_split_weighted_subprompts(animation_prompts_L, settings.pre_text_L, settings.app_text_L)
posT, negT = batch_split_weighted_subprompts(animation_prompts_L, settings.pre_text_L, settings.app_text_L)
#pc, pn, pw = BatchInterpolatePromptsSD3(posG, posL, clip, settings,)
#nc, nn, nw = BatchInterpolatePromptsSD3(negG, negL, clip, settings,)
#p = BatchPoolAnimConditioningSD3(pc, pn, pw)
#n = BatchPoolAnimConditioningSD3(nc, nn, nw)
return (p, n,)
+6 -4
View File
@@ -345,7 +345,7 @@ class PromptScheduleEncodeSDXL:
"text_l": ("STRING", {"multiline": True, }), "clip": ("CLIP", ),
"max_frames": ("INT", {"default": 120.0, "min": 1.0, "max": 999999.0, "step": 1.0}),
"current_frame": ("INT", {"default": 0.0, "min": 0.0, "max": 999999.0, "step": 1.0}),
"print_output":("BOOLEAN", {"default": False})
"print_output":("BOOLEAN", {"default": False}),
},
"optional": {
"pre_text_G": ("STRING", {"multiline": True, "forceInput": True}),
@@ -364,7 +364,7 @@ class PromptScheduleEncodeSDXL:
CATEGORY = "FizzNodes 📅🅕🅝/ScheduleNodes"
def animate(self, clip, width, height, crop_w, crop_h, target_width, target_height, text_g, text_l, app_text_G, app_text_L, pre_text_G, pre_text_L, max_frames, current_frame, print_output, pw_a, pw_b, pw_c, pw_d):
def animate(self, clip, text_g, text_l, width, height, crop_w, crop_h, target_width, target_height, max_frames, current_frame, print_output, app_text_G = '', app_text_L = '', pre_text_G = '', pre_text_L = '', pw_a=0, pw_b=0, pw_c=0, pw_d=0):
settings = ScheduleSettings(
text_g=text_g,
pre_text_G=pre_text_G,
@@ -409,8 +409,10 @@ class BatchPromptScheduleEncodeSDXL:
"text_l": ("STRING", {"multiline": True, }), "clip": ("CLIP", ),
"max_frames": ("INT", {"default": 120.0, "min": 1.0, "max": 999999.0, "step": 1.0}),
"print_output":("BOOLEAN", {"default": False}),
},
"optional": {
"pre_text_G": ("STRING", {"multiline": True, "forceInput": True}),
"app_text_G": ("STRING", {"multiline": True, "forceInput": True}),
"pre_text_L": ("STRING", {"multiline": True, "forceInput": True}),
@@ -428,7 +430,7 @@ class BatchPromptScheduleEncodeSDXL:
CATEGORY = "FizzNodes 📅🅕🅝/BatchScheduleNodes"
def animate(self, clip, width, height, crop_w, crop_h, target_width, target_height, text_g, text_l, app_text_G, app_text_L, pre_text_G, pre_text_L, max_frames, print_output, pw_a=0, pw_b=0, pw_c=0, pw_d=0):
def animate(self, clip, text_g, text_l, width, height, crop_w, crop_h, target_width, target_height, max_frames, print_output, app_text_G = '', app_text_L = '', pre_text_G = '', pre_text_L = '', pw_a=0, pw_b=0, pw_c=0, pw_d=0):
settings = ScheduleSettings(
text_g=text_g,
pre_text_G=pre_text_G,
@@ -493,7 +495,7 @@ class BatchPromptScheduleEncodeSDXLLatentInput:
CATEGORY = "FizzNodes 📅🅕🅝/BatchScheduleNodes"
def animate(self, clip, width, height, crop_w, crop_h, target_width, target_height, text_g, text_l, app_text_G, app_text_L, pre_text_G, pre_text_L, num_latents, print_output, pw_a, pw_b, pw_c, pw_d):
def animate(self, clip, text_g, text_l, width, height, crop_w, crop_h, target_width, target_height, num_latents, print_output, app_text_G = '', app_text_L = '', pre_text_G = '', pre_text_L = '', pw_a=0, pw_b=0, pw_c=0, pw_d=0):
settings = ScheduleSettings(
text_g=text_g,
pre_text_G=pre_text_G,