Views
No views yet
zero-shot-image-classification: https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.ZeroShotImageClassificationPipeline
1from PIL import Image
2import requests
3
4from transformers import CLIPProcessor, CLIPModel
5
6model = CLIPModel.from_pretrained("wkcn/TinyCLIP-ViT-8M-16-Text-3M-YFCC15M")
7processor = CLIPProcessor.from_pretrained("wkcn/TinyCLIP-ViT-8M-16-Text-3M-YFCC15M")
8
9url = "http://images.cocodataset.org/val2017/000000039769.jpg"
10image = Image.open(requests.get(url, stream=True).raw)
11
12inputs = processor(text=["a photo of a cat", "a photo of a dog"], images=image, return_tensors="pt", padding=True)
13
14outputs = model(**inputs)
15logits_per_image = outputs.logits_per_image # this is the image-text similarity score
16probs = logits_per_image.softmax(dim=1) # we can take the softmax to get the label probabilities
| Model | Weight inheritance | Pretrain | IN-1K Acc@1(%) | MACs(G) | Throughput(pairs/s) | Link |
|---|---|---|---|---|---|---|
| TinyCLIP ViT-39M/16 Text-19M | manual | YFCC-15M | 63.5 | 9.5 | 1,469 | Model |
| TinyCLIP ViT-8M/16 Text-3M | manual | YFCC-15M | 41.1 | 2.0 | 4,150 | Model |
| TinyCLIP ResNet-30M Text-29M | manual | LAION-400M | 59.1 | 6.9 | 1,811 | Model |
| TinyCLIP ResNet-19M Text-19M | manual | LAION-400M | 56.4 | 4.4 | 3,024 | Model |
| TinyCLIP ViT-61M/32 Text-29M | manual | LAION-400M | 62.4 | 5.3 | 3,191 | Model |
| TinyCLIP ViT-40M/32 Text-19M | manual | LAION-400M | 59.8 | 3.5 | 4,641 | Model |
| TinyCLIP ViT-63M/32 Text-31M | auto | LAION-400M | 63.9 | 5.6 | 2,905 | Model |
| TinyCLIP ViT-45M/32 Text-18M | auto | LAION-400M | 61.4 | 3.7 | 3,682 | Model |
| TinyCLIP ViT-22M/32 Text-10M | auto | LAION-400M | 53.7 | 1.9 | 5,504 | Model |
| TinyCLIP ViT-63M/32 Text-31M | auto | LAION+YFCC-400M | 64.5 | 5.6 | 2,909 | Model |
| TinyCLIP ViT-45M/32 Text-18M | auto | LAION+YFCC-400M | 62.7 | 1.9 | 3,685 | Model |
1@InProceedings{tinyclip,
2 title = {TinyCLIP: CLIP Distillation via Affinity Mimicking and Weight Inheritance},
3 author = {Wu, Kan and Peng, Houwen and Zhou, Zhenghong and Xiao, Bin and Liu, Mengchen and Yuan, Lu and Xuan, Hong and Valenzuela, Michael and Chen, Xi (Stephen) and Wang, Xinggang and Chao, Hongyang and Hu, Han},
4 booktitle = {Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV)},
5 month = {October},
6 year = {2023},
7 pages = {21970-21980}
8}