[GH-ISSUE #172] Get different image_features in different environment? #150

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

Originally created by @MagicCodess on GitHub (Nov 4, 2021).
Original GitHub issue: https://github.com/openai/CLIP/issues/172

`import torch
import clip
from PIL import Image

device = "cuda" if torch.cuda.is_available() else "cpu"
model, preprocess = clip.load("ViT-B/32", device=device)

image = preprocess(Image.open("CLIP.png")).unsqueeze(0).to(device)
text = clip.tokenize(["a diagram", "a dog", "a cat"]).to(device)

with torch.no_grad():
image_features = model.encode_image(image)`

This feautures are different in different environment, is there a method to fix it?

Originally created by @MagicCodess on GitHub (Nov 4, 2021). Original GitHub issue: https://github.com/openai/CLIP/issues/172 `import torch import clip from PIL import Image device = "cuda" if torch.cuda.is_available() else "cpu" model, preprocess = clip.load("ViT-B/32", device=device) image = preprocess(Image.open("CLIP.png")).unsqueeze(0).to(device) text = clip.tokenize(["a diagram", "a dog", "a cat"]).to(device) with torch.no_grad(): image_features = model.encode_image(image)` This feautures are different in different environment, is there a method to fix it?
Author
Owner

@jongwook commented on GitHub (Nov 16, 2021):

Unfortunately there are slight numerical differences depending on which hardware the model was run on. See #114 and #13.

<!-- gh-comment-id:969672618 --> @jongwook commented on GitHub (Nov 16, 2021): Unfortunately there are slight numerical differences depending on which hardware the model was run on. See #114 and #13.
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#150
No description provided.