CG's custom nodes: Stash
Stash
To install:
cd [path to ComfyUI]/custom_nodes
git clone https://github.com/chrisgoringe/cg-stash.git
Stash is a set of four custom nodes (three required, one optional) designed to make iterative workflows (such as inpainting, img2img, or outpainting) much more convenient. It allows you to 'stash' an image when it is generated, and then choose whether to use it for the next interation, reject it and use the previous image, or start again from your initial image.
Here's an example - inpainting a photo by Stephen Leonardi to add a space launch. At the bottom of this page is the image generated, which contains the workflow.
The top half of the workflow is just a typical inpaint setup, except that the Image Stash
and Image Unstash
nodes are inserted. Image Stash
is placed to 'intercept' the output image; Image Unstash
is placed near the input image, to (potentially) replace it. The stash contains (up to) three different images: initial
(the image it gets from its initial input), and the input
and output
of the last run.
The third essential node is the Image Stash Controller
. It determines the behaviour of the Image Unstash
node that share its id
. It has three settings:
New image
- used when you load up a new image. In this setting theImage Unstash
node passes theinitial
image through untouched (and saves it asinput
).Use latest output
- used when the last iteration was an improvement. In this setting theImage Unstash
ignoresinitial
, and instead returns theoutput
from the previous run.Reject latest output
- when an iteration went badly, and you want to go back to the previous one. TheImage Unstash
returns previousinput
again.
In each case, the Image Stash
node just saves what it gets as output
and returns it.
The optional node, Image Unstash All
, returns all three images - from left to right it shows the initial
, input
, and output
. This node has an optional input called trigger
which you need1 to attach downstream of the Image Stash
node in order to ensure that it is executed after the image has been generated.
Here's an image with the workflow:
1 Technical note: ComfyUI chooses the output node that is dependant on fewest unexecuted other nodes to run, so the Image Stash Controller
gets run early, but this means the Image Unstash All
node will run before the images get generated if it doesn't have an input. ComfyUI pull request #1348 is a mechanism to allow nodes to be given an explicit priority, so if it gets merged the trigger
will no longer be needed.