Skip to content

Commit

Permalink
Fix running wrong result when automatic replenishment of inputs and o…
Browse files Browse the repository at this point in the history
…utputs
  • Loading branch information
yolain committed Aug 22, 2024
1 parent 12002ac commit ba701d1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
32 changes: 24 additions & 8 deletions py/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .libs.utils import AlwaysEqualProxy, ByPassTypeTuple, cleanGPUUsedForce, compare_revision
from .libs.cache import remove_cache
import numpy as np
import re
import json
import torch
import comfy.utils
Expand Down Expand Up @@ -664,11 +665,12 @@ def while_loop_close(self, flow, condition, dynprompt=None, unique_id=None, **kw
node.set_input(k, parent.out(v[1]))
else:
node.set_input(k, v)

new_open = graph.lookup_node(open_node)
for i in range(MAX_FLOW_NUM):
key = "initial_value%d" % i
new_open.set_input(key, kwargs.get(key, None))
my_clone = graph.lookup_node("Recurse" )
my_clone = graph.lookup_node("Recurse")
result = map(lambda x: my_clone.out(x), range(MAX_FLOW_NUM))
return {
"result": tuple(result),
Expand All @@ -686,7 +688,7 @@ def INPUT_TYPES(cls):
"total": ("INT", {"default": 1, "min": 0, "max": 100000, "step": 1}),
},
"optional": {
"initial_value%d" % i: (AlwaysEqualProxy("*"),) for i in range(1, DEFAULT_FLOW_NUM)
"initial_value%d" % i: (AlwaysEqualProxy("*"),) for i in range(1, MAX_FLOW_NUM)
},
"hidden": {
"initial_value0": (AlwaysEqualProxy("*"),),
Expand All @@ -695,8 +697,8 @@ def INPUT_TYPES(cls):
}
}

RETURN_TYPES = ByPassTypeTuple(tuple(["FLOW_CONTROL", "INT"] + [AlwaysEqualProxy("*")] * (DEFAULT_FLOW_NUM - 1)))
RETURN_NAMES = ByPassTypeTuple(tuple(["flow", "index"] + ["value%d" % i for i in range(1, DEFAULT_FLOW_NUM)]))
RETURN_TYPES = ByPassTypeTuple(tuple(["FLOW_CONTROL", "INT"] + [AlwaysEqualProxy("*")] * (MAX_FLOW_NUM - 1)))
RETURN_NAMES = ByPassTypeTuple(tuple(["flow", "index"] + ["value%d" % i for i in range(1, MAX_FLOW_NUM)]))
FUNCTION = "for_loop_start"

CATEGORY = "EasyUse/Logic/For Loop"
Expand Down Expand Up @@ -725,13 +727,13 @@ def INPUT_TYPES(cls):
"flow": ("FLOW_CONTROL", {"rawLink": True}),
},
"optional": {
"initial_value%d" % i: (AlwaysEqualProxy("*"), {"rawLink": True}) for i in range(1, DEFAULT_FLOW_NUM)
"initial_value%d" % i: (AlwaysEqualProxy("*"), {"rawLink": True}) for i in range(1, MAX_FLOW_NUM)
},
"hidden": {"prompt": "PROMPT", "extra_pnginfo": "EXTRA_PNGINFO", "my_unique_id": "UNIQUE_ID"},
}

RETURN_TYPES = ByPassTypeTuple(tuple([AlwaysEqualProxy("*")] * (DEFAULT_FLOW_NUM - 1)))
RETURN_NAMES = ByPassTypeTuple(tuple(["value%d" % i for i in range(1, DEFAULT_FLOW_NUM)]))
RETURN_TYPES = ByPassTypeTuple(tuple([AlwaysEqualProxy("*")] * (MAX_FLOW_NUM - 1)))
RETURN_NAMES = ByPassTypeTuple(tuple(["value%d" % i for i in range(1, MAX_FLOW_NUM)]))
FUNCTION = "for_loop_end"

CATEGORY = "EasyUse/Logic/For Loop"
Expand Down Expand Up @@ -923,9 +925,23 @@ def batch(self, a, b):
if a.shape[1:] != b.shape[1:]:
b = comfy.utils.common_upscale(b.movedim(-1, 1), a.shape[2], a.shape[1], "bilinear", "center").movedim(1, -1)
return (torch.cat((a, b), 0),)
elif isinstance(a, (str, float, int, list, dict, tuple)):
elif isinstance(a, (str, float, int)):
if b is None:
return (a,)
elif isinstance(b, tuple):
return (b + (a,),)
return ((a, b),)
elif isinstance(b, (str, float, int)):
if a is None:
return (b,)
elif isinstance(a, tuple):
return (a + (b,),)
return ((b, a),)
else:
if a is None:
return (b,)
elif b is None:
return (a,)
return (a + b,)

# 转换所有类型
Expand Down
1 change: 0 additions & 1 deletion web_version/v2/assets/extensions-B7lGDrcJ.js

This file was deleted.

1 change: 1 addition & 0 deletions web_version/v2/assets/extensions-DjHfjjgA.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web_version/v2/easyuse.js

Large diffs are not rendered by default.

0 comments on commit ba701d1

Please sign in to comment.