Spaces:
Starting
on
L40S
Starting
on
L40S
File size: 4,173 Bytes
4450790 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
#-----------------------------------------------------------------------------------------------------------#
# CR Animation Nodes by RockOfFire and Akatsuzi https://github.com/Suzie1/CR-Animation-Nodes
# for ComfyUI https://github.com/comfyanonymous/ComfyUI
#-----------------------------------------------------------------------------------------------------------#
#-----------------------------------------------------------------------------------------------------------#
# FUNCTIONS
#-----------------------------------------------------------------------------------------------------------#
def keyframe_scheduler(schedule, schedule_alias, current_frame):
# Initialise
schedule_lines = list()
previous_params = ""
# Loop through the schedule to find lines with matching schedule_alias
for item in schedule:
alias = item[0]
if alias == schedule_alias:
schedule_lines.extend([(item)])
# Loop through the filtered lines
for i, item in enumerate(schedule_lines):
# Get alias and schedule line
alias, line = item
# Skip empty lines
if not line.strip():
print(f"[Warning] Skipped blank line at line {i}")
continue
# Get parameters from the tuples
frame_str, params = line.split(',', 1)
frame = int(frame_str)
# Strip spaces at start of params
params = params.lstrip()
# Return the params
if frame < current_frame:
previous_params = params
continue
if frame == current_frame:
previous_params = params
else:
params = previous_params
return params
# Continue using the final params after the last schedule line has been evaluated
return previous_params
def prompt_scheduler(schedule, schedule_alias, current_frame):
# Initialise
schedule_lines = list()
previous_prompt = ""
previous_keyframe = 0
#print(schedule, schedule_alias, current_frame)
# Loop through the schedule to find lines with matching schedule_alias
for item in schedule:
alias = item[0]
if alias == schedule_alias:
schedule_lines.extend([(item)])
# Loop through the filtered lines
for i, item in enumerate(schedule_lines):
# Get alias and schedule line
alias, line = item
# Get parameters from the tuples
frame_str, prompt = line.split(',', 1)
frame_str = frame_str.strip('\"')
frame = int(frame_str)
# Strip leading spaces and quotes
prompt = prompt.lstrip()
prompt = prompt.replace('"', '')
# Return the parameters
if frame < current_frame:
previous_prompt = prompt
previous_keyframe = frame
#print(f"[Debug] frame < current_frame, frame {frame}, current frame {current_frame}")
#print(f"[Debug] frame < current_frame, prompt {prompt}")
continue
if frame == current_frame:
next_prompt = prompt
next_keyframe = frame
previous_prompt = prompt
previous_keyframe = frame
#print(f"[Debug] frame = current_frame, frame {frame}, current frame {current_frame}, next keyframe {next_keyframe}")
#print(f"[Debug] frame = current_frame, prompt {prompt}")
else:
next_prompt = prompt
next_keyframe = frame
prompt = previous_prompt
#print(f"[Debug] frame > current_frame, frame {frame}, current frame {current_frame}, next keyframe {next_keyframe}")
#print(f"[Debug] frame > current_frame, next prompt {next_prompt}")
return prompt, next_prompt, previous_keyframe, next_keyframe
# Continue using the final params after the last schedule line has been evaluated
return previous_prompt, previous_prompt, previous_keyframe, previous_keyframe |