Skip to content

Commit

Permalink
fix for use with larger openai clip models by extracting dimension of…
Browse files Browse the repository at this point in the history
… last layernorm in clip
  • Loading branch information
lucidrains committed Sep 29, 2022
1 parent b39653c commit c18c080
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion dalle2_pytorch/dalle2_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,10 @@ def __init__(
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

Expand All @@ -333,7 +336,7 @@ def _hook(self, _, inputs, outputs):

@property
def dim_latent(self):
return 512
return self.dim_latent_

@property
def image_size(self):
Expand Down
2 changes: 1 addition & 1 deletion dalle2_pytorch/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.10.6'
__version__ = '1.10.7'

0 comments on commit c18c080

Please sign in to comment.