Views
No views yet
ViT-L-14 can be retrieved via instructions found on OpenAI's CLIP repository on Github. We provide a usage example below.multilingual-clip and clip.pip install multilingual-clip
pip install git+https://github.com/openai/CLIP.git1from multilingual_clip import pt_multilingual_clip
2import transformers
3
4texts = [
5 'Three blind horses listening to Mozart.',
6 'Älgen är skogens konung!',
7 'Wie leben Eisbären in der Antarktis?',
8 'Вы знали, что все белые медведи левши?'
9]
10model_name = 'M-CLIP/LABSE-Vit-L-14'
11
12# Load Model & Tokenizer
13model = pt_multilingual_clip.MultilingualCLIP.from_pretrained(model_name)
14tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
15
16embeddings = model.forward(texts, tokenizer)
17print("Text features shape:", embeddings.shape)1import torch
2import clip
3import requests
4from PIL import Image
5
6device = "cuda" if torch.cuda.is_available() else "cpu"
7model, preprocess = clip.load("ViT-L/14", device=device)
8
9url = "http://images.cocodataset.org/val2017/000000039769.jpg"
10image = Image.open(requests.get(url, stream=True).raw)
11image = preprocess(image).unsqueeze(0).to(device)
12
13with torch.no_grad():
14 image_features = model.encode_image(image)
15
16print("Image features shape:", image_features.shape) | Name | En | De | Es | Fr | Zh | It | Pl | Ko | Ru | Tr | Jp |
|---|---|---|---|---|---|---|---|---|---|---|---|
| OpenAI CLIP Vit-B/32 | 90.3 | - | - | - | - | - | - | - | - | - | - |
| OpenAI CLIP Vit-L/14 | 91.8 | - | - | - | - | - | - | - | - | - | - |
| OpenCLIP ViT-B-16+- | 94.3 | - | - | - | - | - | - | - | - | - | - |
| LABSE Vit-L/14 | 91.6 | 89.6 | 89.5 | 89.9 | 88.9 | 90.1 | 89.8 | 80.8 | 85.5 | 89.8 | 73.9 |
| XLM-R Large Vit-B/32 | 91.8 | 88.7 | 89.1 | 89.4 | 89.3 | 89.8 | 91.4 | 82.1 | 86.1 | 88.8 | 81.0 |
| XLM-R Vit-L/14 | 92.4 | 90.6 | 91.0 | 90.0 | 89.7 | 91.1 | 91.3 | 85.2 | 85.8 | 90.3 | 81.9 |
| XLM-R Large Vit-B/16+ | 95.0 | 93.0 | 93.6 | 93.1 | 94.0 | 93.1 | 94.4 | 89.0 | 90.0 | 93.0 | 84.2 |