Trung0246 / ComfyUI-0246

Random nodes for ComfyUI
MIT License
93 stars 10 forks source link

[WORKFLOW] XY Grid Example #15

Open bananasss00 opened 6 months ago

bananasss00 commented 6 months ago

xy_grid xy_grid.json

With your nodes you can make grids of any complexity, though not as convenient. But thanks anyway :)

Trung0246 commented 6 months ago

Actually with the recent Script node you can create multiple batches then execute using cycle mode from the ScriptPlan which will iterate through every possible permutation ;)

Even better Hub node can directly create batch without going through JunctionBatch.

bananasss00 commented 6 months ago

I haven't quite figured out these nodes yet, I'll be experimenting with them. There is not much information on how they work yet

Trung0246 commented 6 months ago

workflow_grid

I also patched the code the bit, so make sure to update, otherwise the general workflow should works.

Currently Hub only support batch primitive data, not COMBO. I may plan to add BATCH support for COMBO probably.

Forgot to mentions the workflow is in the png.

Trung0246 commented 6 months ago

Just pushed another update to support COMBO. I guess I should stop "small fixes" for now.

JorgeR81 commented 3 months ago

@Trung0246 can you update your workflow here ?

When in run the queue, I've got this error:

Error occurred when executing 0246.Script:

list index out of range

File "C:\Cui\cu_121_2\ComfyUI_windows_portable\ComfyUI\execution.py", line 141, in recursive_execute
input_data_all = get_input_data(inputs, class_def, unique_id, outputs, prompt, extra_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Cui\cu_121_2\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-0246\utils.py", line 381, in new_func
res_value = old_func(*final_args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Cui\cu_121_2\ComfyUI_windows_portable\ComfyUI\execution.py", line 26, in get_input_data
obj = outputs[input_unique_id][output_index]
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
Trung0246 commented 3 months ago

Hm that looks weird. Maybe I could a look when I have time.

DrJKL commented 3 months ago

image

I think these are the new connections.

Trung0246 commented 3 months ago

Oh I thought that we are talking about the first one. Maybe Jorge can try again. Yeah the one JLK mentions is the correct connection.

JorgeR81 commented 3 months ago

Yes, it's working !

Just noticed, in the workflow image, that the [ script_excet_data ] output used to be in another node ...

old_wf

JorgeR81 commented 3 months ago

I've made a [ sampler x scheduler ] version of this workflow, with different hubs.

But when I load the workflow, the 2 hubs that use __BATCH_COMBO__ are allways disconnected.

Is this a bug, or am I doing something wrong ?

sampler_scheduler

DrJKL commented 3 months ago

I can replicate the noodles being detached on load. Same from

Trung0246 commented 3 months ago

Oh it just a minor bug as it's related to how I implemented input/output expand stuff. It kinda annoying but hopefully easy to fix when I have time.

JorgeR81 commented 3 months ago

I was trying to make a version of the first workflow, with the Junction Batch nodes.

But I can't make new connections.

And if I unplug the old ones, they stop working !

For example, if I unplug this Junction Bach node from the Merge node, when I plug it again, the "COMBO" designation is gone, from the output and input connections. There is only an [ * ] and the workflow is broken.

But if I connect from the Junction Bach node above, which still has the "COMBO" designation in the output, the connection is successful ( see bottom image ).

Is this a bug, or is there another way to make new connections ?

test

test2

JorgeR81 commented 3 months ago

Using the CastReroute node, I'm able to create new output connections for "FLOAT" and "INT", in the Junction Bach node

Once I have the correct designation on the Junction Bach output, I can delete the CastReroute node.

But there is no option for "COMBO" in the CastReroute node ...

test3

Trung0246 commented 3 months ago

The problem is COMBO did not actually exist internally but instead it is an array of string which decay to just a single STRING when processed. So that a weird quirk I'm unsure about when I implementing CastReroute and Hub, therefore I decided to leave it as it is. The problem is we wants to retain COMBO type (which is the case for Hub) to make it possible to connect to nodes that are actually expecting that type. Your best bet is convert COMBO to STRING before actually connecting to JunctionBatch then recast to * when connect to node that expecting COMBO.

All of this are why CastReroute exist in the first place, which is a tradeoff for being absurdly flexible.

JorgeR81 commented 3 months ago

I'm able to change the output to STRING in the Junction Batch nodes. But it does not work with STRING or [ * ]. It only works with COMBO.

I'm only able to use the 8 nodes that @bananasss00 connected in his workflow, which already have the output connections as COMBO. If I copy and paste these nodes or if I save them as a template, the connections are changed back to [ * ].

If there was a special trick to make this connection, he would probably have explained how to do this, when he shared his workflow, in the first post.

Perhaps there is not a trick, and this was working correctly when he made the workflow. I noticed that in his workflow image, the Merge nodes had an option called "same". This option does not exist anymore. Maybe this was broken when this option was changed ?

ban

Trung0246 commented 3 months ago

I guess at one time I added COMBO to CastReroute but later deleted it since it's pointless. Probably have to take a look on how to handle this. Also weird I remembered wildcard * works for anything including COMBO.

Also copy-paste is also iffy so that another bug to the list but honestly I think reverting to * is expected behavior since the type resolving mechanism doesn't have a concrete input/output type to rely on.

Yeah same no longer exist. It is now flat probably. This is irrelevant btw.

JorgeR81 commented 3 months ago

I did find a trick to do this !

We can use other nodes with COMBO inputs instead of CastReroute. When a Primitive it's connected to them, the connection output is turned in to COMBO. And the same happens if we connect the JunctionBatch node, instead.

cp

You could try to add COMBO to CastReroute again, because it's a more elegant solution. There is a single unconnected CastReroute node ( set to INT ), the worflow from @bananasss00, but I guess he used this for all the connections types.

But, if you can make the [ * ] connections work correctly, it would be even better, because then we could copy / paste your nodes, and use them as templates.

Now, if the connection is [ * ], it gives this error:

Error occurred when executing 0246.JunctionBatch:

Type "*" of output "*:0" does not available in junction.

File "C:\Cui\cu_121_2\ComfyUI_windows_portable\ComfyUI\execution.py", line 151, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Cui\cu_121_2\ComfyUI_windows_portable\ComfyUI\execution.py", line 81, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Cui\cu_121_2\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-0246\utils.py", line 381, in new_func
res_value = old_func(*final_args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Cui\cu_121_2\ComfyUI_windows_portable\ComfyUI\execution.py", line 65, in map_node_over_list
results.append(getattr(obj, func)(**input_data_all))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Cui\cu_121_2\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-0246\nodes.py", line 1296, in execute
return junction_impl(self, _id, _prompt, _workflow, gather_junction_impl(_junc_in, _id), _offset, _in_mode = True, _out_mode = True, _offset_mode = True, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Cui\cu_121_2\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-0246\nodes.py", line 220, in junction_impl
raise Exception(f"Type \"{elem['type']}\" of output \"{elem['name']}\" does not available in junction.")
JorgeR81 commented 3 months ago

I also noticed that in some cases the * seems to be able to replace COMBO, successfully.

Here I'm connecting a Merge node and Anything Everywhere? node.

The connection is named *, and the AE? node is able to broadcast the data, to the Highway Bach node.

hb