This contains all-in-one 'principled' nodes for T2I, I2I, refining, and scaling. Additionally it has many tools for directly manipulating the color of latents, high res fix math, and scripted image post-processing.
Addons for ComfyUI
To install all the nodes, simply put the entire bsz-nodes
folder inside your custom_nodes
folder in ComfyUI
To install specific nodes, you may put individual .py
files from bsz-nodes
directly into the ComfyUI custom_nodes
folder.
__init__.py
simply forwards all nodes within its folder to ComfyUI, and is not necessary if you're putting nodes directly into custom_nodes
Contains 3 nodes each with a different means to the same end result. These nodes are designed to automatically calculate the appropriate latent sizes when performing a "Hi Res Fix" style workflow.
base_model_res
: Resolution of base model being used. SD 1.5 ≅ 512, SD 2.1 ≅ 768, SDXL ≅ 1024Lo Res Width
: Width intended to be used for first/low res passLo Res Height
: Height intended to be used for first/low res passHi Res Width
: Width intended to be used for final/high res passHi Res Height
: Height intended to be used for final/high res passdesired_width
: Width in pixels for final/high res pass.desired_height
: Height in pixels for final/high res pass.desired_aspect_x
: Horizontal aspect.desired_aspect_Y
: Vertical aspect.scale
: Hi Res horizontal and vertical scale over Lo Res sizes. Note that because this scales both axes, a scale of 2.0
will actually quadruple the amount of pixels in an image, so use with care.A unique node that functions both as BSZAbsoluteHires and BSZAspectHires with a convenient toggle
use_aspect_scale
: Use aspect & scale inputs instead of desired width/height inputsAll-in-one nodes for sampling and scaling pipelines.
Text2Image, Image2Image pipeline workflows with optional refiner Input fields
base_model
: Model from base checkpointbase_clip
: CLIP from base checkpointlatent
: Latent image to start fromrefiner_model
: Model from refiner checkpoint. Optionalrefiner_clip
: CLIP from refiner checkpoint. Optionalpositive_prompt
: Positive promptnegative_prompt
: Negative promptsteps
: Steps for non-scaled passdenoise
: Denoise amount for latent input. Recommend 0.3 for img2img/pixel scale, 0.6 for latent scalecfg
: CFG scalerefiner_amount
: Refiner to base ratio. Requires refiner model and refiner clip to functionrefiner_ascore_positive
: Refiner aesthetic score for positive prompt. Ignored if refiner is not XL architecturerefiner_ascore_negative
: Refiner aesthetic score for negative prompt. Ignored if refiner is not XL architecturesampler
: Sampler. DDIM or Euler needed for proper refiner usagescheduler
: Scheduler. Normal needed for proper refiner usageseed
: Seedy.
Additionally, it produces batches by seed increment instead of whatever the hell ComfyUI does by default. This means seed 4 batch index 3 is equivalent to seed 7, making it much easier to reproduce images from batches.Up/downscaling with either pixel, latent, or model methods. Pixel and model methods first decode with the VAE before scaling and re-encoding.
vae
: VAE to use when converting to pixel space and backlatent
: Latnet imagewidth
: New widthheight
: New heightmethod
: Scaling method to useNodes for manipulating the color of latent images.
Creates an colored (non-empty) latent image according to the SDXL VAE
color
: Choice of color.strength
: Color strength/opacity over zero/graywidth/height/batch_size
: Same as EmptyLatentImageOffsets the latent image(s) value towards black/white according to the SDXL VAE
latent
: Latent image(s).offset
: 0.0 is unchanged, -1.0 is black, 1.0 is white.Creates a latent of arbitrary color by encoding it with the provided VAE. Note that even though 0.5, 0.5, 0.5
seems like it should be equal to an empty latent, in reality it is not and seeds will be very different. Also comes in HSVA flavor.
r/g/b
: RGB in 0.0 -> 1.0 scalea
: Alpha. 0.0 for empty latent, 1.0 for entirely coloredwidth/height/batch_size
: Same as EmptyLatentImageBlend two latents together in a gradient pattern
a
: First latent; will copy params from thisb
: Second latentpattern
: Gradient pattern
sine
: Typical banded gradient. Both horizontal, vertial, diagonal depneding on frequencysine2
: Same as sine
but the y axis is flippedcircle
: Produces circles packed in a honeycomb shapesquircle
: Produces squircles packed in a gridrings
: Produces rings centered on offsets. Circle but recursive instead of tilingxfrequency
: Pattern repetitions along X axis; horizontal gradientyfrequency
: Pattern repetitions along Y axis; vertical gradientxoffset
: Pattern start offset for X frequenciesyoffset
: Pattern start offset for Y frequenciesinvert
: Invert A/B colors. Will still take params from AAdjust an SDXL latent directly using Hue/Chroma/Lightness sliders. Kind of works on non-XL latents, but not as accurately. Input fields
hue
: Hue offset in degreeschroma
: Multiply the chromalightness
: Multiply the lightnessFill the four latent channels with arbitrary values.
latent
: Latent image(s).a/b/c/d
: Values for the four channelsOutput information about the latent tensor into stdout
Nodes that require my own Pixelbuster library. Linux, Windows, and MacOS libraries are included directly in this node pack and won't have to be downloaded separately.
Write simple code to manipulate colors Input fields
image
: Image[s] to work oncode
: Pixelbuster code. See the help for referencee1-e9
: Vars you can set externally that will be seen by the pixelbuster code as e1-e9Write simple code to manipulate latent 'colors' Input fields
latent
: Latents[s] to work on. CIE LAB colorspace for the first 3 channels with the 4th being alpha.code
: Pixelbuster code. See the help for referencee1-e9
: Vars you can set externally that will be seen by the pixelbuster code as e1-e9Personal flair of the SDXL "partial diffusion" workflow. Minimalist node setup with defaults balanced approach to speed/quality
bsz-auto-hires.py
: While this workflow doesn't actually perform any upscaling, it still uses the BSZAutoHiresCombined
node for quick aspect ratio changing and easy CLIP detail target adjustmentsPersonal flair of the SDXL "partial diffusion" workflow with added "High res fix". Slightly prioritizes speed as far as upscaling is concerned.
bsz-auto-hires.py
: Workflow is painful without it.Complete demonstration of nodes in a compact workflow
Everything except bsz-experimental.py
Question|Answer
---|---
What happened to the all-in-one XL node with upscaling and hires fix?|That design was inherently flawed due to ComfyUI's caching system. Now that ComfyUI has bypasses (CTRL+B) I re-wrote it into the single-stage chainable node you see now. This allows the same functionality while not having to restart the whole image when only changing the 2nd stage. Yes it's slightly messier looking but the time savings is huge. Please look at the sdxl-principled.json
workflow for an example of how to most optimally use the new chained node.
Why is there a separate VAE loader instead of using the VAE directly from the main checkpoint?|I personally find it desireable to have the VAE decoupled from the checkpoint so you can change it without re-baking the models. If this isn't desirable to you yourself, simply remove the Load VAE node and reconnect the traces into the main Load Checkpoint node instead.
Why are the KSampler nodes so long?|To show live previews of each stage. I strongly recommend you do the same by launching ComfyUI with --preview-method latent2rgb
or similar.
Why is this setting the default instead of that setting?|It just happens to look better on my benchmark images. If you think it's objectively wrong, open an issue with a compelling case on why it should be changed.