From 2c80d9acb9a542fef843954370390369093b6ac4 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Tue, 9 Jan 2024 15:12:12 -0500 Subject: [PATCH] Round up to nearest power of 2 in SAG node to fix some resolution issues. --- comfy_extras/nodes_sag.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/comfy_extras/nodes_sag.py b/comfy_extras/nodes_sag.py index 450ac3ee..b307b4f5 100644 --- a/comfy_extras/nodes_sag.py +++ b/comfy_extras/nodes_sag.py @@ -58,7 +58,7 @@ def create_blur_map(x0, attn, sigma=3.0, threshold=1.0): attn = attn.reshape(b, -1, hw1, hw2) # Global Average Pool mask = attn.mean(1, keepdim=False).sum(1, keepdim=False) > threshold - ratio = math.ceil(math.sqrt(lh * lw / hw1)) + ratio = 2**(math.ceil(math.sqrt(lh * lw / hw1)) - 1).bit_length() mid_shape = [math.ceil(lh / ratio), math.ceil(lw / ratio)] # Reshape