Spaces:
Paused
Paused
Update ldm/modules/encoders/modules.py
Browse files
ldm/modules/encoders/modules.py
CHANGED
|
@@ -151,7 +151,6 @@ class FrozenOpenCLIPEmbedder(AbstractEncoder):
|
|
| 151 |
)
|
| 152 |
|
| 153 |
self.model = open_clip.create_model(arch, pretrained=pretrained_path)
|
| 154 |
-
self.tokenizer = open_clip.tokenizer.SimpleTokenizer()
|
| 155 |
|
| 156 |
if hasattr(self.model, "visual"):
|
| 157 |
delattr(self.model, "visual")
|
|
@@ -174,8 +173,9 @@ class FrozenOpenCLIPEmbedder(AbstractEncoder):
|
|
| 174 |
param.requires_grad = False
|
| 175 |
|
| 176 |
def forward(self, text):
|
| 177 |
-
tokens =
|
| 178 |
-
|
|
|
|
| 179 |
z = self.encode_with_transformer(tokens)
|
| 180 |
return z
|
| 181 |
|
|
@@ -217,6 +217,4 @@ class FrozenCLIPT5Encoder(AbstractEncoder):
|
|
| 217 |
def forward(self, text):
|
| 218 |
clip_z = self.clip_encoder.encode(text)
|
| 219 |
t5_z = self.t5_encoder.encode(text)
|
| 220 |
-
return [clip_z, t5_z]
|
| 221 |
-
|
| 222 |
-
|
|
|
|
| 151 |
)
|
| 152 |
|
| 153 |
self.model = open_clip.create_model(arch, pretrained=pretrained_path)
|
|
|
|
| 154 |
|
| 155 |
if hasattr(self.model, "visual"):
|
| 156 |
delattr(self.model, "visual")
|
|
|
|
| 173 |
param.requires_grad = False
|
| 174 |
|
| 175 |
def forward(self, text):
|
| 176 |
+
tokens = open_clip.tokenize(text, context_length=self.max_length).to(self.device)
|
| 177 |
+
if tokens.dim() == 1:
|
| 178 |
+
tokens = tokens.unsqueeze(0)
|
| 179 |
z = self.encode_with_transformer(tokens)
|
| 180 |
return z
|
| 181 |
|
|
|
|
| 217 |
def forward(self, text):
|
| 218 |
clip_z = self.clip_encoder.encode(text)
|
| 219 |
t5_z = self.t5_encoder.encode(text)
|
| 220 |
+
return [clip_z, t5_z]
|
|
|
|
|
|