[GH-ISSUE #278] Error when evaluate CLIP with RN50x16 on ImageNet #241

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

Originally created by @euminds on GitHub (Jul 31, 2022).
Original GitHub issue: https://github.com/openai/CLIP/issues/278

Thank you for your amazing paper,

I am trying to evaluate CLIP with RN50x16 on ImageNet,
output = model.encode_image(test_image)
but get error:
File "", line 1, in <cell line: 1>
output = model.encode_image(test_image)
File "/home/user/anaconda3/envs/yolov5_4/lib/python3.8/site-packages/clip/model.py", line 337, in encode_image
return self.visual(image.type(self.dtype))
File "/home/user/anaconda3/envs/yolov5_4/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/home/user/anaconda3/envs/yolov5_4/lib/python3.8/site-packages/clip/model.py", line 148, in forward
x = self.attnpool(x)
File "/home/user/anaconda3/envs/yolov5_4/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl
return forward_call(*input, **kwargs)
File "/home/user/anaconda3/envs/yolov5_4/lib/python3.8/site-packages/clip/model.py", line 69, in forward
x = x + self.positional_embedding[:, None, :].to(x.dtype) # (HW+1)NC
RuntimeError: The size of tensor a (50) must match the size of tensor b (145) at non-singleton dimension 0

Thanks

Originally created by @euminds on GitHub (Jul 31, 2022). Original GitHub issue: https://github.com/openai/CLIP/issues/278 Thank you for your amazing paper, I am trying to evaluate CLIP with RN50x16 on ImageNet, output = model.encode_image(test_image) but get error: File "<ipython-input-8-7e81ca6ebc39>", line 1, in <cell line: 1> output = model.encode_image(test_image) File "/home/user/anaconda3/envs/yolov5_4/lib/python3.8/site-packages/clip/model.py", line 337, in encode_image return self.visual(image.type(self.dtype)) File "/home/user/anaconda3/envs/yolov5_4/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, **kwargs) File "/home/user/anaconda3/envs/yolov5_4/lib/python3.8/site-packages/clip/model.py", line 148, in forward x = self.attnpool(x) File "/home/user/anaconda3/envs/yolov5_4/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, **kwargs) File "/home/user/anaconda3/envs/yolov5_4/lib/python3.8/site-packages/clip/model.py", line 69, in forward x = x + self.positional_embedding[:, None, :].to(x.dtype) # (HW+1)NC RuntimeError: The size of tensor a (50) must match the size of tensor b (145) at non-singleton dimension 0 Thanks
Author
Owner

@everye commented on GitHub (Oct 10, 2022):

@euminds The input_resolution is 384384, not 224224.

<!-- gh-comment-id:1272863351 --> @everye commented on GitHub (Oct 10, 2022): @euminds The input_resolution is 384*384, not 224*224.
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#241
No description provided.