Skip to content

Commit 3df86ac

Browse files
committed
make it work for @ethancohen123
1 parent de5e628 commit 3df86ac

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

dalle2_pytorch/dalle2_pytorch.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,13 @@ def embed_text(self, text):
250250
text = text[..., :self.max_text_len]
251251
text_mask = text != 0
252252
encoder_output = self.clip.text_transformer(text)
253-
text_cls, text_encodings = encoder_output[:, 0], encoder_output[:, 1:]
253+
254+
text_cls, text_encodings = (encoder_output[:, 0], encoder_output[:, 1:]) if encoder_output.ndim == 3 else (encoder_output, None)
254255
text_embed = self.clip.to_text_latent(text_cls)
255-
text_encodings = text_encodings.masked_fill(~text_mask[..., None], 0.)
256+
257+
if exists(text_encodings):
258+
text_encodings = text_encodings.masked_fill(~text_mask[..., None], 0.)
259+
256260
return EmbeddedText(l2norm(text_embed), text_encodings)
257261

258262
@torch.no_grad()

dalle2_pytorch/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.8.2'
1+
__version__ = '1.8.3'

0 commit comments

Comments
 (0)