[GH-ISSUE #238] RN50x64 Model encodes image failed with size dismatch #206

Closed
opened 2026-10-31 21:12:26 +00:00 by bsakaguchi · 2 comments
Owner

Originally created by @Wayne-Mai on GitHub (Apr 27, 2022).
Original GitHub issue: https://github.com/openai/CLIP/issues/238

Hi, I am using "RN50x64" clip model to encode images. Specifically, I use image_z = self.clip_model.encode_image(pred_rgb)
to encode pred_rgb of shape [8,3,224,224] but failed with:

 File "~/anaconda3/envs/text/lib/python3.9/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 (197) at non-singleton dimension 0
Originally created by @Wayne-Mai on GitHub (Apr 27, 2022). Original GitHub issue: https://github.com/openai/CLIP/issues/238 Hi, I am using "RN50x64" clip model to encode images. Specifically, I use `image_z = self.clip_model.encode_image(pred_rgb)` to encode `pred_rgb` of shape `[8,3,224,224]` but failed with: ``` File "~/anaconda3/envs/text/lib/python3.9/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 (197) at non-singleton dimension 0 ```
Author
Owner

@robertodessi commented on GitHub (Jun 3, 2022):

Hi, I found a similar error. Were you able to fix it in the end?

<!-- gh-comment-id:1146170770 --> @robertodessi commented on GitHub (Jun 3, 2022): Hi, I found a similar error. Were you able to fix it in the end?
Author
Owner

@forminju commented on GitHub (Dec 30, 2023):

hi, same problem. did you solve this problem?

<!-- gh-comment-id:1872439700 --> @forminju commented on GitHub (Dec 30, 2023): hi, same problem. did you solve this problem?
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#206
No description provided.