[GH-ISSUE #253] CLIP image_encoder as backbone #222

Closed
opened 2026-10-31 21:12:37 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @iasonasxrist on GitHub (Jun 15, 2022).
Original GitHub issue: https://github.com/openai/CLIP/issues/253

I have been trying to implement the model.py to separate the image encoder from text but i got plenty of errors kind of :

self.positional_embedding = nn.Parameter(torch.empty(self.context_length, transformer_width))

raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'CLIP' object has no attribute 'context_length'

Any ideas how to override them?

Originally created by @iasonasxrist on GitHub (Jun 15, 2022). Original GitHub issue: https://github.com/openai/CLIP/issues/253 I have been trying to implement the model.py to separate the image encoder from text but i got plenty of errors kind of : self.positional_embedding = nn.Parameter(torch.empty(self.context_length, transformer_width)) raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'CLIP' object has no attribute 'context_length' Any ideas how to override them?
Author
Owner

@lr19960813 commented on GitHub (Mar 27, 2023):

I have been trying to implement the model.py to separate the image encoder from text but i got plenty of errors kind of :

self.positional_embedding = nn.Parameter(torch.empty(self.context_length, transformer_width))

raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'CLIP' object has no attribute 'context_length'

Any ideas how to override them?

Hi, I encountered the same problem as you, how did you solve it, looking forward to your reply. Thanks a lot!

<!-- gh-comment-id:1485562643 --> @lr19960813 commented on GitHub (Mar 27, 2023): > I have been trying to implement the model.py to separate the image encoder from text but i got plenty of errors kind of : > > self.positional_embedding = nn.Parameter(torch.empty(self.context_length, transformer_width)) > > raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'CLIP' object has no attribute 'context_length' > > Any ideas how to override them? Hi, I encountered the same problem as you, how did you solve it, looking forward to your reply. Thanks a lot!
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openai/CLIP#222
No description provided.