Skip to content

Commit 6a119e6

Browse files
committed
Bump version from 0.2.6 to 0.2.7
1 parent 4097326 commit 6a119e6

3 files changed

Lines changed: 33 additions & 21 deletions

File tree

nodes/merger.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def define_schema(cls):
249249

250250
@classmethod
251251
def execute(cls, execution_mode: str, model_a: str, model_b: str,
252-
calc_mode: str, mismatch_mode: str, alpha: float, beta: float,
252+
calc_mode: str, mismatch_mode: str, alignment_mode: str, alpha: float, beta: float,
253253
gamma: float, delta: float, seed: int, output_filename: str, save_dtype: str,
254254
process_device: str, exclude_patterns: str, discard_patterns: str) -> io.NodeOutput:
255255
doc = load_documentation_from_file('merger_2_model_modes.md')
@@ -258,7 +258,7 @@ def execute(cls, execution_mode: str, model_a: str, model_b: str,
258258

259259
recipe_params = {
260260
"model_a": model_a, "model_b": model_b, "calc_mode": calc_mode,
261-
"mismatch_mode": mismatch_mode, "alignment_mode": recipe_params.get('alignment_mode', 'pad/crop'),
261+
"mismatch_mode": mismatch_mode, "alignment_mode": alignment_mode,
262262
"alpha": alpha, "beta": beta, "gamma": gamma, "delta": delta, "seed": seed,
263263
"output_filename": output_filename, "save_dtype": save_dtype,
264264
"device": process_device, "dtype": torch.float32,
@@ -304,7 +304,7 @@ def define_schema(cls):
304304

305305
@classmethod
306306
def execute(cls, execution_mode: str, model_a: str, model_b: str,
307-
calc_mode: str, mismatch_mode: str, alpha: float, beta: float,
307+
calc_mode: str, mismatch_mode: str, alignment_mode: str, alpha: float, beta: float,
308308
gamma: float, delta: float, seed: int, output_filename: str, save_dtype: str,
309309
process_device: str, exclude_patterns: str, discard_patterns: str) -> io.NodeOutput:
310310
doc = load_documentation_from_file('merger_2_model_modes.md')
@@ -313,7 +313,7 @@ def execute(cls, execution_mode: str, model_a: str, model_b: str,
313313

314314
recipe_params = {
315315
"model_a": model_a, "model_b": model_b, "calc_mode": calc_mode,
316-
"mismatch_mode": mismatch_mode, "alignment_mode": recipe_params.get('alignment_mode', 'pad/crop'),
316+
"mismatch_mode": mismatch_mode, "alignment_mode": alignment_mode,
317317
"alpha": alpha, "beta": beta, "gamma": gamma, "delta": delta, "seed": seed,
318318
"output_filename": output_filename, "save_dtype": save_dtype,
319319
"device": process_device, "dtype": torch.float32,
@@ -359,7 +359,7 @@ def define_schema(cls):
359359

360360
@classmethod
361361
def execute(cls, execution_mode: str, model_a: str, model_b: str,
362-
calc_mode: str, mismatch_mode: str, alpha: float, beta: float,
362+
calc_mode: str, mismatch_mode: str, alignment_mode: str, alpha: float, beta: float,
363363
gamma: float, delta: float, seed: int, output_filename: str, save_dtype: str,
364364
process_device: str, exclude_patterns: str, discard_patterns: str) -> io.NodeOutput:
365365
doc = load_documentation_from_file('merger_2_model_modes.md')
@@ -368,7 +368,7 @@ def execute(cls, execution_mode: str, model_a: str, model_b: str,
368368

369369
recipe_params = {
370370
"model_a": model_a, "model_b": model_b, "calc_mode": calc_mode,
371-
"mismatch_mode": mismatch_mode, "alignment_mode": recipe_params.get('alignment_mode', 'pad/crop'),
371+
"mismatch_mode": mismatch_mode, "alignment_mode": alignment_mode,
372372
"alpha": alpha, "beta": beta, "gamma": gamma, "delta": delta, "seed": seed,
373373
"output_filename": output_filename, "save_dtype": save_dtype,
374374
"device": process_device, "dtype": torch.float32,
@@ -414,7 +414,7 @@ def define_schema(cls):
414414

415415
@classmethod
416416
def execute(cls, execution_mode: str, model_a: str, model_b: str,
417-
calc_mode: str, mismatch_mode: str, alpha: float, beta: float,
417+
calc_mode: str, mismatch_mode: str, alignment_mode: str, alpha: float, beta: float,
418418
gamma: float, delta: float, seed: int, output_filename: str, save_dtype: str,
419419
process_device: str, exclude_patterns: str, discard_patterns: str) -> io.NodeOutput:
420420
doc = load_documentation_from_file('merger_2_model_modes.md')
@@ -423,7 +423,7 @@ def execute(cls, execution_mode: str, model_a: str, model_b: str,
423423

424424
recipe_params = {
425425
"model_a": model_a, "model_b": model_b, "calc_mode": calc_mode,
426-
"mismatch_mode": mismatch_mode, "alignment_mode": recipe_params.get('alignment_mode', 'pad/crop'),
426+
"mismatch_mode": mismatch_mode, "alignment_mode": alignment_mode,
427427
"alpha": alpha, "beta": beta, "gamma": gamma, "delta": delta, "seed": seed,
428428
"output_filename": output_filename, "save_dtype": save_dtype,
429429
"device": process_device, "dtype": torch.float32,
@@ -469,7 +469,7 @@ def define_schema(cls):
469469

470470
@classmethod
471471
def execute(cls, execution_mode: str, model_a: str, model_b: str,
472-
calc_mode: str, mismatch_mode: str, alpha: float, beta: float,
472+
calc_mode: str, mismatch_mode: str, alignment_mode: str, alpha: float, beta: float,
473473
gamma: float, delta: float, seed: int, output_filename: str, save_dtype: str,
474474
process_device: str, exclude_patterns: str, discard_patterns: str) -> io.NodeOutput:
475475
doc = load_documentation_from_file('merger_2_model_modes.md')
@@ -478,7 +478,7 @@ def execute(cls, execution_mode: str, model_a: str, model_b: str,
478478

479479
recipe_params = {
480480
"model_a": model_a, "model_b": model_b, "calc_mode": calc_mode,
481-
"mismatch_mode": mismatch_mode, "alignment_mode": recipe_params.get('alignment_mode', 'pad/crop'),
481+
"mismatch_mode": mismatch_mode, "alignment_mode": alignment_mode,
482482
"alpha": alpha, "beta": beta, "gamma": gamma, "delta": delta, "seed": seed,
483483
"output_filename": output_filename, "save_dtype": save_dtype,
484484
"device": process_device, "dtype": torch.float32,
@@ -527,7 +527,7 @@ def define_schema(cls):
527527

528528
@classmethod
529529
def execute(cls, execution_mode: str, model_a: str, model_b: str, model_c: str,
530-
calc_mode: str, mismatch_mode: str, alpha: float, beta: float,
530+
calc_mode: str, mismatch_mode: str, alignment_mode: str, alpha: float, beta: float,
531531
gamma: float, delta: float, seed: int, output_filename: str, save_dtype: str,
532532
process_device: str, exclude_patterns: str, discard_patterns: str) -> io.NodeOutput:
533533
doc = load_documentation_from_file('merger_3_model_modes.md')
@@ -536,7 +536,7 @@ def execute(cls, execution_mode: str, model_a: str, model_b: str, model_c: str,
536536

537537
recipe_params = {
538538
"model_a": model_a, "model_b": model_b, "model_c": model_c, "calc_mode": calc_mode,
539-
"mismatch_mode": mismatch_mode, "alignment_mode": recipe_params.get('alignment_mode', 'pad/crop'),
539+
"mismatch_mode": mismatch_mode, "alignment_mode": alignment_mode,
540540
"alpha": alpha, "beta": beta, "gamma": gamma, "delta": delta, "seed": seed,
541541
"output_filename": output_filename, "save_dtype": save_dtype,
542542
"device": process_device, "dtype": torch.float32,
@@ -583,7 +583,7 @@ def define_schema(cls):
583583

584584
@classmethod
585585
def execute(cls, execution_mode: str, model_a: str, model_b: str, model_c: str,
586-
calc_mode: str, mismatch_mode: str, alpha: float, beta: float,
586+
calc_mode: str, mismatch_mode: str, alignment_mode: str, alpha: float, beta: float,
587587
gamma: float, delta: float, seed: int, output_filename: str, save_dtype: str,
588588
process_device: str, exclude_patterns: str, discard_patterns: str) -> io.NodeOutput:
589589
doc = load_documentation_from_file('merger_3_model_modes.md')
@@ -592,7 +592,7 @@ def execute(cls, execution_mode: str, model_a: str, model_b: str, model_c: str,
592592

593593
recipe_params = {
594594
"model_a": model_a, "model_b": model_b, "model_c": model_c, "calc_mode": calc_mode,
595-
"mismatch_mode": mismatch_mode, "alignment_mode": recipe_params.get('alignment_mode', 'pad/crop'),
595+
"mismatch_mode": mismatch_mode, "alignment_mode": alignment_mode,
596596
"alpha": alpha, "beta": beta, "gamma": gamma, "delta": delta, "seed": seed,
597597
"output_filename": output_filename, "save_dtype": save_dtype,
598598
"device": process_device, "dtype": torch.float32,
@@ -639,7 +639,7 @@ def define_schema(cls):
639639

640640
@classmethod
641641
def execute(cls, execution_mode: str, model_a: str, model_b: str, model_c: str,
642-
calc_mode: str, mismatch_mode: str, alpha: float, beta: float,
642+
calc_mode: str, mismatch_mode: str, alignment_mode: str, alpha: float, beta: float,
643643
gamma: float, delta: float, seed: int, output_filename: str, save_dtype: str,
644644
process_device: str, exclude_patterns: str, discard_patterns: str) -> io.NodeOutput:
645645
doc = load_documentation_from_file('merger_3_model_modes.md')
@@ -648,7 +648,7 @@ def execute(cls, execution_mode: str, model_a: str, model_b: str, model_c: str,
648648

649649
recipe_params = {
650650
"model_a": model_a, "model_b": model_b, "model_c": model_c, "calc_mode": calc_mode,
651-
"mismatch_mode": mismatch_mode, "alignment_mode": recipe_params.get('alignment_mode', 'pad/crop'),
651+
"mismatch_mode": mismatch_mode, "alignment_mode": alignment_mode,
652652
"alpha": alpha, "beta": beta, "gamma": gamma, "delta": delta, "seed": seed,
653653
"output_filename": output_filename, "save_dtype": save_dtype,
654654
"device": process_device, "dtype": torch.float32,
@@ -695,7 +695,7 @@ def define_schema(cls):
695695

696696
@classmethod
697697
def execute(cls, execution_mode: str, model_a: str, model_b: str, model_c: str,
698-
calc_mode: str, mismatch_mode: str, alpha: float, beta: float,
698+
calc_mode: str, mismatch_mode: str, alignment_mode: str, alpha: float, beta: float,
699699
gamma: float, delta: float, seed: int, output_filename: str, save_dtype: str,
700700
process_device: str, exclude_patterns: str, discard_patterns: str) -> io.NodeOutput:
701701
doc = load_documentation_from_file('merger_3_model_modes.md')
@@ -704,7 +704,7 @@ def execute(cls, execution_mode: str, model_a: str, model_b: str, model_c: str,
704704

705705
recipe_params = {
706706
"model_a": model_a, "model_b": model_b, "model_c": model_c, "calc_mode": calc_mode,
707-
"mismatch_mode": mismatch_mode, "alignment_mode": recipe_params.get('alignment_mode', 'pad/crop'),
707+
"mismatch_mode": mismatch_mode, "alignment_mode": alignment_mode,
708708
"alpha": alpha, "beta": beta, "gamma": gamma, "delta": delta, "seed": seed,
709709
"output_filename": output_filename, "save_dtype": save_dtype,
710710
"device": process_device, "dtype": torch.float32,
@@ -751,7 +751,7 @@ def define_schema(cls):
751751

752752
@classmethod
753753
def execute(cls, execution_mode: str, model_a: str, model_b: str, model_c: str,
754-
calc_mode: str, mismatch_mode: str, alpha: float, beta: float,
754+
calc_mode: str, mismatch_mode: str, alignment_mode: str, alpha: float, beta: float,
755755
gamma: float, delta: float, seed: int, output_filename: str, save_dtype: str,
756756
process_device: str, exclude_patterns: str, discard_patterns: str) -> io.NodeOutput:
757757
doc = load_documentation_from_file('merger_3_model_modes.md')
@@ -760,7 +760,7 @@ def execute(cls, execution_mode: str, model_a: str, model_b: str, model_c: str,
760760

761761
recipe_params = {
762762
"model_a": model_a, "model_b": model_b, "model_c": model_c, "calc_mode": calc_mode,
763-
"mismatch_mode": mismatch_mode, "alignment_mode": recipe_params.get('alignment_mode', 'pad/crop'),
763+
"mismatch_mode": mismatch_mode, "alignment_mode": alignment_mode,
764764
"alpha": alpha, "beta": beta, "gamma": gamma, "delta": delta, "seed": seed,
765765
"output_filename": output_filename, "save_dtype": save_dtype,
766766
"device": process_device, "dtype": torch.float32,

nodes/merger_ops.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ def resize_by_interpolation(tensor1, tensor2):
4040
t2_f = t2_f.view(view_shape)
4141

4242
# Select mode based on dimensions
43+
if dims1 == 4:
44+
# [Out, In, H, W] -> [1, 1, Out, In, H*W] (5D)
45+
view_shape = [1, 1, tensor2.shape[0], tensor2.shape[1], tensor2.shape[2] * tensor2.shape[3]]
46+
target_size = [tensor1.shape[0], tensor1.shape[1], tensor1.shape[2] * tensor1.shape[3]]
47+
t2_f = t2_f.view(view_shape)
48+
t2_res = F.interpolate(t2_f, size=target_size, mode='trilinear', align_corners=False)
49+
return tensor1, t2_res.view(tensor1.shape).to(orig_dtype)
50+
4351
if dims1 == 1:
4452
mode = 'linear'
4553
elif dims1 == 2:
@@ -448,6 +456,7 @@ def create_recipe(self, key, **kwargs):
448456
b = LoadTensor(key, kwargs['model_b'], **loader_args_bc)
449457
c = LoadTensor(key, kwargs['model_c'], **loader_args_bc)
450458
diff = Sub(key, b, c)
459+
diff.alignment_mode = alignment_mode
451460
if kwargs['beta'] == 1: diff = Smooth(key, diff)
452461
diffm = Multiply(key, kwargs['alpha'], diff)
453462
res = Add(key, a, diffm)
@@ -474,6 +483,7 @@ def create_recipe(self, key, **kwargs):
474483
b = LoadTensor(key, kwargs['model_b'], **loader_args_bc)
475484
c = LoadTensor(key, kwargs['model_c'], **loader_args_bc)
476485
diff = TrainDiff(key, a, b, c)
486+
diff.alignment_mode = alignment_mode
477487
diffm = Multiply(key, kwargs['alpha'], diff)
478488
res = Add(key, a, diffm)
479489
res.alignment_mode = alignment_mode
@@ -523,6 +533,7 @@ def create_recipe(self, key, **kwargs):
523533
b = LoadTensor(key, kwargs['model_b'], **loader_args_bc)
524534
c = LoadTensor(key, kwargs['model_c'], **loader_args_bc)
525535
extracted = ExtractOp(key, kwargs['alpha'], kwargs['beta'], kwargs['gamma'] * 15, a, b, c)
536+
extracted.alignment_mode = alignment_mode
526537
multiplied = Multiply(key, kwargs['delta'], extracted)
527538
res = Add(key, a, multiplied)
528539
res.alignment_mode = alignment_mode
@@ -548,6 +559,7 @@ def create_recipe(self, key, **kwargs):
548559
b = LoadTensor(key, kwargs['model_b'], **loader_args_bc)
549560
c = LoadTensor(key, kwargs['model_c'], **loader_args_bc)
550561
extracted = Similarities(key, kwargs['alpha'], 1, kwargs['gamma'] * 15, b, c)
562+
extracted.alignment_mode = alignment_mode
551563
multiplied = Multiply(key, kwargs['beta'], extracted)
552564
res = Add(key, a, multiplied)
553565
res.alignment_mode = alignment_mode

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "ComfyUI-ModelUtils"
33
description = "[WIP]Custom nodes for handling, inspecting, modifying and creating various model files."
4-
version = "0.2.6"
4+
version = "0.2.7"
55
license = { file = "LICENSE" }
66

77
[project.urls]

0 commit comments

Comments
 (0)