File size: 10,232 Bytes
e5b8fac |
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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
import comfy
import numexpr
import torch
import numpy as np
import pandas as pd
import re
import json
from .ScheduleFuncs import *
from .BatchFuncs import *
def prompt_schedule(settings:ScheduleSettings,clip):
settings.start_frame = 0
# 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 = process_input_text(settings.text_g)
# add pre_text and app_text then split the combined prompt into positive and negative prompts
pos, neg = batch_split_weighted_subprompts(animation_prompts, settings.pre_text_G, settings.app_text_G)
# Interpolate the positive prompt weights over frames
pos_cur_prompt, pos_nxt_prompt, weight = interpolate_prompt_seriesA(pos, settings)
neg_cur_prompt, neg_nxt_prompt, weight = interpolate_prompt_seriesA(neg, settings)
# Apply composable diffusion across the batch
p = PoolAnimConditioning(pos_cur_prompt[settings.current_frame], pos_nxt_prompt[settings.current_frame],
weight[settings.current_frame], clip)
n = PoolAnimConditioning(neg_cur_prompt[settings.current_frame], neg_nxt_prompt[settings.current_frame],
weight[settings.current_frame], clip)
# return the positive and negative conditioning at the current frame
return (p, n,)
def batch_prompt_schedule(settings:ScheduleSettings,clip):
# Clear whitespace and newlines from json
animation_prompts = process_input_text(settings.text_g)
# Add pre_text and app_text then split the combined prompt into positive and negative prompts
pos, neg = batch_split_weighted_subprompts(animation_prompts, settings.pre_text_G, settings.app_text_G)
# Interpolate the positive prompt weights over frames
pos_cur_prompt, pos_nxt_prompt, weight = interpolate_prompt_seriesA(pos, settings)
neg_cur_prompt, neg_nxt_prompt, weight = interpolate_prompt_seriesA(neg, settings)
# Apply composable diffusion across the batch
p = BatchPoolAnimConditioning(pos_cur_prompt, pos_nxt_prompt, weight, clip, settings)
n = BatchPoolAnimConditioning(neg_cur_prompt, neg_nxt_prompt, weight, clip, settings)
# return positive and negative conditioning as well as the current and next prompts for each
return (p, n,)
def batch_prompt_schedule_latentInput(settings:ScheduleSettings,clip, latents):
# Clear whitespace and newlines from json
animation_prompts = process_input_text(settings.text_g)
# Add pre_text and app_text then split the combined prompt into positive and negative prompts
pos, neg = batch_split_weighted_subprompts(animation_prompts, settings.pre_text_G, settings.app_text_G)
# Interpolate the positive prompt weights over frames
pos_cur_prompt, pos_nxt_prompt, weight = interpolate_prompt_seriesA(pos, settings)
# Apply composable diffusion across the batch
p = BatchPoolAnimConditioning(pos_cur_prompt, pos_nxt_prompt, weight, clip, settings)
# Interpolate the negative prompt weights over frames
neg_cur_prompt, neg_nxt_prompt, weight = interpolate_prompt_seriesA(neg, settings)
# Apply composable diffusion across the batch
n = BatchPoolAnimConditioning(neg_cur_prompt, neg_nxt_prompt, weight, clip, settings)
return (p, n, latents,)
def string_schedule(settings:ScheduleSettings):
settings.start_frame = 0
# 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 = process_input_text(settings.text_g)
# add pre_text and app_text then split the combined prompt into positive and negative prompts
pos, neg = batch_split_weighted_subprompts(animation_prompts, settings.pre_text_G, settings.app_text_G)
# Interpolate the positive prompt weights over frames
pos_cur_prompt, pos_nxt_prompt, weight = interpolate_prompt_seriesA(pos, settings)
# Interpolate the negative prompt weights over frames
neg_cur_prompt, neg_nxt_prompt, weight = interpolate_prompt_seriesA(neg, settings)
return(pos_cur_prompt[settings.current_frame], neg_cur_prompt[settings.current_frame], )
def batch_string_schedule(settings:ScheduleSettings):
settings.start_frame = 0
# Clear whitespace and newlines from json
animation_prompts = process_input_text(settings.text_g)
# add pre_text and app_text then split the combined prompt into positive and negative prompts
pos, neg = batch_split_weighted_subprompts(animation_prompts, settings.pre_text_G, settings.app_text_G)
# Interpolate the positive prompt weights over frames
pos_cur_prompt, pos_nxt_prompt, weight = interpolate_prompt_seriesA(pos, settings)
# Interpolate the negative prompt weights over frames
neg_cur_prompt, neg_nxt_prompt, weight = interpolate_prompt_seriesA(neg, settings)
return (pos_cur_prompt, neg_cur_prompt,)
def prompt_schedule_SDXL(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)
# 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)
pc, pn, pw = BatchInterpolatePromptsSDXL(posG, posL, clip, settings, )
nc, nn, nw = BatchInterpolatePromptsSDXL(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_SDXL(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)
# 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)
pc, pn, pw = BatchInterpolatePromptsSDXL(posG, posL, clip, settings,)
nc, nn, nw = BatchInterpolatePromptsSDXL(negG, negL, clip, settings,)
p = BatchPoolAnimConditioningSDXL(pc, pn, pw, clip, settings)
n = BatchPoolAnimConditioningSDXL(nc, nn, nw, clip, settings)
return (p, n,)
def batch_prompt_schedule_SDXL_latentInput(settings:ScheduleSettings,clip, latents):
settings.start_frame = 0
# Clear whitespace and newlines from json
animation_prompts_G = process_input_text(settings.text_g)
animation_prompts_L = 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)
pc, pn, pw = BatchInterpolatePromptsSDXL(posG, posL, clip, settings)
nc, nn, nw = BatchInterpolatePromptsSDXL(negG, negL, clip, settings)
p = BatchPoolAnimConditioningSDXL(pc, pn, pw, clip, settings)
n = BatchPoolAnimConditioningSDXL(nc, nn, nw, clip, settings)
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,)
|