forked from FizzleDorf/ComfyUI_FizzNodes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ScheduledNodes.py
620 lines (532 loc) Β· 34.7 KB
/
ScheduledNodes.py
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
#These nodes were made using code from the Deforum extension for A1111 webui
#You can find the project here: https://github.com/deforum-art/sd-webui-deforum
import comfy
import numexpr
import torch
import numpy as np
import pandas as pd
import re
import json
from .ScheduleFuncs import (
check_is_number, interpolate_prompts_SDXL, PoolAnimConditioning,
interpolate_string, addWeighted, reverseConcatenation, split_weighted_subprompts
)
from .BatchFuncs import interpolate_prompt_series, BatchPoolAnimConditioning, BatchInterpolatePromptsSDXL, batch_split_weighted_subprompts #, BatchGLIGENConditioning
from .ValueFuncs import batch_get_inbetweens, batch_parse_key_frames, parse_key_frames, get_inbetweens, sanitize_value
#Max resolution value for Gligen area calculation.
MAX_RESOLUTION=8192
defaultPrompt=""""0" :"",
"12" :"",
"24" :"",
"36" :"",
"48" :"",
"60" :"",
"72" :"",
"84" :"",
"96" :"",
"108" :"",
"120" :""
"""
defaultValue="""0:(0),
12:(0),
24:(0),
36:(0),
48:(0),
60:(0),
72:(0),
84:(0),
96:(0),
108:(0),
120:(0)
"""
#This node parses the user's formatted prompt,
#sequences the current prompt,next prompt, and
#conditioning strength, evaluates expressions in
#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}),
"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,}),
"print_output":("BOOLEAN", {"default": False}),},# "forceInput": True}),},
"optional": {"pre_text": ("STRING", {"multiline": True,}),# "forceInput": True}),
"app_text": ("STRING", {"multiline": True,}),# "forceInput": True}),
"pw_a": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}), #"forceInput": True }),
"pw_b": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}), #"forceInput": True }),
"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", "CONDITIONING",)
RETURN_NAMES = ("POS", "NEG",)
FUNCTION = "animate"
CATEGORY = "FizzNodes π
π
π
/ScheduleNodes"
def animate(self, text, max_frames, print_output, current_frame, clip, pw_a=0, pw_b=0, pw_c=0, pw_d=0, pre_text='', app_text=''):
inputText = str("{" + text + "}")
inputText = re.sub(r',\s*}', '}', inputText)
animation_prompts = json.loads(inputText.strip())
start_frame = 0
pos, neg = batch_split_weighted_subprompts(animation_prompts, pre_text, app_text)
pos_cur_prompt, pos_nxt_prompt, weight = interpolate_prompt_series(pos, max_frames, start_frame, pre_text, app_text, pw_a,
pw_b, pw_c, pw_d, print_output)
pc = PoolAnimConditioning(pos_cur_prompt[current_frame], pos_nxt_prompt[current_frame], weight[current_frame], clip)
neg_cur_prompt, neg_nxt_prompt, weight = interpolate_prompt_series(neg, max_frames, start_frame, pre_text, app_text, pw_a,
pw_b, pw_c, pw_d, print_output)
nc = PoolAnimConditioning(neg_cur_prompt[current_frame], neg_nxt_prompt[current_frame], weight[current_frame], clip)
return (pc, nc,)
class BatchPromptSchedule:
@classmethod
def INPUT_TYPES(s):
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}),
"print_output":("BOOLEAN", {"default": False}),},
# "forceInput": True}),},
"optional": {"pre_text": ("STRING", {"multiline": True, "default": "PRE" }), # "forceInput": True}),
"app_text": ("STRING", {"multiline": True, "default": "APP" }), # "forceInput": True}),
"start_frame": ("INT", {"default": 0, "min": 0, "max": 9999, "step": 1, }),
"pw_a": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1, }),
# "forceInput": True }),
"pw_b": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1, }),
# "forceInput": True }),
"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", "CONDITIONING",)
RETURN_NAMES = ("POS", "NEG",)
FUNCTION = "animate"
CATEGORY = "FizzNodes π
π
π
/BatchScheduleNodes"
def animate(self, text, max_frames, print_output, clip, start_frame, pw_a, pw_b, pw_c, pw_d, pre_text='', app_text=''):
inputText = str("{" + text + "}")
inputText = re.sub(r',\s*}', '}', inputText)
max_frames += start_frame
animation_prompts = json.loads(inputText.strip())
pos, neg = batch_split_weighted_subprompts(animation_prompts, pre_text, app_text)
pos_cur_prompt, pos_nxt_prompt, weight = interpolate_prompt_series(pos, max_frames, start_frame, pre_text, app_text, pw_a, pw_b, pw_c, pw_d, print_output)
pc = BatchPoolAnimConditioning( pos_cur_prompt, pos_nxt_prompt, weight, clip,)
neg_cur_prompt, neg_nxt_prompt, weight = interpolate_prompt_series(neg, max_frames, start_frame, 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
def INPUT_TYPES(s):
return {"required": {"text": ("STRING", {"multiline": True, "default": defaultPrompt}),
"clip": ("CLIP",),
"num_latents": ("LATENT", ),
"print_output":("BOOLEAN", {"default": False}),},
# "forceInput": True}),},
"optional": {"pre_text": ("STRING", {"multiline": True, "default": "PRE", }), # "forceInput": True}),
"app_text": ("STRING", {"multiline": True, "default": "APP", }), # "forceInput": True}),
"start_frame": ("INT", {"default": 0.0, "min": 0, "max": 9999, "step": 1, }),
"pw_a": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1, }),
# "forceInput": True }),
"pw_b": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1, }),
# "forceInput": True }),
"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", "CONDITIONING", "LATENT", )
RETURN_NAMES = ("POS", "NEG", "INPUT_LATENTS",)
FUNCTION = "animate"
CATEGORY = "FizzNodes π
π
π
/BatchScheduleNodes"
def animate(self, text, num_latents, print_output, clip, start_frame, pw_a, pw_b, pw_c, pw_d, pre_text='', app_text=''):
max_frames = sum(tensor.size(0) for tensor in num_latents.values())
max_frames += start_frame
inputText = str("{" + text + "}")
inputText = re.sub(r',\s*}', '}', inputText)
animation_prompts = json.loads(inputText.strip())
pos, neg = batch_split_weighted_subprompts(animation_prompts, pre_text, app_text)
pos_cur_prompt, pos_nxt_prompt, weight = interpolate_prompt_series(pos, max_frames, start_frame, pre_text,
app_text, pw_a, pw_b, pw_c, pw_d,
print_output)
pc = BatchPoolAnimConditioning(pos_cur_prompt, pos_nxt_prompt, weight, clip, )
neg_cur_prompt, neg_nxt_prompt, weight = interpolate_prompt_series(neg, max_frames, start_frame, 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, num_latents,)
class StringSchedule:
@classmethod
def INPUT_TYPES(s):
return {"required": {"text": ("STRING", {"multiline": True, "default": defaultPrompt}),
"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}),},
"optional": {"pre_text": ("STRING", {"multiline": True, "default": "PRE", }), # "forceInput": True}),
"app_text": ("STRING", {"multiline": True, "default": "APP", }), # "forceInput": True}),
"pw_a": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1, }),
# "forceInput": True }),
"pw_b": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1, }),
# "forceInput": True }),
"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 = ("STRING",)
FUNCTION = "animate"
CATEGORY = "FizzNodes π
π
π
/ScheduleNodes"
def animate(self, text, max_frames, current_frame, pw_a=0, pw_b=0, pw_c=0, pw_d=0, pre_text='', app_text=''):
inputText = str("{" + text + "}")
inputText = re.sub(r',\s*}', '}', inputText)
animation_prompts = json.loads(inputText.strip())
cur_prompt = interpolate_string(animation_prompts, max_frames, current_frame, pre_text,
app_text, pw_a, pw_b, pw_c, pw_d)
#c = PoolAnimConditioning(cur_prompt, nxt_prompt, weight, clip, )
return (cur_prompt,)
class PromptScheduleSDXLRefiner:
@classmethod
def INPUT_TYPES(s):
return {"required": {
"ascore": ("FLOAT", {"default": 6.0, "min": 0.0, "max": 1000.0, "step": 0.01}),
"width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"text": ("STRING", {"multiline": True, "default":defaultPrompt}), "clip": ("CLIP", ),
}}
RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "encode"
CATEGORY = "advanced/conditioning"
def encode(self, clip, ascore, width, height, text):
tokens = clip.tokenize(text)
cond, pooled = clip.encode_from_tokens(tokens, return_pooled=True)
return ([[cond, {"pooled_output": pooled, "aesthetic_score": ascore, "width": width,"height": height}]], )
class BatchStringSchedule:
@classmethod
def INPUT_TYPES(s):
return {"required": {"text": ("STRING", {"multiline": True, "default": defaultPrompt}),
"max_frames": ("INT", {"default": 120.0, "min": 1.0, "max": 9999.0, "step": 1.0}),},
# "forceInput": True}),},
"optional": {"pre_text": ("STRING", {"multiline": True, "default": "PRE", }), # "forceInput": True}),
"app_text": ("STRING", {"multiline": True, "default": "APP", }), # "forceInput": True}),
"pw_a": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1, }),
# "forceInput": True }),
"pw_b": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1, }),
# "forceInput": True }),
"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 = ("STRING",)
FUNCTION = "animate"
CATEGORY = "FizzNodes π
π
π
/BatchScheduleNodes"
def animate(self, text, max_frames, pw_a=0, pw_b=0, pw_c=0, pw_d=0, pre_text='', app_text=''):
inputText = str("{" + text + "}")
inputText = re.sub(r',\s*}', '}', inputText)
start_frame = 0
animation_prompts = json.loads(inputText.strip())
cur_prompt_series, nxt_prompt_series, weight_series = interpolate_prompt_series(animation_prompts, max_frames, start_frame, pre_text,
app_text, pw_a, pw_b, pw_c, pw_d)
#c = PoolAnimConditioning(cur_prompt, nxt_prompt, weight, clip, )
return (cur_prompt_series,)
class BatchPromptScheduleEncodeSDXL:
@classmethod
def INPUT_TYPES(s):
return {"required": {
"width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"crop_w": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION}),
"crop_h": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION}),
"target_width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"target_height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"text_g": ("STRING", {"multiline": True, "default": "CLIP_G"}), "clip": ("CLIP", ),
"text_l": ("STRING", {"multiline": True, "default": "CLIP_L"}), "clip": ("CLIP", ),
"max_frames": ("INT", {"default": 120.0, "min": 1.0, "max": 9999.0, "step": 1.0}),
"print_output":("BOOLEAN", {"default": False}),},
"optional": {"pre_text_G": ("STRING", {"multiline": True, "default": "PRE_G"}),# "forceInput": True}),
"app_text_G": ("STRING", {"multiline": True, "default": "APP_G"}),# "forceInput": True}),
"pre_text_L": ("STRING", {"multiline": True, "default": "PRE_L"}),# "forceInput": True}),
"app_text_L": ("STRING", {"multiline": True, "default": "APP_L"}),# "forceInput": True}),
"pw_a": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}), #"forceInput": True }),
"pw_b": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}), #"forceInput": True }),
"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"
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, pw_b, pw_c, pw_d):
inputTextG = str("{" + text_g + "}")
inputTextL = str("{" + text_l + "}")
inputTextG = re.sub(r',\s*}', '}', inputTextG)
inputTextL = re.sub(r',\s*}', '}', inputTextL)
animation_promptsG = json.loads(inputTextG.strip())
animation_promptsL = json.loads(inputTextL.strip())
return (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,),)
class BatchPromptScheduleEncodeSDXLLatentInput:
@classmethod
def INPUT_TYPES(s):
return {"required": {
"width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"crop_w": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION}),
"crop_h": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION}),
"target_width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"target_height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"text_g": ("STRING", {"multiline": True, "default": "CLIP_G"}), "clip": ("CLIP", ),
"text_l": ("STRING", {"multiline": True, "default": "CLIP_L"}), "clip": ("CLIP", ),
"num_latents": ("LATENT", ),
"print_output":("BOOLEAN", {"default": False}),},
"optional": {"pre_text_G": ("STRING", {"multiline": True, "default": "PRE_G",}),# "forceInput": True}),
"app_text_G": ("STRING", {"multiline": True, "default": "APP_G",}),# "forceInput": True}),
"pre_text_L": ("STRING", {"multiline": True, "default": "PRE_L",}),# "forceInput": True}),
"app_text_L": ("STRING", {"multiline": True, "default": "APP_L",}),# "forceInput": True}),
"pw_a": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}), #"forceInput": True }),
"pw_b": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}), #"forceInput": True }),
"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",)
FUNCTION = "animate"
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):
max_frames = sum(tensor.size(0) for tensor in num_latents.values())
inputTextG = str("{" + text_g + "}")
inputTextL = str("{" + text_l + "}")
inputTextG = re.sub(r',\s*}', '}', inputTextG)
inputTextL = re.sub(r',\s*}', '}', inputTextL)
animation_promptsG = json.loads(inputTextG.strip())
animation_promptsL = json.loads(inputTextL.strip())
return (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, ), num_latents, )
class PromptScheduleEncodeSDXL:
@classmethod
def INPUT_TYPES(s):
return {"required": {
"width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"crop_w": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION}),
"crop_h": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION}),
"target_width": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"target_height": ("INT", {"default": 1024.0, "min": 0, "max": MAX_RESOLUTION}),
"text_g": ("STRING", {"multiline": True, "default": "CLIP_G"}), "clip": ("CLIP", ),
"text_l": ("STRING", {"multiline": True, "default": "CLIP_L"}), "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}),},
"optional": {"pre_text_G": ("STRING", {"multiline": True, "default": "PRE_G",}),# "forceInput": True}),
"app_text_G": ("STRING", {"multiline": True, "default": "APP_G",}),# "forceInput": True}),
"pre_text_L": ("STRING", {"multiline": True, "default": "PRE_L",}),# "forceInput": True}),
"app_text_L": ("STRING", {"multiline": True, "default": "APP_L",}),# "forceInput": True}),
"pw_a": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}), #"forceInput": True }),
"pw_b": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}), #"forceInput": True }),
"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"
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, pw_a, pw_b, pw_c, pw_d):
inputTextG = str("{" + text_g + "}")
inputTextL = str("{" + text_l + "}")
inputTextG = re.sub(r',\s*}', '}', inputTextG)
inputTextL = re.sub(r',\s*}', '}', inputTextL)
animation_promptsG = json.loads(inputTextG.strip())
animation_promptsL = json.loads(inputTextL.strip())
return (interpolate_prompts_SDXL(animation_promptsG, animation_promptsL, max_frames, current_frame, 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, ),)
# This node schedules the prompt using separate nodes as the keyframes.
# The values in the prompt are evaluated in NodeFlowEnd.
class PromptScheduleNodeFlow:
@classmethod
def INPUT_TYPES(s):
return {"required": {"text": ("STRING", {"multiline": True}),
"num_frames": ("INT", {"default": 24.0, "min": 0.0, "max": 9999.0, "step": 1.0}),},
"optional": {"in_text": ("STRING", {"multiline": False, }), # "forceInput": True}),
"max_frames": ("INT", {"default": 0.0, "min": 0.0, "max": 9999.0, "step": 1.0,})}} # "forceInput": True}),}}
RETURN_TYPES = ("INT","STRING",)
FUNCTION = "addString"
CATEGORY = "FizzNodes π
π
π
/ScheduleNodes"
def addString(self, text, in_text='', max_frames=0, num_frames=0):
if in_text:
# Remove trailing comma from in_text if it exists
in_text = in_text.rstrip(',')
new_max = num_frames + max_frames
if max_frames == 0:
# Construct a new JSON object with a single key-value pair
new_text = in_text + (', ' if in_text else '') + f'"{max_frames}": "{text}"'
else:
# Construct a new JSON object with a single key-value pair
new_text = in_text + (', ' if in_text else '') + f'"{new_max}": "{text}"'
return (new_max, new_text,)
#Last node in the Node Flow for evaluating the json produced by the above node.
class PromptScheduleNodeFlowEnd:
@classmethod
def INPUT_TYPES(s):
return {"required": {"text": ("STRING", {"multiline": False, "forceInput": True}),
"clip": ("CLIP", ),
"max_frames": ("INT", {"default": 0.0, "min": 0.0, "max": 9999.0, "step": 1.0,}),
"print_output": ("BOOLEAN", {"default": False}),
"current_frame": ("INT", {"default": 0.0, "min": 0.0, "max": 9999.0, "step": 1.0,}),}, #"forceInput": True}),},
"optional": {"pre_text": ("STRING", {"multiline": True, "default": "PRE", }),#"forceInput": True}),
"app_text": ("STRING", {"multiline": True, "default": "APP", }),#"forceInput": True}),
"pw_a": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}),# "forceInput": True}),
"pw_b": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}),# "forceInput": True}),
"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","CONDITIONING",)
RETURN_NAMES = ("POS", "NEG",)
FUNCTION = "animate"
CATEGORY = "FizzNodes π
π
π
/ScheduleNodes"
def animate(self, text, max_frames, print_output, current_frame, clip, pw_a = 0, pw_b = 0, pw_c = 0, pw_d = 0, pre_text = '', app_text = ''):
if text[-1] == ",":
text = text[:-1]
if text[0] == ",":
text = text[:0]
start_frame = 0
inputText = str("{" + text + "}")
inputText = re.sub(r',\s*}', '}', inputText)
animation_prompts = json.loads(inputText.strip())
max_frames += start_frame
pos, neg = batch_split_weighted_subprompts(animation_prompts, pre_text, app_text)
pos_cur_prompt, pos_nxt_prompt, weight = interpolate_prompt_series(pos, max_frames, start_frame, pre_text, app_text, pw_a,
pw_b, pw_c, pw_d, print_output)
pc = PoolAnimConditioning(pos_cur_prompt[current_frame], pos_nxt_prompt[current_frame], weight[current_frame],
clip, )
neg_cur_prompt, neg_nxt_prompt, weight = interpolate_prompt_series(neg, max_frames, start_frame, pre_text, app_text, pw_a,
pw_b, pw_c, pw_d, print_output)
nc = PoolAnimConditioning(neg_cur_prompt[current_frame], neg_nxt_prompt[current_frame], weight[current_frame],
clip, )
return (pc, nc,)
class BatchPromptScheduleNodeFlowEnd:
@classmethod
def INPUT_TYPES(s):
return {"required": {"text": ("STRING", {"multiline": False, "forceInput": True}),
"clip": ("CLIP", ),
"max_frames": ("INT", {"default": 0.0, "min": 0.0, "max": 9999.0, "step": 1.0,}),
"print_output": ("BOOLEAN", {"default": False}),
},
"optional": {"pre_text": ("STRING", {"multiline": False, }),#"forceInput": True}),
"app_text": ("STRING", {"multiline": False, }),#"forceInput": True}),
"pw_a": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}),# "forceInput": True}),
"pw_b": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1,}),# "forceInput": True}),
"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"
CATEGORY = "FizzNodes π
π
π
/BatchScheduleNodes"
def animate(self, text, max_frames, start_frame, print_output, clip, pw_a=0, pw_b=0, pw_c=0, pw_d=0, pre_text='', current_frame = 0,
app_text=''):
if text[-1] == ",":
text = text[:-1]
if text[0] == ",":
text = text[:0]
inputText = str("{" + text + "}")
inputText = re.sub(r',\s*}', '}', inputText)
animation_prompts = json.loads(inputText.strip())
max_frames += start_frame
pos, neg = batch_split_weighted_subprompts(animation_prompts, pre_text, app_text)
pos_cur_prompt, pos_nxt_prompt, weight = interpolate_prompt_series(pos, max_frames, start_frame, pre_text, app_text, pw_a,
pw_b, pw_c, pw_d, print_output)
pc = BatchPoolAnimConditioning(pos_cur_prompt[current_frame], pos_nxt_prompt[current_frame], weight[current_frame],
clip, )
neg_cur_prompt, neg_nxt_prompt, weight = interpolate_prompt_series(neg, max_frames, start_frame, pre_text, app_text, pw_a,
pw_b, pw_c, pw_d, print_output)
nc = BatchPoolAnimConditioning(neg_cur_prompt[current_frame], neg_nxt_prompt[current_frame], weight[current_frame],
clip, )
return (pc, nc,)
class BatchGLIGENSchedule:
@classmethod
def INPUT_TYPES(s):
return {"required": {"conditioning_to": ("CONDITIONING",),
"clip": ("CLIP",),
"gligen_textbox_model": ("GLIGEN",),
"text": ("STRING", {"multiline": True, "default":defaultPrompt}),
"width": ("INT", {"default": 64, "min": 8, "max": MAX_RESOLUTION, "step": 8}),
"height": ("INT", {"default": 64, "min": 8, "max": MAX_RESOLUTION, "step": 8}),
"x": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION, "step": 8}),
"y": ("INT", {"default": 0, "min": 0, "max": MAX_RESOLUTION, "step": 8}),
"max_frames": ("INT", {"default": 120.0, "min": 1.0, "max": 9999.0, "step": 1.0}),
"print_output":("BOOLEAN", {"default": False})},
# "forceInput": True}),},
"optional": {"pre_text": ("STRING", {"multiline": True, "default": "PRE", }), # "forceInput": True}),
"app_text": ("STRING", {"multiline": True, "default": "APP", }), # "forceInput": True}),
"pw_a": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1, }),
# "forceInput": True }),
"pw_b": ("FLOAT", {"default": 0.0, "min": -9999.0, "max": 9999.0, "step": 0.1, }),
# "forceInput": True }),
"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"
CATEGORY = "FizzNodes π
π
π
/BatchScheduleNodes"
def animate(self, conditioning_to, clip, gligen_textbox_model, text, width, height, x, y, max_frames, print_output, pw_a, pw_b, pw_c, pw_d, pre_text='', app_text=''):
inputText = str("{" + text + "}")
inputText = re.sub(r',\s*}', '}', inputText)
animation_prompts = json.loads(inputText.strip())
cur_series, nxt_series, weight_series = interpolate_prompt_series(animation_prompts, max_frames, pre_text, app_text, pw_a, pw_b, pw_c, pw_d, print_output)
out = []
for i in range(0, max_frames - 1):
# Calculate changes in x and y here, based on your logic
x_change = 8
y_change = 0
# Update x and y values
x += x_change
y += y_change
print(x)
print(y)
out.append(self.append(conditioning_to, clip, gligen_textbox_model, pre_text, width, height, x, y))
return (out,)
def append(self, conditioning_to, clip, gligen_textbox_model, text, width, height, x, y):
c = []
cond, cond_pooled = clip.encode_from_tokens(clip.tokenize(text), return_pooled=True)
for t in range(0, len(conditioning_to)):
n = [conditioning_to[t][0], conditioning_to[t][1].copy()]
position_params = [(cond_pooled, height // 8, width // 8, y // 8, x // 8)]
prev = []
if "gligen" in n[1]:
prev = n[1]['gligen'][2]
n[1]['gligen'] = ("position", gligen_textbox_model, prev + position_params)
c.append(n)
return c
#This node parses the user's test input into
#interpolated floats. Expressions can be input
#and evaluated.
class ValueSchedule:
@classmethod
def INPUT_TYPES(s):
return {"required": {"text": ("STRING", {"multiline": True, "default":defaultValue}),
"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}),
}}
RETURN_TYPES = ("FLOAT", "INT")
FUNCTION = "animate"
CATEGORY = "FizzNodes π
π
π
/ScheduleNodes"
def animate(self, text, max_frames, current_frame,):
t = get_inbetweens(parse_key_frames(text, max_frames), max_frames)
cFrame = current_frame
return (t[cFrame],int(t[cFrame]),)
class BatchValueSchedule:
@classmethod
def INPUT_TYPES(s):
return {"required": {"text": ("STRING", {"multiline": True, "default": defaultValue}),
"max_frames": ("INT", {"default": 120.0, "min": 1.0, "max": 9999.0, "step": 1.0}),
}}
RETURN_TYPES = ("FLOAT", "INT")
FUNCTION = "animate"
CATEGORY = "FizzNodes π
π
π
/BatchScheduleNodes"
def animate(self, text, max_frames, ):
t = batch_get_inbetweens(batch_parse_key_frames(text, max_frames), max_frames)
return (t, list(map(int,t)),)
class BatchValueScheduleLatentInput:
@classmethod
def INPUT_TYPES(s):
return {"required": {"text": ("STRING", {"multiline": True, "default": defaultValue}),
"num_latents": ("LATENT", ),
}}
RETURN_TYPES = ("FLOAT", "INT", "LATENT", )
FUNCTION = "animate"
CATEGORY = "FizzNodes π
π
π
/BatchScheduleNodes"
def animate(self, text, num_latents, ):
num_elements = sum(tensor.size(0) for tensor in num_latents.values())
max_frames = num_elements
t = batch_get_inbetweens(batch_parse_key_frames(text, max_frames), max_frames)
return (t, list(map(int,t)), num_latents, )