From c18c0801283d30384912df0e35f225f3df1566a3 Mon Sep 17 00:00:00 2001 From: Phil Wang Date: Thu, 29 Sep 2022 09:09:41 -0700 Subject: [PATCH] fix for use with larger openai clip models by extracting dimension of last layernorm in clip --- dalle2_pytorch/dalle2_pytorch.py | 5 ++++- dalle2_pytorch/version.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dalle2_pytorch/dalle2_pytorch.py b/dalle2_pytorch/dalle2_pytorch.py index 489a1f3..9ab9566 100644 --- a/dalle2_pytorch/dalle2_pytorch.py +++ b/dalle2_pytorch/dalle2_pytorch.py @@ -314,7 +314,10 @@ class OpenAIClipAdapter(BaseClipAdapter): self.eos_id = 49407 # for handling 0 being also '!' text_attention_final = self.find_layer('ln_final') + + self.dim_latent_ = text_attention_final.weight.shape[0] self.handle = text_attention_final.register_forward_hook(self._hook) + self.clip_normalize = preprocess.transforms[-1] self.cleared = False @@ -333,7 +336,7 @@ class OpenAIClipAdapter(BaseClipAdapter): @property def dim_latent(self): - return 512 + return self.dim_latent_ @property def image_size(self): diff --git a/dalle2_pytorch/version.py b/dalle2_pytorch/version.py index 37f0254..8047ba3 100644 --- a/dalle2_pytorch/version.py +++ b/dalle2_pytorch/version.py @@ -1 +1 @@ -__version__ = '1.10.6' +__version__ = '1.10.7'