Add a LatentFlip node.

This commit is contained in:
comfyanonymous 2023-01-31 03:28:38 -05:00
parent 69df7eba94
commit 3fa009f4cc
1 changed files with 22 additions and 1 deletions

View File

@ -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,
}