-
Notifications
You must be signed in to change notification settings - Fork 1
/
context.txt
301 lines (222 loc) · 9.47 KB
/
context.txt
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
import math
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.components.fields as field
from custom_nodes.Derfuu_ComfyUI_ModdedNodes.components.tree import TREE_CONVERTERS
class Int2Float:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"Value": field.INT,
}
}
RETURN_TYPES = ("FLOAT",)
FUNCTION = "get_value"
CATEGORY = TREE_CONVERTERS
def get_value(self, Value):
return (float(Value),)
class CeilNode:
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"Value": field.FLOAT,
}
}
RETURN_TYPES = ("INT",)
FUNCTION = "get_value"
CATEGORY = TREE_CONVERTERS
def get_value(self, Value):
total = int(math.ceil(Value))
return (total,)
class FloorNode:
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"Value": field.FLOAT,
}
}
RETURN_TYPES = ("INT",)
FUNCTION = "get_value"
CATEGORY = TREE_CONVERTERS
def get_value(self, Value):
total = int(math.floor(Value))
return (total,)
class ABSNode:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(self):
return {
"required": {
"Value": field.FLOAT,
"negative_out": ([False, True],)
}
}
RETURN_TYPES = ("FLOAT",)
FUNCTION = "abs_val"
CATEGORY = TREE_CONVERTERS
def abs_val(self, Value, Get_negative):
if Get_negative:
return (-abs(Value),)
return (abs(Value),)
#### NEXT MODULE #######
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.components.sizes as sizes
from custom_nodes.Derfuu_ComfyUI_ModdedNodes.components.tree import TREE_FUNCTIONS
class GetLatentSize:
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"latent": ("LATENT",),
"original": ([False, True],),
}
}
RETURN_TYPES = ("INT", "INT", "TUPLE",)
CATEGORY = TREE_FUNCTIONS
FUNCTION = 'get_size'
def get_size(self, latent, original):
size = sizes.get_latent_size(latent, original)
return (size[0], size[1], size,)
class GetImageSize:
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"image": ("IMAGE",),
}
}
RETURN_TYPES = ("INT", "INT", "TUPLE", "INT", "INT", "INT", "INT", "ANY",)
RETURN_LABELS = ("Width", "Height", "Size",)
CATEGORY = TREE_FUNCTIONS
FUNCTION = 'get_size'
def get_size(self, image):
size = sizes.get_image_size(image)
w, h, s = size[0], size[1], size
return w, h, s, int(h / 64) * 64, int(w / 64) * 64, int(w / 128) * 128, int(h / 128) * 128, 1
class HalfInt:
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"num": ("INT",{"default":512}),
},
"optional": {
"num_float": ("FLOAT",{"default":None}),
}
}
RETURN_TYPES = ("INT",)
CATEGORY = TREE_FUNCTIONS
FUNCTION = 'half'
def half(self, num, num_float=None):
if num is not None:
num = num
return (round(num / 2),)
#### NEXT MODULE #######
import math
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.components.fields as field
from custom_nodes.Derfuu_ComfyUI_ModdedNodes.components.tree import TREE_COND
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.components.sizes as sizes
class ConditioningAreaScale_Ratio:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"conditioning": ('CONDITIONING',),
"modifier": field.FLOAT,
"strength_modifier": field.FLOAT,
}
}
RETURN_TYPES = ("CONDITIONING",)
FUNCTION = "resize"
CATEGORY = TREE_COND
def resize(self, conditioning, modifier, strength_modifier, min_sigma=0.0, max_sigma=99.0):
c = []
for t in conditioning:
n = [t[0], t[1].copy()]
try:
size, offset = sizes.get_conditioning_size(n[1])
except:
c.append(n)
continue
height = int(size["h"] * 8 * modifier)
width = int(size["w"] * 8 * modifier)
y = int(offset["y"] * 8 * modifier)
x = int(offset["x"] * 8 * modifier)
n[1]['area'] = (height // 8, width // 8, y // 8, x // 8)
n[1]['strength'] *= strength_modifier
n[1]['min_sigma'] = min_sigma
n[1]['max_sigma'] = max_sigma
c.append(n)
return (c,)
#### __init__.py #######
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.Nodes.Custom.Types as TypeNodes
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.Nodes.Debug.Debug as DebugNodes
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.Nodes.Functions.Converters as ConvNodes
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.Nodes.Functions.GetSizes as GetSizes
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.Nodes.Functions.Random as RandNodes
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.Nodes.Functions.Tuples as TupleNodes
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.Nodes.Math.SimpleMath as SMath
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.Nodes.Math.Trigonometry as TMath
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.Nodes.Modded.StandardInputs.Images as St_ImageNodes
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.Nodes.Modded.StandardInputs.Latents as St_LatentNodes
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.Nodes.Modded.StandardInputs.Condotionig as St_CondNodes
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.Nodes.Modded.TuplesUsed.Latents as Tu_LatentNodes
import custom_nodes.Derfuu_ComfyUI_ModdedNodes.Nodes.Modded.TuplesUsed.Conditioning as Tu_CondNodes
NODE_CLASS_MAPPINGS = {
"Float": TypeNodes.FloatNode, # Return float Value
"Integer": TypeNodes.IntegerNode, # Return int Value
"Text": TypeNodes.StringNode, # IDK where to use this... yet
"Text box": TypeNodes.MultilineStringNode, # This too
"Text with replaced weight": TypeNodes.StringReplaceWeightNode,
# NOTE: if input values are not changed, they don't print in console, same to random
"Float debug print": DebugNodes.DebugNodeFloat,
"Int debug print": DebugNodes.DebugNodeInt,
"Tuple debug print": DebugNodes.DebugNodeTuple,
"String debug print": DebugNodes.DebugNodeString,
"Random": RandNodes.RandomValue, # Return random value in range
"Tuple": TupleNodes.Tuple, # Takes floats into Tuple
"Int to tuple": TupleNodes.Int2Tuple, # Takes ints into Tuple
"Tuple to floats": TupleNodes.Tuple2Float, # Return 2 floats from Tuple
"Tuple to ints": TupleNodes.Tuple2Int, # Return 2 ints from Tuple
"Tuple swap": TupleNodes.FlipTuple, # Swap Values in tuple
"Int to float": ConvNodes.Int2Float, # Interpretation of int value as float
"Ceil": ConvNodes.CeilNode, # Rounds Value to next int
"Floor": ConvNodes.FloorNode, # Rounds Value to previous int
"Absolute value": ConvNodes.ABSNode, # Return absolute Value of input
"Get latent size": GetSizes.GetLatentSize, # Return size of latent
"Get image size": GetSizes.GetImageSize,
"Half Int": GetSizes.HalfInt,
"Sum": SMath.SumNode, # Summaries 2 values
"Subtract": SMath.SubtractNode, # Subtracts Value_B from Value_A
"Multiply": SMath.MultiplyNode, # Multiplies 2 values
"Divide": SMath.DivideNode, # Divides Value_A on Value_B
"Power": SMath.PowNode, # Returns Value_A powered by Value_B
"Square root": SMath.SquareRootNode, # Returns square root of Value
"Sinus": TMath.SinNode, # Returns sinus of Value
"Cosines": TMath.CosNode, # Returns cosines of Value
"Tangent": TMath.tgNode, # Returns tangents of Value
# STANDARD MODDED
"Latent Scale by ratio": St_LatentNodes.LatentScale_Ratio, # Scales latent proportionally on value
"Latent Scale to side": St_LatentNodes.LatentScale_Side, # Proportionally scales latent to fit in side size
"Image scale by ratio": St_ImageNodes.ImageScale_Ratio, # Scales image proportionally on value
"Image scale to side": St_ImageNodes.ImageScale_Side, # Proportionally scales image to fit in side size
"Conditioning area scale by ratio": St_CondNodes.ConditioningAreaScale_Ratio,
# TUPLE MODDED
"ConditioningSetArea with tuples": Tu_CondNodes.ConditioningSetArea, # Compose condition on field using tuples
"LatentComposite with tuples": Tu_LatentNodes.LatentComposite,
}