-
Notifications
You must be signed in to change notification settings - Fork 6
/
__init__.py
1380 lines (1131 loc) · 50 KB
/
__init__.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
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# IMAGE PassThrough (Aegis72)
# this node takes an image as an input andpasses it through. It is used for remote
# targeting with an "Anything Everywhere" node sender
import sys
import torch
import numpy as np
from PIL import Image, ImageFilter, ImageDraw, ImageFont
from PIL import Image
import subprocess
import math
p310_plus = (sys.version_info >= (3, 10))
MANIFEST = {
"name": "Aegisflow Utility Nodes",
"version": (1, 1, 0),
"author": "Aegis72",
"project": "https://majorstudio.gumroad.com",
"description": "UtilityNodes for Aegisflow comfyui workflow, based heavily on WASquatch's image batch node",
}
#Passer for SDXL
class aegisflow_multi_passxl:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
},
"optional": {
"image": ("IMAGE",),
"mask": ("MASK",),
"latent": ("LATENT",),
"model": ("MODEL",),
"vae": ("VAE",),
"clip": ("CLIP",),
"positive": ("CONDITIONING",),
"negative": ("CONDITIONING",),
"refiner model":("MODEL",),
"refiner clip":("CLIP",),
"refiner positive":("CONDITIONING",),
"refiner negative":("CONDITIONING",),
"sdxl tuple": ("SDXL_TUPLE",),
},
}
RETURN_TYPES = ("IMAGE", "MASK", "LATENT", "MODEL", "VAE", "CLIP", "CONDITIONING", "CONDITIONING", "MODEL", "CLIP", "CONDITIONING", "CONDITIONING", "SDXL_TUPLE",)
RETURN_NAMES = ("image", "mask", "latent", "model", "vae", "clip", "positive", "negative", "refiner model", "refiner clip", "refiner positive", "refiner negative", "sdxl tuple",)
FUNCTION = "af_passnodesxl"
CATEGORY = "AegisFlow/passers"
def af_passnodesxl(self, **kwargs):
output_order = ("image", "mask", "latent", "model", "vae", "clip", "positive", "negative", "refiner model", "refiner clip", "refiner positive", "refiner negative", "sdxl tuple",)
outputs = []
for key in output_order:
if key in kwargs and kwargs[key] is not None:
outputs.append(kwargs[key])
else:
# Call a specific method to create an empty placeholder for each type
empty_placeholder = self.create_empty_placeholder_for_type(key)
outputs.append(empty_placeholder)
return outputs
def create_empty_placeholder_for_type(self, type_key):
# This method should return a valid empty placeholder for the given type
# Placeholder implementation; adjust based on your system's requirements for each type
placeholder_map = {
"image": None, # Adjust to valid empty IMAGE placeholder
"mask": None, # Adjust to valid empty MASK placeholder
"latent": None, # Adjust to valid empty LATENT placeholder
"model": None, # Adjust to valid empty MODEL placeholder
"vae": None, # Adjust to valid empty VAE placeholder
"clip": None, # Adjust to valid empty CLIP placeholder
"positive": None, # Adjust to valid empty CONDITIONING placeholder
"negative": None, # Adjust to valid empty CONDITIONING placeholder
"refiner model": None, # Adjust to valid empty MODEL placeholder
"refiner clip": None, # Adjust to valid empty CLIP placeholder
"refiner positive": None, # Adjust to valid empty CONDITIONING placeholder
"refiner negative": None, # Adjust to valid empty CONDITIONING placeholder
"sdxl tuple": None, # Adjust to valid empty SDXL_TUPLE placeholder
}
return placeholder_map.get(type_key, None)
#Passer for SD 1.5
class aegisflow_multi_pass:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
},
"optional": {
"image": ("IMAGE",),
"mask": ("MASK",),
"latent": ("LATENT",),
"model": ("MODEL",),
"vae": ("VAE",),
"clip": ("CLIP",),
"positive": ("CONDITIONING",),
"negative": ("CONDITIONING",),
"sdxl tuple": ("SDXL_TUPLE",),
},
}
RETURN_TYPES = ("IMAGE", "MASK", "LATENT", "MODEL", "VAE", "CLIP", "CONDITIONING", "CONDITIONING", "SDXL_TUPLE",)
RETURN_NAMES = ("image", "mask", "latent", "model", "vae", "clip", "positive", "negative", "sdxl tuple",)
FUNCTION = "af_passnodes"
CATEGORY = "AegisFlow/passers"
def af_passnodes(self, **kwargs):
output_order = ("image", "mask", "latent", "model", "vae", "clip", "positive", "negative", "sdxl tuple",)
outputs = []
for key in output_order:
if key in kwargs and kwargs[key] is not None:
outputs.append(kwargs[key])
else:
# Call a specific method to create an empty placeholder for each type
empty_placeholder = self.create_empty_placeholder_for_type(key)
outputs.append(empty_placeholder)
return outputs
def create_empty_placeholder_for_type(self, type_key):
# This method should return a valid empty placeholder for the given type
# Placeholder implementation; adjust based on your system's requirements for each type
placeholder_map = {
"image": None, # Adjust to valid empty IMAGE placeholder
"mask": None, # Adjust to valid empty MASK placeholder
"latent": None, # Adjust to valid empty LATENT placeholder
"model": None, # Adjust to valid empty MODEL placeholder
"vae": None, # Adjust to valid empty VAE placeholder
"clip": None, # Adjust to valid empty CLIP placeholder
"positive": None, # Adjust to valid empty CONDITIONING placeholder
"negative": None, # Adjust to valid empty CONDITIONING placeholder
"sdxl tuple": None, # Adjust to valid empty SDXL_TUPLE placeholder
}
return placeholder_map[type_key]
# model PassThrough (Aegis72)
# this node takes a model as an input and passes it through. It is used for remote
# targeting with an "Anything Everywhere" node sender
class aegisflow_model_pass:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
},
"optional": {
"model": ("MODEL",),
},
}
RETURN_TYPES = ("MODEL",)
RETURN_NAMES = ("model",)
FUNCTION = "model_passer"
CATEGORY = "AegisFlow/passers"
def model_passer(self, **kwargs):
# Check if "model" key exists in kwargs and it is not None, otherwise return an empty MODEL placeholder
if "model" in kwargs and kwargs["model"] is not None:
return [kwargs["model"]]
else:
# Assuming 'empty_model_placeholder' represents a valid empty MODEL type structure
empty_model_placeholder = self.create_empty_model_placeholder()
return [empty_model_placeholder]
def create_empty_model_placeholder(self):
# Implement this method based on what constitutes a valid empty MODEL type in your system
# This might involve returning an empty list, a specific object, or another suitable placeholder
return None # Adjust this return value based on your system's requirements
# model PassThrough (Aegis72)
# this node takes a model as an input and passes it through. It is used for remote
# targeting with an "Anything Everywhere" node sender
class aegisflow_clip_pass:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
},
"optional": {
"clip": ("CLIP",),
},
}
RETURN_TYPES = ("CLIP",)
RETURN_NAMES = ("clip",)
FUNCTION = "clip_passer"
CATEGORY = "AegisFlow/passers"
def clip_passer(self, **kwargs):
# Check if "clip" key exists in kwargs and it is not None, otherwise return an empty CLIP placeholder
if "clip" in kwargs and kwargs["clip"] is not None:
return [kwargs["clip"]]
else:
# Assuming 'empty_clip_placeholder' represents a valid empty CLIP type structure
empty_clip_placeholder = self.create_empty_clip_placeholder()
return [empty_clip_placeholder]
def create_empty_clip_placeholder(self):
# Implement this method based on what constitutes a valid empty CLIP type in your system
# For example, this might return an empty list, a specific object, or another suitable placeholder
return None # Adjust this return value based on your system's requirements
# vae PassThrough (Aegis72)
# this node takes a vae as an input and passes it through. It is used for remote
# targeting with an "Anything Everywhere" node sender
class aegisflow_vae_pass:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
},
"optional": {
"vae": ("VAE",),
},
}
RETURN_TYPES = ("VAE",)
RETURN_NAMES = ("vae",)
FUNCTION = "vae_passer"
CATEGORY = "AegisFlow/passers"
def vae_passer(self, **kwargs):
# Check if "vae" key exists in kwargs and it is not None, otherwise return an empty VAE placeholder
if "vae" in kwargs and kwargs["vae"] is not None:
return [kwargs["vae"]]
else:
# Assuming 'empty_vae_placeholder' represents a valid empty VAE type structure
empty_vae_placeholder = self.create_empty_vae_placeholder()
return [empty_vae_placeholder]
def create_empty_vae_placeholder(self):
# Implement this method based on what constitutes a valid empty VAE type in your system
# For example, this might return an empty list, a specific object, or another suitable placeholder
return None # Adjust this return value based on your system's requirements
# Image PassThrough (Aegis72)
# this node takes an image as an input and passes it through. It is used for remote
# targeting with an "Anything Everywhere" node sender
class aegisflow_image_pass:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
},
"optional": {
"image": ("IMAGE",),
"mask": ("MASK",),
},
}
RETURN_TYPES = ("IMAGE", "MASK",)
RETURN_NAMES = ("image", "mask",)
FUNCTION = "image_passer"
CATEGORY = "AegisFlow/passers"
def image_passer(self, **kwargs):
# Initialize placeholders for image and mask
image_result = None
mask_result = None
# Check if "image" key exists in kwargs and it is not None, otherwise use an empty IMAGE placeholder
if "image" in kwargs and kwargs["image"] is not None:
image_result = kwargs["image"]
else:
# Assuming 'create_empty_image_placeholder' returns a valid empty IMAGE type structure
image_result = self.create_empty_image_placeholder()
# Check if "mask" key exists in kwargs and it is not None, otherwise use None as the mask result
if "mask" in kwargs and kwargs["mask"] is not None:
mask_result = kwargs["mask"]
else:
# Here we assume that if no mask is provided, we return None or an equivalent placeholder if necessary
mask_result = None # Adjust based on how you want to handle an absent mask
# Return both image and mask results
return [image_result, mask_result]
def create_empty_image_placeholder(self):
# Implement this method based on what constitutes a valid empty IMAGE type in your system
# For example, this might return an empty list, a specific object, or another suitable placeholder
return None # Adjust this return value based on your system's requirements
# LATENT PassThrough (Aegis72)
# this node takes an latent as an input and passes it through. It is used for remote
# targeting with an "Anything Everywhere" node sender
class aegisflow_latent_pass:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
},
"optional": {
"latent": ("LATENT",),
},
}
RETURN_TYPES = ("LATENT",)
RETURN_NAMES = ("latent",)
FUNCTION = "latent_passer"
CATEGORY = "AegisFlow/passers"
def latent_passer(self, **kwargs):
# Check if "latent" key exists in kwargs and it is not None, otherwise return an empty LATENT placeholder
if "latent" in kwargs and kwargs["latent"] is not None:
return [kwargs["latent"]]
else:
# Assuming 'empty_latent_placeholder' represents a valid empty LATENT type structure
empty_latent_placeholder = self.create_empty_latent_placeholder()
return [empty_latent_placeholder]
def create_empty_latent_placeholder(self):
# Implement this method based on what constitutes a valid empty LATENT type in your system
# For example, this might return an empty list, a specific object, or another suitable placeholder
return None # Adjust this return value based on your system's requirements
# MASK PassThrough (Aegis72)
# this node takes a mask as an input and passes it through. It is used for remote
# targeting with an "Anything Everywhere" node sender
class aegisflow_mask_pass:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
},
"optional": {
"mask": ("MASK",),
},
}
RETURN_TYPES = ("MASK",)
RETURN_NAMES = ("mask",)
FUNCTION = "mask_passer"
CATEGORY = "AegisFlow/passers"
def mask_passer(self, **kwargs):
# Check if "mask" key exists in kwargs and it is not None, otherwise return an empty MASK placeholder
if "mask" in kwargs and kwargs["mask"] is not None:
return [kwargs["mask"]]
else:
# Assuming 'empty_mask_placeholder' represents a valid empty MASK type structure
empty_mask_placeholder = self.create_empty_mask_placeholder()
return [empty_mask_placeholder]
def create_empty_mask_placeholder(self):
# Implement this method based on what constitutes a valid empty MASK type in your system
# This might involve returning an empty list, a specific object, or another suitable placeholder
return None # Adjust this return value based on your system's requirements
# PosNeg PassThrough (Aegis72)
# this node takes CLIP as an input and passes it through. It is used for remote
# targeting with an "Anything Everywhere" node sender
class aegisflow_posneg_pass:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
},
"optional": {
"positive": ("CONDITIONING",),
"negative": ("CONDITIONING",),
},
}
RETURN_TYPES = ("CONDITIONING","CONDITIONING",)
RETURN_NAMES = ("positive","negative",)
FUNCTION = "posneg_passer"
CATEGORY = "AegisFlow/passers"
def posneg_passer(self, **kwargs):
# Initialize placeholders for positive and negative to handle cases where they are not provided
positive_placeholder = self.create_empty_conditioning_placeholder() if "positive" not in kwargs or kwargs["positive"] is None else kwargs["positive"]
negative_placeholder = self.create_empty_conditioning_placeholder() if "negative" not in kwargs or kwargs["negative"] is None else kwargs["negative"]
return [positive_placeholder, negative_placeholder]
def create_empty_conditioning_placeholder(self):
# Implement this method based on what constitutes a valid empty CONDITIONING type in your system
# This might involve returning an empty list, a specific object, or another suitable placeholder
return None # Adjust this return value based on your system's requirements
# Conditioning PassThrough (Aegis72)
# this node takes CONDITIONING as an input and passes it through. It is used for remote
# targeting with an "Anything Everywhere" node sender
class aegisflow_cond_pass:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
},
"optional": {
"conditioning": ("CONDITIONING",),
},
}
RETURN_TYPES = ("CONDITIONING",)
RETURN_NAMES = ("conditioning",)
FUNCTION = "conditioning_passer"
CATEGORY = "AegisFlow/passers"
def conditioning_passer(self, **kwargs):
# Check if "conditioning" key exists in kwargs and it is not None, otherwise return an empty CONDITIONING placeholder
if "conditioning" in kwargs and kwargs["conditioning"] is not None:
return [kwargs["conditioning"]]
else:
# Assuming 'empty_conditioning_placeholder' represents a valid empty CONDITIONING type structure
empty_conditioning_placeholder = self.create_empty_conditioning_placeholder()
return [empty_conditioning_placeholder]
def create_empty_conditioning_placeholder(self):
# Implement this method based on what constitutes a valid empty CONDITIONING type in your system
# This might involve returning an empty list, a specific object, or another suitable placeholder
return None # Adjust this return value based on your system's requirements
# SDXL Tuple PassThrough (Aegis72)
# this node takes CONDITIONING as an input and passes it through. It is used for remote
# targeting with an "Anything Everywhere" node sender
class aegisflow_sdxltuple_pass:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
},
"optional": {
"sdxl tuple": ("SDXL_TUPLE",),
},
}
RETURN_TYPES = ("SDXL_TUPLE",)
RETURN_NAMES = ("sdxl tuple",)
FUNCTION = "tuple_passer"
CATEGORY = "AegisFlow/passers"
def tuple_passer(self, **kwargs):
# Check if "sdxl tuple" key exists in kwargs and it is not None, otherwise return an empty SDXL_TUPLE placeholder
if "sdxl tuple" in kwargs and kwargs["sdxl tuple"] is not None:
return [kwargs["sdxl tuple"]]
else:
# Assuming 'empty_sdxl_tuple_placeholder' represents a valid empty SDXL_TUPLE type structure
empty_sdxl_tuple_placeholder = self.create_empty_sdxl_tuple_placeholder()
return [empty_sdxl_tuple_placeholder]
def create_empty_sdxl_tuple_placeholder(self):
# Implement this method based on what constitutes a valid empty SDXL_TUPLE type in your system
# This might involve returning an empty list, a specific object, or another suitable placeholder
return None # Adjust this return value based on your system's requirements
# ---------------------------------------------------------------------------------------------------------------------#
# This is an input switch for Controlnet Preprocessors. Can pick an input and that image will be the one picked for the workflow.
class af_preproc_chooser:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"Input": ("INT", {"default": 1, "min": 1, "max": 9}),
},
"optional": {
"c1_passthrough": ("IMAGE",),
"c2_normal_lineart": ("IMAGE",),
"c3_anime_lineart": ("IMAGE",),
"c4_manga_lineart": ("IMAGE",),
"c5_midas_depthmap": ("IMAGE",),
"c6_color_palette": ("IMAGE",),
"c7_canny_edge": ("IMAGE",),
"c8_openpose_recognizer": ("IMAGE",),
"c9_scribble_lines": ("IMAGE",),
"c10_yourchoice1": ("IMAGE",),
"c11_yourchoice2": ("IMAGE",),
}
}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "af_preproc_chooser"
CATEGORY = "AegisFlow/passers"
def af_preproc_chooser(self, Input, to_process=None, c1_passthrough=None, c2_normal_lineart=None, c3_anime_lineart=None, c4_manga_lineart=None, c5_midas_depthmap=None, c6_color_palette=None, c7_canny_edge=None, c8_openpose_recognizer=None, c9_scribble_lines=None, c10_yourchoice1=None, c11_yourchoice2=None,):
if Input == 1:
return (c1_passthrough, )
elif Input == 2:
return (c2_normal_lineart, )
elif Input == 3:
return (c3_anime_lineart, )
elif Input == 4:
return (c4_manga_lineart, )
elif Input == 5:
return (c5_midas_depthmap, )
elif Input == 6:
return (c6_color_palette, )
elif Input == 7:
return (c7_canny_edge, )
elif Input == 8:
return (c8_openpose_recognizer, )
elif Input == 9:
return (c9_scribble_lines, )
elif Input == 10:
return (c10_yourchoice1, )
else:
return (c11_yourchoice2, )
# Developed by Ally - https://www.patreon.com/theally
# https://civitai.com/user/theally
# This node provides a simple interface to adjust the brightness/contrast of the output image prior to saving
# many users were having difficulties with both installing and keeping theAlly nodes consistent and so I am integrating the three required them into this node set.
class BrightnessContrast_theAlly:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
"""
Input Types
"""
return {
"required": {
"image": ("IMAGE",),
"mode": (["brightness", "contrast"],),
"strength": ("FLOAT", {"default": 0.5, "min": -1.0, "max": 1.0, "step": 0.01}),
"enabled": ("BOOLEAN", {"default": True},),
},
}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "apply_filter"
CATEGORY = "AegisFlow/fx"
def apply_filter(self, image, mode, strength, enabled):
# Choose a filter based on the 'mode' value
if enabled:
if mode == "brightness":
image = np.clip(image + strength, 0.0, 1.0)
elif mode == "contrast":
image = np.clip(image * strength, 0.0, 1.0)
else:
print(f"Invalid filter option: {mode}. No changes applied.")
return (image,)
# Developed by Ally - https://www.patreon.com/theally
# https://civitai.com/user/theally
# This node provides a simple interface to flip the image horizontally or vertically prior to saving
class ImageFlip_theAlly:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"image": ("IMAGE",),
"flip_type": (["horizontal", "vertical"],),
"enabled": ("BOOLEAN", {"default": True},),
},
}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "flip_image"
CATEGORY = "AegisFlow/fx"
def flip_image(self, image, flip_type, enabled):
# Convert the input image tensor to a NumPy array
image_np = 255. * image.cpu().numpy().squeeze()
if not enabled:
return (image,)
if flip_type == "horizontal":
flipped_image_np = np.flip(image_np, axis=1)
elif flip_type == "vertical":
flipped_image_np = np.flip(image_np, axis=0)
else:
print("Invalid flip_type. Must be either 'horizontal' or 'vertical'. No changes applied.")
return (image,)
# Convert the flipped NumPy array back to a tensor
flipped_image_np = flipped_image_np.astype(np.float32) / 255.0
flipped_image_tensor = torch.from_numpy(flipped_image_np).unsqueeze(0)
return (flipped_image_tensor,)
# Developed by Ally - https://www.patreon.com/theally
# https://civitai.com/user/theally
# This node provides a simple interface to apply a gaussian blur approximation (with box blur) to the image prior to output
class GaussianBlur_theAlly:
"""
This node provides a simple interface to apply Gaussian blur to the output image.
"""
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
"""
Input Types
"""
return {
"required": {
"image": ("IMAGE",),
"strength": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 200.0, "step": 0.01}),
"enabled": ("BOOLEAN", {"default": True},),
},
}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "apply_filter"
CATEGORY = "AegisFlow/fx"
def apply_filter(self, image, strength, enabled):
if not enabled:
return (image,)
i = 255. * image.cpu().numpy().squeeze()
img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8))
# Apply Gaussian blur using the strength value
blurred_img = img.filter(ImageFilter.GaussianBlur(radius=strength))
# Convert the blurred PIL Image back to a tensor
blurred_image_np = np.array(blurred_img).astype(np.float32) / 255.0
blurred_image_tensor = torch.from_numpy(blurred_image_np).unsqueeze(0)
return (blurred_image_tensor,)
class af_placeholdertuple:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {},
"optional": {}}
RETURN_TYPES = ("SDXL_TUPLE",)
FUNCTION = "placeholdertuple"
CATEGORY = "AegisFlow/placeholders"
def placeholdertuple(self,):
provided_tuple_string = "(<comfy.model_patcher.ModelPatcher object at 0x00000215AF92E410>, " \
"<comfy.sd.CLIP object at 0x0000021582576110>, " \
"[[tensor([[[-0.3921, 0.0278, -0.0675, ..., -0.4916, -0.3165, 0.0655], " \
"[-0.6300, -0.3306, 0.3012, ..., 0.2379, -0.3163, 0.4271], " \
"[ 0.2102, 0.3428, 0.3694, ..., -1.1688, -1.4279, -0.7521], " \
"..., " \
"[-0.3279, -0.1775, -1.6074, ..., -0.3802, -1.1385, -0.0408], " \
"[-0.3222, -0.1721, -1.5919, ..., -0.3691, -1.1436, -0.0270], " \
"[-0.3520, -0.0728, -1.5434, ..., -0.3932, -1.0915, -0.0713]]]), {'pooled_output': None}]], " \
"[[tensor([[[-0.3921, 0.0278, -0.0675, ..., -0.4916, -0.3165, 0.0655], " \
"[-0.6300, -0.3306, 0.3012, ..., 0.2379, -0.3163, 0.4271], " \
"[ 0.2102, 0.3428, 0.3694, ..., -1.1688, -1.4279, -0.7521], " \
"..., " \
"[-0.2891, -0.6821, -1.5167, ..., -0.6290, -1.7984, 0.3385], " \
"[-0.2864, -0.6799, -1.5096, ..., -0.6233, -1.7977, 0.3522], " \
"[-0.2866, -0.5871, -1.4560, ..., -0.6451, -1.7306, 0.2990]]]), {'pooled_output': None}]], " \
"None, None, None, None)"
result = tuple(provided_tuple_string.split(", "))
return (result,)
class af_pipe_in_15:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(s):
return {
"required": {
},
"optional": {
"image": ("IMAGE",),
"mask": ("MASK",),
"latent": ("LATENT",),
"model": ("MODEL",),
"vae": ("VAE",),
"clip": ("CLIP",),
"positive": ("CONDITIONING",),
"negative": ("CONDITIONING",),
"image_width": ("INT", {"default": 512, "min": 64, "max": 0xffffffffffffffff, "forceInput": True}),
"image_height": ("INT", {"default": 512, "min": 64, "max": 0xffffffffffffffff, "forceInput": True}),
"latent_width": ("INT", {"default": 512, "min": 64, "max": 0xffffffffffffffff, "forceInput": True}),
"latent_height": ("INT", {"default": 512, "min": 64, "max": 0xffffffffffffffff, "forceInput": True}),
},
}
RETURN_TYPES = ("PIPE_LINE", "STRING", )
RETURN_NAMES = ("pipe", "discord", )
FUNCTION = "af_pipe_in"
CATEGORY = "AegisFlow/passers"
def af_pipe_in(self, image=0, mask=0, latent=0, model=0, vae=0, clip=0, positive=0, negative=0,image_width=0, image_height=0, latent_width=0, latent_height=0):
pipe_line = (image, mask, latent, model, vae, clip, positive, negative, image_width, image_height, latent_width, latent_height)
discord = "https://discord.gg/fVQB2XAKTM"
return (pipe_line, discord, )
class af_pipe_out_15:
@classmethod
def INPUT_TYPES(s):
return {
"required": {"pipe": ("PIPE_LINE",)},
}
RETURN_TYPES = ("PIPE_LINE", "IMAGE", "MASK", "LATENT", "MODEL", "VAE", "CLIP", "CONDITIONING", "CONDITIONING", "INT", "INT", "INT", "INT", "STRING",)
RETURN_NAMES = ("pipe", "image", "mask", "latent", "model", "vae", "clip", "positive", "negative", "image_width", "image_height", "latent_width", "latent_height", "discord link",)
FUNCTION = "af_pipe_out"
CATEGORY = "AegisFlow/passers"
def af_pipe_out(self, pipe):
discord = "https://discord.gg/fVQB2XAKTM"
image, mask, latent, model, vae, clip, positive, negative, image_width, image_height, latent_width, latent_height = pipe
return (pipe, image, mask, latent, model, vae, clip, positive, negative, image_width, image_height, latent_width, latent_height, discord,)
class af_pipe_in_xl:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(s):
return {
"required": {
},
"optional": {
"image": ("IMAGE",),
"mask": ("MASK",),
"sdxl_tuple": ("SDXL_TUPLE",),
"latent": ("LATENT",),
"model": ("MODEL",),
"vae": ("VAE",),
"clip": ("CLIP",),
"positive": ("CONDITIONING",),
"negative": ("CONDITIONING",),
"refiner_model": ("MODEL",),
"refiner_vae": ("VAE",),
"refiner_clip": ("CLIP",),
"refiner_positive": ("CONDITIONING",),
"refiner_negative": ("CONDITIONING",),
"image_width": ("INT", {"default": 1024, "min": 64, "max": 0xffffffffffffffff, "forceInput": True}),
"image_height": ("INT", {"default": 1024, "min": 64, "max": 0xffffffffffffffff, "forceInput": True}),
"latent_width": ("INT", {"default": 1024, "min": 64, "max": 0xffffffffffffffff, "forceInput": True}),
"latent_height": ("INT", {"default": 1024, "min": 64, "max": 0xffffffffffffffff, "forceInput": True}),
},
}
RETURN_TYPES = ("PIPE_LINE", "STRING", )
RETURN_NAMES = ("pipe", "discord", )
FUNCTION = "af_pipe_in_xl"
CATEGORY = "AegisFlow/passers"
def af_pipe_in_xl(self, image=0, sdxl_tuple=0, mask=0, latent=0, model=0, vae=0, clip=0, positive=0, negative=0, refiner_model=0, refiner_vae=0, refiner_clip=0, refiner_positive=0, refiner_negative=0, image_width=0, image_height=0, latent_width=0, latent_height=0 ): #image_width=0, image_height=0, latent_width=0, latent_height=0
pipe_line = (image, mask, sdxl_tuple, latent, model, vae, clip, positive, negative, refiner_model, refiner_vae, refiner_clip, refiner_positive, refiner_negative, image_width, image_height, latent_width, latent_height)
discord = "https://discord.gg/fVQB2XAKTM"
return (pipe_line, discord, )
class af_pipe_out_xl:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(s):
return {
"required": {"pipe": ("PIPE_LINE",)},
}
RETURN_TYPES = ("IMAGE", "MASK", "SDXL_TUPLE", "LATENT", "MODEL", "VAE", "CLIP", "CONDITIONING", "CONDITIONING", "MODEL", "VAE", "CLIP", "CONDITIONING", "CONDITIONING", "INT", "INT", "INT", "INT", "STRING",)
RETURN_NAMES = ("image", "mask", "sdxl_tuple", "latent", "model", "vae", "clip", "positive", "negative", "refiner_model", "refiner_vae", "refiner_clip", "refiner_positive", "refiner_negative", "image_width", "image_height", "latent_width", "latent_height", "discord link",)
FUNCTION = "af_pipe_out_xl"
CATEGORY = "AegisFlow/passers"
def af_pipe_out_xl(self, pipe):
image, mask, sdxl_tuple, latent, model, vae, clip, positive, negative, refiner_model, refiner_vae, refiner_clip, refiner_positive, refiner_negative, image_width, image_height, latent_width, latent_height = pipe
discord = "https://discord.gg/fVQB2XAKTM"
return (image, mask, sdxl_tuple, latent, model, vae, clip, positive, negative, refiner_model, refiner_vae, refiner_clip, refiner_positive, refiner_negative, image_width, image_height, latent_width, latent_height, discord, )
# Vextra Nodes; These are having issues being imported due to some errors occurring on the original nodes; maintainer has not been available to fix the issue and as such we are including them here
# with full credit to the original developer diontimmer. Not all of their nodes are present, but just the ones we use. The "Add text to image has been extended to handle multiple OS default fonts."
class Flatten_Colors():
"""
This node provides a simple interface to flatten colors in the output image.
"""
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
"""
Input Types
"""
return {
"required": {
"images": ("IMAGE",),},
"optional": {
"number_of_colors": ("INT", {"default": 5, "min": 1, "max": 4000, "step": 1}),
},
}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "flatten"
CATEGORY = "AegisFlow/fx"
def tensor_to_pil(self, img):
if img is not None:
i = 255. * img.cpu().numpy().squeeze()
img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8))
return img
def flatten(self, images, number_of_colors):
#create empty tensor with the same shape as images
total_images = []
for image in images:
image = self.tensor_to_pil(image)
image = image.convert('P', palette=Image.ADAPTIVE, colors=number_of_colors)
# convert to tensor
out_image = np.array(image.convert("RGB")).astype(np.float32) / 255.0
out_image = torch.from_numpy(out_image).unsqueeze(0)
total_images.append(out_image)
total_images = torch.cat(total_images, 0)
return (total_images,)
def or_convert(im, mode):
return im if im.mode == mode else im.convert(mode)
def hue_rotate(im, deg=0):
cos_hue = math.cos(math.radians(deg))
sin_hue = math.sin(math.radians(deg))
matrix = [
.213 + cos_hue * .787 - sin_hue * .213,
.715 - cos_hue * .715 - sin_hue * .715,
.072 - cos_hue * .072 + sin_hue * .928,
0,
.213 - cos_hue * .213 + sin_hue * .143,
.715 + cos_hue * .285 + sin_hue * .140,
.072 - cos_hue * .072 - sin_hue * .283,
0,
.213 - cos_hue * .213 - sin_hue * .787,
.715 - cos_hue * .715 + sin_hue * .715,
.072 + cos_hue * .928 + sin_hue * .072,
0,
]
rotated = or_convert(im, 'RGB').convert('RGB', matrix)
return or_convert(rotated, im.mode)
class HueRotation():
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
"""
Input Types
"""
return {
"required": {
"images": ("IMAGE",),},
"optional": {
"hue_rotation": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 360.0, "step": 0.1}),
},
}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "apply_hr"
CATEGORY = "AegisFlow/fx"
def tensor_to_pil(self, img):
if img is not None:
i = 255. * img.cpu().numpy().squeeze()
img = Image.fromarray(np.clip(i, 0, 255).astype(np.uint8))
return img
def apply_hr(self, images, hue_rotation):
#create empty tensor with the same shape as images
total_images = []
for image in images:
image = self.tensor_to_pil(image)
image = hue_rotate(image, hue_rotation)
# convert to tensor
out_image = np.array(image.convert("RGB")).astype(np.float32) / 255.0
out_image = torch.from_numpy(out_image).unsqueeze(0)
total_images.append(out_image)
total_images = torch.cat(total_images, 0)
return (total_images,)
COLOR_MODES = {
'RGB': 'RGB',
'RGBA': 'RGBA',
'luminance': 'L',
'luminance_alpha': 'LA',
'cmyk': 'CMYK',
'ycbcr': 'YCbCr',
'lab': 'LAB',
'hsv': 'HSV',
'single_channel': '1',
}
class Swap_Color_Mode():
"""
This node provides a simple interface to swap color modes of the output image.
"""
def __init__(self):
pass
@classmethod