Views
No views yet
laion/CLIP-ViT-H-14-laion2B-s32B-b79K| Model | Unpert. (UA) | Unpert. (ENG) | SSA-Dict | SSA-GPT-4o | SSA-Hybrid |
|---|---|---|---|---|---|
| OpenCLIP | 32.1 / 54.3 | 41.6 / 65.7 | 7.6 / 39.3 | 10.9 / 44.0 | 16.8 / 49.0 |
| Synonym FT | 39.07 / 63.76 | 45.77 / 69.79 | 19.78 / 51.57 | 25.14 / 56.36 | 28.08 / 58.94 |
ukr-clip-vit-h-14-frozen-xlm-roberta-large-laion5B-s13B-b90k.pt1import torch
2from PIL import Image
3import open_clip
4
5device = "cuda" if torch.cuda.is_available() else "cpu"
6
7pretrained_path = "ukr-clip-vit-h-14-frozen-xlm-roberta-large-laion5B-s13B-b90k/ukr-clip-vit-h-14-frozen-xlm-roberta-large-laion5B-s13B-b90k.pt"
8
9# Load model & preprocessing
10model, _, preprocess = open_clip.create_model_and_transforms('xlm-roberta-large-ViT-H-14', pretrained=pretrained_path)
11model.to(device)
12model.eval()
13tokenizer = open_clip.get_tokenizer('xlm-roberta-large-ViT-H-14')
14
15# Example inputs
16image = preprocess(Image.open("ukr-clip-vit-h-14-frozen-xlm-roberta-large-laion5B-s13B-b90k/dog.jpg")).unsqueeze(0)
17text = tokenizer(["діаграма", "собака", "кіт"])
18
19# Encode & normalize
20with torch.no_grad(), torch.autocast("cuda"):
21 image_features = model.encode_image(image.to(device))
22 text_features = model.encode_text(text.to(device))
23 image_features /= image_features.norm(dim=-1, keepdim=True)
24 text_features /= text_features.norm(dim=-1, keepdim=True)
25
26# Compute similarity
27text_probs = (100.0 * image_features @ text_features.T).softmax(dim=-1)
28print("Label probs:", text_probs)