Downloads · 30 days
0
ai-forever/ru-clip
ru-clip is a machine learning model from ai-forever. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Disclaimer: The code for using model you can found here. The ruCLIP model was developed by researchers at SberDevices and Sber AI based on origin OpenAI paper. The model uses a ViT-B/32 Transformer architecture (initi…
Downloads · 30 days
0
Access
Public
Updated Dec 24, 2021
Repo size
3.2 GB
Likes
3
Public
Click a slice to open those files.
.bin2.3 GB · 72%
From the Hugging Face model README
Disclaimer: The code for using model you can found here.
The ruCLIP model was developed by researchers at SberDevices and Sber AI based on origin OpenAI paper.
The model uses a ViT-B/32 Transformer architecture (initialized from OpenAI checkpoint and freezed while training) as an image encoder and uses ruGPT3Small as a text encoder. These encoders are trained to maximize the similarity of (image, text) pairs via a contrastive loss.
Our habr post.
Code for using model you can obtain in our repo.
from clip.evaluate.utils import (
get_text_batch, get_image_batch, get_tokenizer,
show_test_images, load_weights_only
)
import torch
# Load model and tokenizer
model, args = load_weights_only("ViT-B/32-small")
model = model.cuda().float().eval()
tokenizer = get_tokenizer()
# Load test images and prepare for model
images, texts = show_test_images(args)
input_ids, attention_mask = get_text_batch(["Это " + desc for desc in texts], tokenizer, args)
img_input = get_image_batch(images, args.img_transform, args)
# Call model
with torch.no_grad():
logits_per_image, logits_per_text = model(
img_input={"x": img_input},
text_input={"x": input_ids, "attention_mask": attention_mask}
)
We evaluate our model on CIFAR100 and CIFAR10 datasets.
zero-shot classification CIFAR100 top1 accuracy 0.4057; top5 accuracy 0.6975.
zero-shot classification CIFAR10 top1 accuracy 0.7803; top5 accuracy 0.9834.