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.

split tokenizer from encoder

BlenderNeko73175cf58c03
diff --git a/comfy/sd.py b/comfy/sd.py
index 2d7ff5ab0..6bd30daf4 100644
--- a/comfy/sd.py
+++ b/comfy/sd.py
@@ -372,10 +372,12 @@ class CLIP:
def clip_layer(self, layer_idx):
self.layer_idx = layer_idx
- def encode(self, text):
+ def tokenize(self, text):
+ return self.tokenizer.tokenize_with_weights(text)
+
+ def encode(self, tokens):
if self.layer_idx is not None:
self.cond_stage_model.clip_layer(self.layer_idx)
- tokens = self.tokenizer.tokenize_with_weights(text)
try:
self.patcher.patch_model()
cond = self.cond_stage_model.encode_token_weights(tokens)
diff --git a/nodes.py b/nodes.py
index 946c66857..b81d16015 100644
--- a/nodes.py
+++ b/nodes.py
@@ -44,7 +44,8 @@ class CLIPTextEncode:
CATEGORY = "conditioning"
def encode(self, clip, text):
- return ([[clip.encode(text), {}]], )
+ tokens = clip.tokenize(text)
+ return ([[clip.encode(tokens), {}]], )
class ConditioningCombine:
@classmethod