batchPromptSchedule --neg implemented

This commit is contained in:
FizzleDorf
2023-11-03 12:59:18 -04:00
parent 183b4347cc
commit 38bf3a8f5c
2 changed files with 33 additions and 21 deletions
+13 -7
View File
@@ -51,8 +51,10 @@ def interpolate_prompt_series(animation_prompts, max_frames, pre_text, app_text,
if len(sorted_prompts) - 1 == 0:
for i in range(0, len(cur_prompt_series) - 1):
current_prompt = sorted_prompts[0][1]
cur_prompt_series[i] = str(pre_text) + " " + str(current_prompt) + " " + str(app_text)
nxt_prompt_series[i] = str(pre_text) + " " + str(current_prompt) + " " + str(app_text)
#cur_prompt_series[i] = str(pre_text) + " " + str(current_prompt) + " " + str(app_text)
#nxt_prompt_series[i] = str(pre_text) + " " + str(current_prompt) + " " + str(app_text)
cur_prompt_series[i] = str(current_prompt)
nxt_prompt_series[i] = str(current_prompt)
# Initialized outside of loop for nan check
current_key = 0
@@ -89,8 +91,11 @@ def interpolate_prompt_series(animation_prompts, max_frames, pre_text, app_text,
nxt_prompt_series[f] = ''
weight_series[f] = 0.0
cur_prompt_series[f] += (str(pre_text) + " " + str(current_prompt) + " " + str(app_text))
nxt_prompt_series[f] += (str(pre_text) + " " + str(next_prompt) + " " + str(app_text))
#cur_prompt_series[f] += (str(pre_text) + " " + str(current_prompt) + " " + str(app_text))
#nxt_prompt_series[f] += (str(pre_text) + " " + str(next_prompt) + " " + str(app_text))
cur_prompt_series[f] = str(current_prompt)
nxt_prompt_series[f] = str(next_prompt)
weight_series[f] += current_weight
@@ -105,9 +110,10 @@ def interpolate_prompt_series(animation_prompts, max_frames, pre_text, app_text,
cur_prompt_series[f] = ''
nxt_prompt_series[f] = ''
weight_series[f] = current_weight
cur_prompt_series[f] += (str(pre_text) + " " + str(current_prompt) + " " + str(app_text))
nxt_prompt_series[f] += (str(pre_text) + " " + str(next_prompt) + " " + str(app_text))
#cur_prompt_series[f] += (str(pre_text) + " " + str(current_prompt) + " " + str(app_text))
#nxt_prompt_series[f] += (str(pre_text) + " " + str(next_prompt) + " " + str(app_text))
cur_prompt_series[f] = str(current_prompt)
nxt_prompt_series[f] = str(next_prompt)
if isinstance(prompt_weight_1, int):
prompt_weight_1 = tuple([prompt_weight_1] * max_frames)
+20 -14
View File
@@ -46,14 +46,14 @@ defaultValue="""0:(0),
"""
#This node parses the user's formatted prompt,
#sequences the current prompt,next prompt, and
#sequences the current prompt,next prompt, and
#conditioning strength, evaluates expressions in
#the prompts, and then returns either current,
#the prompts, and then returns either current,
#next or averaged conditioning.
class PromptSchedule:
@classmethod
def INPUT_TYPES(s):
return {"required": {"text": ("STRING", {"multiline": True, "default":defaultPrompt}),
return {"required": {"text": ("STRING", {"multiline": True, "default":defaultPrompt}),
"clip": ("CLIP", ),
"max_frames": ("INT", {"default": 120.0, "min": 1.0, "max": 9999.0, "step": 1.0}),
"current_frame": ("INT", {"default": 0.0, "min": 0.0, "max": 9999.0, "step": 1.0,})},# "forceInput": True}),},
@@ -64,7 +64,7 @@ class PromptSchedule:
"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", )
FUNCTION = "animate"
@@ -98,25 +98,31 @@ class BatchPromptSchedule:
# "forceInput": True }),
}}
RETURN_TYPES = ("CONDITIONING",)
RETURN_TYPES = ("CONDITIONING", "CONDITIONING",)
FUNCTION = "animate"
CATEGORY = "FizzNodes/BatchScheduleNodes"
def animate(self, text, max_frames, print_output, clip, pw_a, pw_b, pw_c, pw_d, pre_text='', app_text=''):
pos, neg = batch_split_weighted_subprompts(text, max_frames)
inputText = str("{" + text + "}")
inputText = re.sub(r',\s*}', '}', inputText)
# Join positive prompts into a single string
positivePrompt = "{" + ''.join(pos) + "}"
animation_prompts = json.loads(inputText.strip())
print("animation_prompts :", animation_prompts)
pos, neg = batch_split_weighted_subprompts(animation_prompts, pre_text, app_text)
positivePrompt = re.sub(r',\s*}', '}', positivePrompt)
print("pos :", pos)
print("neg :", neg)
animation_prompts = json.loads(positivePrompt.strip())
cur_prompt, nxt_prompt, weight = interpolate_prompt_series(animation_prompts, max_frames, pre_text,
pos_cur_prompt, pos_nxt_prompt, weight = interpolate_prompt_series(pos, max_frames, pre_text,
app_text, pw_a, pw_b, pw_c, pw_d, print_output)
c = BatchPoolAnimConditioning(cur_prompt, nxt_prompt, weight, clip, )
return (c,)
pc = BatchPoolAnimConditioning( pos_cur_prompt, pos_nxt_prompt, weight, clip, )
neg_cur_prompt, neg_nxt_prompt, weight = interpolate_prompt_series(neg, max_frames, pre_text,
app_text, pw_a, pw_b, pw_c, pw_d, print_output)
nc = BatchPoolAnimConditioning(neg_cur_prompt, neg_nxt_prompt, weight, clip, )
return (pc, nc, )
class BatchPromptScheduleLatentInput:
@classmethod