You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Qs: (1) we are calculate image and text features, but they are not being used in the code.
(2) Are the arguments to the model (image,text) or (image_feature, text_features)
Hello,
I see the following example on the page:
Qs: (1) we are calculate image and text features, but they are not being used in the code.
(2) Are the arguments to the model (image,text) or (image_feature, text_features)
Thanks
mport 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)
text_features = model.encode_text(text)
print("Label probs:", probs) # prints: [[0.9927937 0.00421068 0.00299572]]
The text was updated successfully, but these errors were encountered: