Downloads · 30 days
4
1% of all-time downloads
UCSC-VLAA/ViT-H-14-CLIPS-224-Recap-DataComp-1B
ViT-H-14-CLIPS-224-Recap-DataComp-1B is a machine learning model from UCSC-VLAA. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for open_clip. The card lists the license as apache-2.0.
- Repository: https://github.com/UCSC-VLAA/CLIPS - Paper: https://arxiv.org/abs/2411.16828 - Project Page: https://ucsc-vlaa.github.io/CLIPS/
Downloads · 30 days
4
1% of all-time downloads
All-time downloads
451
Public
Repo size
3.9 GB
Likes
0
Public
Click a slice to open those files.
.bin3.9 GB · 100%
From the Hugging Face model README
import torch
import torch.nn.functional as F
from urllib.request import urlopen
from PIL import Image
from open_clip import create_model_from_pretrained, get_tokenizer
model, preprocess = create_model_from_pretrained('hf-hub:UCSC-VLAA/ViT-H-14-CLIPS-224-Recap-DataComp-1B')
tokenizer = get_tokenizer('hf-hub:UCSC-VLAA/ViT-H-14-CLIPS-224-Recap-DataComp-1B')
image = Image.open(urlopen(
'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
))
image = preprocess(image).unsqueeze(0)
text = tokenizer(["a diagram", "a dog", "a cat", "a beignet"], context_length=model.context_length)
with torch.no_grad(), torch.cuda.amp.autocast():
image_features = model.encode_image(image)
text_features = model.encode_text(text)
image_features = F.normalize(image_features, dim=-1)
text_features = F.normalize(text_features, dim=-1)
text_probs = (100.0 * image_features @ text_features.T).softmax(dim=-1)
print("Label probs:", text_probs) # prints: [[0., 0., 0., 1.0]]