Grids & combinatorial outputs#759
Closed
space-nuko wants to merge 12 commits into
Closed
Conversation
This reverts commit df0c752.
Closed
Contributor
|
Comfy's general preference for nodes like this is to release it as a custom node unless there's a clear reason to put it in core. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a grids feature similar to XYZ-plots in webui, supporting an arbitrary number of axes
NOTE: It's still extremely WIP and assumes a uniform batch size, nodes that change the batch size partway or rebatch latents will almost certainly break it. Also I need to make sure the new
PrimitiveNodewidgets don't break existing workflowsTest workflow
Sets up a 5-axis grid from various parameters
https://files.catbox.moe/tym26a.json
Features added
The executor now supports combinatorial inputs. This means it will generate a new prompt for every combination of one or more list of input values for each node, and pass each one of those prompts further down the graph combinatorially as well
All nodes now show batch progress in addition to individual progress if they're being mapped over combinatorially
PrimitiveNodegets new options for defining grid axis options,listfor a comma separated list andrangefor numeric ranges (in supported input types). Each one of the two new value types will add a new grid axis to the output(NOTE: The
listtype needs to change from comma-separated lists to support lists of text prompts, which almost always contain commas internally. Also I may just split this functionality into its ownGridAxisnode instead)PrimitiveNodecan combine more than one attached input into a single axis, for example to treat both LoRA weights as one axis. And this works (or at least is supposed to) for more than one node attachedSaveImageandPreviewImagecan now show grids if combinatorial outputs were usedImplementation
Internally some new state was added to inputs and outputs in the partially executed graph to keep track of which grid axis they came from. Nodes with more than one output like
LoraLoadertreat all of their outputs as having originated from the same axis, such that both outputs (CLIPandMODEL) are treated as one axis instead of two separate axes. Otherwise theCLIPfrom one batch could be combined with theMODELfrom another batch, which never happens during normal usage ofLoraLoader, so it's an invalid statePrimitiveNodeinternally "joins" all the inputs it's connected to into one axis as well, by associating each connection with a unique axis ID (which is thePrimitiveNode's ID for now). This ID is attached to the node's outputs and propagated downstream so long as those outputs have the only unique combinatorial axis ID across the inputs the other nodes receive, else the axis ID is reset so a new combination can be createdThe frontend relies on the sorting of the nodes' inputs based on some criteria to correctly associate the final output images with their coordinates in the graph. New combinatorial inputs will be prepended to the set of combinations, such that earlier axes will be changed more frequently. As an example, if A is connected to B, and each has a
weightaxis with two values, then the order in the grid will beIf there is more than one axis attached to a node then they will be applied in the alphabetical order of the input names
This order is recreated in the frontend by traversing the graph backwards from the output image nodes, instead of the backend explicitly sending the mapping from output to grid coordinates, as it gets pretty arduous to keep track of. I'm not even sure it can be tracked in the general case if the batch size changes since there's no universal way to correlate a number of inputs to outputs in a given backend node
Basically while there are a lot of use cases that this built-in grid feature can support, there are bound to be many it can't support, and it's a matter of throwing as many prompts as possible at it until it breaks so that those edge cases can be uncovered