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 latent upscale by node.

comfyanonymousc00bb1a0b78f
diff --git a/nodes.py b/nodes.py
index e5cec2632..f0a93ebd5 100644
--- a/nodes.py
+++ b/nodes.py
@@ -768,6 +768,25 @@ class LatentUpscale:
s["samples"] = comfy.utils.common_upscale(samples["samples"], width // 8, height // 8, upscale_method, crop)
return (s,)
+class LatentUpscaleBy:
+ upscale_methods = ["nearest-exact", "bilinear", "area", "bislerp"]
+
+ @classmethod
+ def INPUT_TYPES(s):
+ return {"required": { "samples": ("LATENT",), "upscale_method": (s.upscale_methods,),
+ "scale_by": ("FLOAT", {"default": 1.5, "min": 0.01, "max": 8.0, "step": 0.01}),}}
+ RETURN_TYPES = ("LATENT",)
+ FUNCTION = "upscale"
+
+ CATEGORY = "latent"
+
+ def upscale(self, samples, upscale_method, scale_by):
+ s = samples.copy()
+ width = round(samples["samples"].shape[3] * scale_by)
+ height = round(samples["samples"].shape[2] * scale_by)
+ s["samples"] = comfy.utils.common_upscale(samples["samples"], width, height, upscale_method, "disabled")
+ return (s,)
+
class LatentRotate:
@classmethod
def INPUT_TYPES(s):
@@ -1244,6 +1263,7 @@ NODE_CLASS_MAPPINGS = {
"VAELoader": VAELoader,
"EmptyLatentImage": EmptyLatentImage,
"LatentUpscale": LatentUpscale,
+ "LatentUpscaleBy": LatentUpscaleBy,
"LatentFromBatch": LatentFromBatch,
"RepeatLatentBatch": RepeatLatentBatch,
"SaveImage": SaveImage,
@@ -1322,6 +1342,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"LatentCrop": "Crop Latent",
"EmptyLatentImage": "Empty Latent Image",
"LatentUpscale": "Upscale Latent",
+ "LatentUpscaleBy": "Upscale Latent By",
"LatentComposite": "Latent Composite",
"LatentFromBatch" : "Latent From Batch",
"RepeatLatentBatch": "Repeat Latent Batch",