mirror of
https://github.com/openai/CLIP.git
synced 2026-11-05 01:37:26 +00:00
[GH-ISSUE #110] Use pretrained CLIP with a context_length not equal to 77 (default value) #97
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openai/CLIP#97
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ABaldrati on GitHub (May 28, 2021).
Original GitHub issue: https://github.com/openai/CLIP/issues/110
Thanks you guys for the amazing job and releasing CLIP model.
As written in the title I wanted to ask if it was possible to use pretrained CLIP models with a context_length different from the default value (which is 77).
If I try to change the
context_lengthof the tokenizer to another value (like 150), using pretrained clip model "out of the box" I get the following error:File "/homes/students_home/abaldrati/miniconda3/lib/python3.8/site-packages/clip/model.py", line 342, in encode_text x = x + self.positional_embedding.type(self.dtype) RuntimeError: The size of tensor a (150) must match the size of tensor b (77) at non-singleton dimension 1Thanks again for the amazing work
@vinson2233 commented on GitHub (Jun 4, 2021):
I don't think that's possible since the network is designed and trained for context_length up to 77.
You might want to retrain your model from scratch, or just reduce your text so it <= 77 characters(UPDATE : It should be 77 tokens, not 77 characters)
@ABaldrati commented on GitHub (Jun 7, 2021):
Yes I imagined that, thanks for the answer anyway
@Cbhihe commented on GitHub (Oct 27, 2021):
@vinson2233:
Thanks for answering the question asked by @ABaldrati. I had the exact same issue.
I take that your answer is still valid.
You may want to correct your answer in that (unless mistaken) it should read "...<= 77 tokens", not "characters".
In fact it should read 75 tokens, including words, any punctuation symbol, a "start-of-summary" token, and an "end-of-summary" token, which should not be more than 77 in total. Thanks. ;-)
@vinson2233 commented on GitHub (Oct 28, 2021):
@Cbhihe yup, you are right, it should be
tokens, notcharacter. The author have tell about this in this issue https://github.com/openai/CLIP/issues/119@iasonasxrist commented on GitHub (Jul 18, 2022):
Same problem! Suppose i cannot edit it due to the training process