Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Add a LatentFlip node.

comfyanonymous3fa009f4cc67
diff --git a/nodes.py b/nodes.py
index 974ebf52f..5cccc79f0 100644
--- a/nodes.py
+++ b/nodes.py
@@ -210,7 +210,6 @@ class LatentRotate:
CATEGORY = "latent"
def rotate(self, samples, rotation):
- s = samples.clone()
rotate_by = 0
if rotation.startswith("90"):
rotate_by = 1
@@ -221,6 +220,27 @@ class LatentRotate:
s = torch.rot90(samples, k=rotate_by, dims=[3, 2])
return (s,)
+
+class LatentFlip:
+ @classmethod
+ def INPUT_TYPES(s):
+ return {"required": { "samples": ("LATENT",),
+ "flip_method": (["x-axis: vertically", "y-axis: horizontally"],),
+ }}
+ RETURN_TYPES = ("LATENT",)
+ FUNCTION = "flip"
+
+ CATEGORY = "latent"
+
+ def flip(self, samples, flip_method):
+ if flip_method.startswith("x"):
+ s = torch.flip(samples, dims=[2])
+ elif flip_method.startswith("y"):
+ s = torch.flip(samples, dims=[3])
+ else:
+ s = samples
+
+ return (s,)
def common_ksampler(device, model, seed, steps, cfg, sampler_name, scheduler, positive, negative, latent_image, denoise=1.0, disable_noise=False, start_step=None, last_step=None, force_full_denoise=False):
if disable_noise:
noise = torch.zeros(latent_image.size(), dtype=latent_image.dtype, layout=latent_image.layout, device="cpu")
@@ -409,6 +429,7 @@ NODE_CLASS_MAPPINGS = {
"ConditioningSetArea": ConditioningSetArea,
"KSamplerAdvanced": KSamplerAdvanced,
"LatentRotate": LatentRotate,
+ "LatentFlip": LatentFlip,
}