Views
No views yet
pip install sentence-transformers), the usage of this model is easy:1from sentence_transformers import SentenceTransformer, util
2from PIL import Image
3
4#Load CLIP model
5model = SentenceTransformer('clip-ViT-L-14')
6
7#Encode an image:
8img_emb = model.encode(Image.open('two_dogs_in_snow.jpg'))
9
10#Encode text descriptions
11text_emb = model.encode(['Two dogs in the snow', 'A cat on a table', 'A picture of London at night'])
12
13#Compute cosine similarities
14cos_scores = util.cos_sim(img_emb, text_emb)
15print(cos_scores)| Model | Top 1 Performance |
|---|---|
| clip-ViT-B-32 | 63.3 |
| clip-ViT-B-16 | 68.1 |
| clip-ViT-L-14 | 75.4 |