From b6951768c41fa69a870c022a3adbc349fc4f2ac1 Mon Sep 17 00:00:00 2001 From: Raphael Walker Date: Thu, 6 Feb 2025 22:51:16 +0100 Subject: [PATCH 1/3] fix a bug in the attn_masked redux code when using weight=1.0 (#6721) --- nodes.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nodes.py b/nodes.py index ba9c4e4b..9779d5fd 100644 --- a/nodes.py +++ b/nodes.py @@ -1064,7 +1064,8 @@ class StyleModelApply: for t in conditioning: (txt, keys) = t keys = keys.copy() - if strength_type == "attn_bias" and strength != 1.0: + # even if the strength is 1.0 (i.e, no change), if there's already a mask, we have to add to it + if strength_type == "attn_bias" and strength != 1.0 and "attention_mask" not in keys: # math.log raises an error if the argument is zero # torch.log returns -inf, which is what we want attn_bias = torch.log(torch.Tensor([strength])) From 079eccc92a82b16727f9ff88da613e8b1f078eae Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Fri, 7 Feb 2025 03:29:12 -0500 Subject: [PATCH 2/3] Don't compress http response by default. Remove argument to disable it. Add new --enable-compress-response-body argument to enable it. --- comfy/cli_args.py | 2 +- server.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/comfy/cli_args.py b/comfy/cli_args.py index a92fc0db..ec8f92e8 100644 --- a/comfy/cli_args.py +++ b/comfy/cli_args.py @@ -179,7 +179,7 @@ parser.add_argument( parser.add_argument("--user-directory", type=is_valid_directory, default=None, help="Set the ComfyUI user directory with an absolute path. Overrides --base-directory.") -parser.add_argument("--disable-compres-response-body", action="store_true", help="Disable compressing response body.") +parser.add_argument("--enable-compress-response-body", action="store_true", help="Enable compressing response body.") if comfy.options.args_parsing: args = parser.parse_args() diff --git a/server.py b/server.py index 7b860847..1a79da7e 100644 --- a/server.py +++ b/server.py @@ -57,8 +57,6 @@ async def cache_control(request: web.Request, handler): async def compress_body(request: web.Request, handler): accept_encoding = request.headers.get("Accept-Encoding", "") response: web.Response = await handler(request) - if args.disable_compres_response_body: - return response if not isinstance(response, web.Response): return response if response.content_type not in ["application/json", "text/plain"]: @@ -165,7 +163,10 @@ class PromptServer(): self.client_session:Optional[aiohttp.ClientSession] = None self.number = 0 - middlewares = [cache_control, compress_body] + middlewares = [cache_control] + if args.enable_compress_response_body: + middlewares.append(compress_body) + if args.enable_cors_header: middlewares.append(create_cors_middleware(args.enable_cors_header)) else: From 832e3f5ca3c357e527fdf811502357bd2798425e Mon Sep 17 00:00:00 2001 From: Raphael Walker Date: Fri, 7 Feb 2025 20:44:43 +0100 Subject: [PATCH 3/3] Fix another small bug in attention_bias redux (#6737) * fix a bug in the attn_masked redux code when using weight=1.0 * oh shit wait there was another bug --- nodes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nodes.py b/nodes.py index 9779d5fd..1d2b1f9f 100644 --- a/nodes.py +++ b/nodes.py @@ -1065,10 +1065,10 @@ class StyleModelApply: (txt, keys) = t keys = keys.copy() # even if the strength is 1.0 (i.e, no change), if there's already a mask, we have to add to it - if strength_type == "attn_bias" and strength != 1.0 and "attention_mask" not in keys: + if "attention_mask" in keys or (strength_type == "attn_bias" and strength != 1.0): # math.log raises an error if the argument is zero # torch.log returns -inf, which is what we want - attn_bias = torch.log(torch.Tensor([strength])) + attn_bias = torch.log(torch.Tensor([strength if strength_type == "attn_bias" else 1.0])) # get the size of the mask image mask_ref_size = keys.get("attention_mask_img_shape", (1, 1)) n_ref = mask_ref_size[0] * mask_ref_size[1]