From 0d8f3764468999bc34700799553919ded9b34ef8 Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Thu, 14 Sep 2023 18:12:36 -0400 Subject: [PATCH] Set last layer on SD2.x models uses the proper indexes now. Before I had made the last layer the penultimate layer because some checkpoints don't have them but it's not consistent with the others models. TLDR: for SD2.x models only: CLIPSetLastLayer -1 is now -2. --- comfy/sd2_clip.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/comfy/sd2_clip.py b/comfy/sd2_clip.py index 818c9711e..05e50a005 100644 --- a/comfy/sd2_clip.py +++ b/comfy/sd2_clip.py @@ -12,16 +12,6 @@ class SD2ClipModel(sd1_clip.SD1ClipModel): super().__init__(device=device, freeze=freeze, layer=layer, layer_idx=layer_idx, textmodel_json_config=textmodel_json_config, textmodel_path=textmodel_path, dtype=dtype) self.empty_tokens = [[49406] + [49407] + [0] * 75] - def clip_layer(self, layer_idx): - if layer_idx < 0: - layer_idx -= 1 #The real last layer of SD2.x clip is the penultimate one. The last one might contain garbage. - if abs(layer_idx) >= 24: - self.layer = "hidden" - self.layer_idx = -2 - else: - self.layer = "hidden" - self.layer_idx = layer_idx - class SD2Tokenizer(sd1_clip.SD1Tokenizer): def __init__(self, tokenizer_path=None, embedding_directory=None): super().__init__(tokenizer_path, pad_with_end=False, embedding_directory=embedding_directory, embedding_size=1024)