|
|
|
@ -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) |
|
|
|
|