Based on ComfyUI_TravelSuite by NicholasMcCarthy
This suite of nodes allows for different types of latent walks, offering flexibility in interpolation and blending across various latent spaces. It supports walking between latent spaces, conditional latents, and even noise spaces. The supported modes of travel and blend give a wide variety of creative options.
Here is an example made with flux.1-schnell-gguf-4:
Here is a workflow on how you can do the same without this package - but with 20+ nodes instead of 10 and no batch-computing - therefore significantly slower.
Each of these nodes facilitates a unique type of latent walk, detailed below.
- linear: Linear interpolation from start to end.
- circle: Interpolates along a circular path in latent space.
- quadratic: Steps along a quadratic (x²) path.
- cubic: Steps along a cubic (x³) path.
- quartic: Steps along a quartic (x⁴) path.
- geometric: Steps along a geometric progression.
- hinge: Splits the steps at a given cut point (hinge) and interpolates above and below the cut point separately.
- norm: Steps according to a normal distribution centered at 0.5. The
factor
parameter adjusts the Gaussian scale.
- lerp: Linear interpolation between latents.
- slerp: Spherical interpolation between latents.
- add: Adds two latent vectors.
- multiply: Multiplies two latent vectors element-wise.
- divide: Divides one latent vector by another element-wise.
- subtract: Subtracts one latent vector from another.
- overlay, hard_light, soft_light, screen: Standard image blend modes applied to latent vectors.
- linear_dodge: Lightens latent vectors by increasing brightness.
- difference: Subtracts colors and inverts the result when needed.
- exclusion: Similar to difference but with less contrast.
- random: Applies random noise between the two latent vectors.
Travel in LATENT / VAE encoded space.
- start: Starting latent vector (
LATENT
). - end: Ending latent vector (
LATENT
). - steps: The number of steps for interpolation (min: 3, max: 10000, default: 5). This determines the number of intermediate latents generated.
- factor: A floating-point value influencing the travel behavior, depending on the travel mode (default: 0.5) - only relevant for the travel-modes hinge and norm.
- blend: Specifies the blending mode used during interpolation. See Blend Modes for available options.
- travel: Determines the mode of interpolation (traveling). See Travel Modes for available options.
- reflect: Boolean indicating whether the travel values should be reflected around the midpoint (default:
False
). - (Optional) vae_model: A trained VAE model for decoding latent vectors into images.
- latents: A series of latent vectors representing the transition from the start latent to the end latent over the specified number of steps.
- images: A series of images decoded from the latent vectors using the provided VAE model.
Travel in the NOISE space of the advanced sampler.
Currently, samplers don't support batches / lists of noise vectors, so this node requires execution inversion demo for loops
Same as LatentWalk: start
, end
, steps
, factor
, travel
, reflect
but without blend
.
But the only blending mode is add
due to technical limitations - as well as the requirement that noise-vectors must have a specific linalg-norm to work - which is why some post-processing is required.
- list: A batch of noise vectors, in case samplers support it in the future.
- accumulation: Accumulated noise vectors that can be used in for-loop operations.
Travel the CONDITIONING / CLIP encoded space.
**Requires the correct batch_size in the latent_space node and the noise
Same as LatentWalk: start
, end
, steps
, factor
, travel
, blend
, reflect
.
- conditionings: A batch of conditioning vectors.
Travel the CONDITIONING / CLIP encoded space with random noise. Normalize the CONDITIONING to have the same length as start
.
class LatentWalkConditionalRandom:
@classmethod
def INPUT_TYPES(cls):
return {"required": {
"start": ("CONDITIONING",),
"dist_mult": ("FLOAT", {"default": 0.5, "min": 0.001, "max": 1000.0, "step": 0.01}),
"momentum": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.01}),
"steps": ("INT", {"default": 9, "max": 10000, "step": 1}),
}}
RETURN_TYPES = ("CONDITIONING",)
RETURN_NAMES = ("CONDITIONINGS",)
FUNCTION = "latent_walk_conditional_random"
def latent_walk_conditional_random(self, start, dist_mult, momentum, steps):
sc, sp = unpack_conditioning(start)
rc = torch.cat(list(random_walk(sc, dist_mult, momentum, steps)), 0)
rp = torch.cat(list(random_walk(sp, dist_mult, momentum, steps)), 0)
return ([[rc, {"pooled_output": rp}]],)
- start: Starting latent vector (
CONDITIONING
). - dist_mult: Multiplier to the length of the original latent space length for a step (default: 0.5).
- momentum: How far to go into the same direction as the last step. 0 = off, perfectly random, 1.0 = go in a straight line. (default: 0.0).
- steps: The number of steps for interpolation (min: 3, max: 10000, default: 5). This determines the number of intermediate latents generated.
- conditionings: A batch of conditioning vectors.
To install the LatentWalk nodes, simply place the scripts in your ComfyUI custom_nodes
folder and restart the application.