From 7d2467e830ca8f6dfab67e74867aa08fded3d75e Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Sat, 5 Oct 2024 13:22:39 -0400 Subject: [PATCH 1/4] Some minor cleanups. --- comfy/clip_vision.py | 3 +-- comfy/float.py | 1 - comfy/sd.py | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/comfy/clip_vision.py b/comfy/clip_vision.py index 20dc3345d..64392e270 100644 --- a/comfy/clip_vision.py +++ b/comfy/clip_vision.py @@ -109,8 +109,7 @@ def load_clipvision_from_sd(sd, prefix="", convert_keys=False): keys = list(sd.keys()) for k in keys: if k not in u: - t = sd.pop(k) - del t + sd.pop(k) return clip def load(ckpt_path): diff --git a/comfy/float.py b/comfy/float.py index 4a6ae6776..0c8f1d6cf 100644 --- a/comfy/float.py +++ b/comfy/float.py @@ -1,5 +1,4 @@ import torch -import math def calc_mantissa(abs_x, exponent, normal_mask, MANTISSA_BITS, EXPONENT_BIAS, generator=None): mantissa_scaled = torch.where( diff --git a/comfy/sd.py b/comfy/sd.py index 3b4cff747..a494e531c 100644 --- a/comfy/sd.py +++ b/comfy/sd.py @@ -29,7 +29,6 @@ import comfy.text_encoders.long_clipl import comfy.model_patcher import comfy.lora import comfy.t2i_adapter.adapter -import comfy.supported_models_base import comfy.taesd.taesd def load_lora_for_models(model, clip, lora, strength_model, strength_clip): From 2c641e64adb95a374aa4acb5bd32d0392f8ff72a Mon Sep 17 00:00:00 2001 From: Lex <32320531+LexLuc@users.noreply.github.com> Date: Sun, 6 Oct 2024 17:47:51 +0800 Subject: [PATCH 2/4] IS_CHANGED should be a classmethod (#5159) --- custom_nodes/websocket_image_save.py | 1 + 1 file changed, 1 insertion(+) diff --git a/custom_nodes/websocket_image_save.py b/custom_nodes/websocket_image_save.py index 5aa573642..09fe1bde5 100644 --- a/custom_nodes/websocket_image_save.py +++ b/custom_nodes/websocket_image_save.py @@ -37,6 +37,7 @@ class SaveImageWebsocket: return {} + @classmethod def IS_CHANGED(s, images): return time.time() From 7d29fbf74bc99e0bc864aee5ae07d41de5266b18 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Sun, 6 Oct 2024 17:55:46 -0400 Subject: [PATCH 3/4] Slightly improve the fast previews for flux by adding a bias. --- comfy/latent_formats.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/comfy/latent_formats.py b/comfy/latent_formats.py index 78397d75a..eaad3b312 100644 --- a/comfy/latent_formats.py +++ b/comfy/latent_formats.py @@ -147,23 +147,24 @@ class Flux(SD3): self.scale_factor = 0.3611 self.shift_factor = 0.1159 self.latent_rgb_factors =[ - [-0.0404, 0.0159, 0.0609], - [ 0.0043, 0.0298, 0.0850], - [ 0.0328, -0.0749, -0.0503], - [-0.0245, 0.0085, 0.0549], - [ 0.0966, 0.0894, 0.0530], - [ 0.0035, 0.0399, 0.0123], - [ 0.0583, 0.1184, 0.1262], - [-0.0191, -0.0206, -0.0306], - [-0.0324, 0.0055, 0.1001], - [ 0.0955, 0.0659, -0.0545], - [-0.0504, 0.0231, -0.0013], - [ 0.0500, -0.0008, -0.0088], - [ 0.0982, 0.0941, 0.0976], - [-0.1233, -0.0280, -0.0897], - [-0.0005, -0.0530, -0.0020], - [-0.1273, -0.0932, -0.0680] + [-0.0346, 0.0244, 0.0681], + [ 0.0034, 0.0210, 0.0687], + [ 0.0275, -0.0668, -0.0433], + [-0.0174, 0.0160, 0.0617], + [ 0.0859, 0.0721, 0.0329], + [ 0.0004, 0.0383, 0.0115], + [ 0.0405, 0.0861, 0.0915], + [-0.0236, -0.0185, -0.0259], + [-0.0245, 0.0250, 0.1180], + [ 0.1008, 0.0755, -0.0421], + [-0.0515, 0.0201, 0.0011], + [ 0.0428, -0.0012, -0.0036], + [ 0.0817, 0.0765, 0.0749], + [-0.1264, -0.0522, -0.1103], + [-0.0280, -0.0881, -0.0499], + [-0.1262, -0.0982, -0.0778] ] + self.latent_rgb_factors_bias = [-0.0329, -0.0718, -0.0851] self.taesd_decoder_name = "taef1_decoder" def process_in(self, latent): From e5ecdfdd2dd980262086b0df17cfde0b1d505dbc Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Sun, 6 Oct 2024 19:27:04 -0400 Subject: [PATCH 4/4] Make fast previews for SDXL a little better by adding a bias. --- comfy/latent_formats.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/comfy/latent_formats.py b/comfy/latent_formats.py index eaad3b312..d472a0ebf 100644 --- a/comfy/latent_formats.py +++ b/comfy/latent_formats.py @@ -31,11 +31,13 @@ class SDXL(LatentFormat): def __init__(self): self.latent_rgb_factors = [ # R G B - [ 0.3920, 0.4054, 0.4549], - [-0.2634, -0.0196, 0.0653], - [ 0.0568, 0.1687, -0.0755], - [-0.3112, -0.2359, -0.2076] + [ 0.3651, 0.4232, 0.4341], + [-0.2533, -0.0042, 0.1068], + [ 0.1076, 0.1111, -0.0362], + [-0.3165, -0.2492, -0.2188] ] + self.latent_rgb_factors_bias = [ 0.1084, -0.0175, -0.0011] + self.taesd_decoder_name = "taesdxl_decoder" class SDXL_Playground_2_5(LatentFormat):