Model card for CLIP-KD ViT-T-16 distilled from CLIP-ViT-B-16 pretrained from CC3M and CC12M
Github source: https://github.com/winycg/CLIP-KD
From weight: ViT-B-16_cc3m_12m_kd_ViT-T-16_cc3m_12m_ep32.pt
The weight of this model was modified from open_clip
format to be compatible with huggingface CLIP
library.
Table of Contents
Model Details
Model Description
A CLIP ViT-T/16 model trained with the CC3M and CC12M (https://github.com/google-research-datasets/conceptual-12m) using OpenCLIP (https://github.com/mlfoundations/open_clip).
Uses
This model weights can be downloaded using both open_clip
and transformer CLIP
library (currently at version 4.44.0). This model is a CLIP-based model, which is typically used for tasks like zero-shot image classification, text-image retrieval, and more.
Using open_clip
Using
from transformers import CLIPProcessor, CLIPModel
from PIL import Image
import requests
# Load the model and processor
model_name = "romrawinjp/clip-kd_ViT-T-16_KD-CC3M12M"
model = CLIPModel.from_pretrained(model_name)
processor = CLIPProcessor.from_pretrained(model_name)
# Load an image from a URL or local file
url = "https://example.com/path/to/your/image.jpg"
# Define the text labels for classification
text_labels = ["a photo of a cat", "a photo of a dog", "a photo of a bird"]
# Process the image and text
inputs = processor(text=text_labels, images=image, return_tensors="pt", padding=True)
# Get the model's predictions
outputs = model(**inputs)
logits_per_image = outputs.logits_per_image # This is the image-text similarity score
probs = logits_per_image.softmax(dim=1) # Convert logits to probabilities
# Print the results
for label, prob in zip(text_labels, probs[0]):
print(f"Label: {label}, Probability: {prob.item():.4f}")
Zero-shot image classification example
Zero-shot image classification, image and text retrieval, among others.
Downstream Use
Image classification and other image task fine-tuning, linear probe image classification, image generation guiding and conditioning, among others.
Out-of-Scope Use
As per the OpenAI models,
Any deployed use case of the model - whether commercial or not - is currently out of scope. Non-deployed use cases such as image search in a constrained environment, are also not recommended unless there is thorough in-domain testing of the model with a specific, fixed class taxonomy. This is because our safety assessment demonstrated a high need for task specific testing especially given the variability of CLIP’s performance with different class taxonomies. This makes untested and unconstrained deployment of the model in any use case currently potentially harmful.
Certain use cases which would fall under the domain of surveillance and facial recognition are always out-of-scope regardless of performance of the model. This is because the use of artificial intelligence for tasks such as these can be premature currently given the lack of testing norms and checks to ensure its fair use.
Training Details
Training Data
This model was trained with the 1.4 Billion samples of the DataComp-1B dataset (https://arxiv.org/abs/2304.14108).
IMPORTANT NOTE: The motivation behind dataset creation is to democratize research and experimentation around large-scale multi-modal model training and handling of uncurated, large-scale datasets crawled from publically available internet. Our recommendation is therefore to use the dataset for research purposes. Be aware that this large-scale dataset is uncurated. Keep in mind that the uncurated nature of the dataset means that collected links may lead to strongly discomforting and disturbing content for a human viewer. Therefore, please use the demo links with caution and at your own risk. It is possible to extract a “safe” subset by filtering out samples based on the safety tags (using a customized trained NSFW classifier that we built). While this strongly reduces the chance for encountering potentially harmful content when viewing, we cannot entirely exclude the possibility for harmful content being still present in safe mode, so that the warning holds also there. We think that providing the dataset openly to broad research and other interested communities will allow for transparent investigation of benefits that come along with training large-scale models as well as pitfalls and dangers that may stay unreported or unnoticed when working with closed large datasets that remain restricted to a small community. Providing our dataset openly, we however do not recommend using it for creating ready-to-go industrial products, as the basic research about general properties and safety of such large-scale models, which we would like to encourage with this release, is still in progress.
Training Procedure
Please see https://arxiv.org/abs/2304.14108.
Evaluation
Evaluation done on 38 datasets, using the DataComp repo and the LAION CLIP Benchmark.
Testing Data, Factors & Metrics
Testing Data
The testing is performed on a suite of 38 datasets. See our paper for more details (https://arxiv.org/abs/2304.14108).
Results
The model achieves a 73.5% zero-shot top-1 accuracy on ImageNet-1k. See our paper for more details and results (https://arxiv.org/abs/2304.14108).
Acknowledgements
Acknowledging stability.ai for the compute used to train this model.
Citation
BibTeX:
DataComp
@article{datacomp,
title={DataComp: In search of the next generation of multimodal datasets},
author={Samir Yitzhak Gadre, Gabriel Ilharco, Alex Fang, Jonathan Hayase, Georgios Smyrnis, Thao Nguyen, Ryan Marten, Mitchell Wortsman, Dhruba Ghosh, Jieyu Zhang, Eyal Orgad, Rahim Entezari, Giannis Daras, Sarah Pratt, Vivek Ramanujan, Yonatan Bitton, Kalyani Marathe, Stephen Mussmann, Richard Vencu, Mehdi Cherti, Ranjay Krishna, Pang Wei Koh, Olga Saukh, Alexander Ratner, Shuran Song, Hannaneh Hajishirzi, Ali Farhadi, Romain Beaumont, Sewoong Oh, Alex Dimakis, Jenia Jitsev, Yair Carmon, Vaishaal Shankar, Ludwig Schmidt},
journal={arXiv preprint arXiv:2304.14108},
year={2023}
}
OpenAI CLIP paper
@inproceedings{Radford2021LearningTV,
title={Learning Transferable Visual Models From Natural Language Supervision},
author={Alec Radford and Jong Wook Kim and Chris Hallacy and A. Ramesh and Gabriel Goh and Sandhini Agarwal and Girish Sastry and Amanda Askell and Pamela Mishkin and Jack Clark and Gretchen Krueger and Ilya Sutskever},
booktitle={ICML},
year={2021}
}
OpenCLIP software
@software{ilharco_gabriel_2021_5143773,
author = {Ilharco, Gabriel and
Wortsman, Mitchell and
Wightman, Ross and
Gordon, Cade and
Carlini, Nicholas and
Taori, Rohan and
Dave, Achal and
Shankar, Vaishaal and
Namkoong, Hongseok and
Miller, John and
Hajishirzi, Hannaneh and
Farhadi, Ali and
Schmidt, Ludwig},
title = {OpenCLIP},
month = jul,
year = 2021,
note = {If you use this software, please cite it as below.},
publisher = {Zenodo},
version = {0.1},
doi = {10.5281/zenodo.5143773},
url = {https://doi.org/10.5281/zenodo.5143773}
}
How to Get Started with the Model
- Downloads last month
- 18