Zero-Shot Image Classification
Transformers.js
ONNX
clip
noahzhy commited on
Commit
1a7ffa9
·
verified ·
1 Parent(s): 7d5600b

Upload folder using huggingface_hub

Browse files
README.md ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ widget:
4
+ - src: https://huggingface.co/datasets/mishig/sample_images/resolve/main/cat-dog-music.png
5
+ candidate_labels: playing music, playing sports
6
+ example_title: Cat & Dog
7
+ library_name: transformers.js
8
+ datasets:
9
+ - mlfoundations/datacomp_pools
10
+ pipeline_tag: zero-shot-image-classification
11
+ base_model:
12
+ - laion/CLIP-ViT-L-14-DataComp.XL-s13B-b90K
13
+ ---
14
+
15
+
16
+
17
+ # CLIP-ViT-L-14-DataComp.XL-s13B-b90K (ONNX)
18
+
19
+
20
+ This is an ONNX version of [laion/CLIP-ViT-L-14-DataComp.XL-s13B-b90K](https://huggingface.co/laion/CLIP-ViT-L-14-DataComp.XL-s13B-b90K). It was automatically converted and uploaded using [this Hugging Face Space](https://huggingface.co/spaces/onnx-community/convert-to-onnx).
21
+
22
+
23
+ ## Usage with Transformers.js
24
+
25
+
26
+ See the pipeline documentation for `zero-shot-image-classification`: https://huggingface.co/docs/transformers.js/api/pipelines#module_pipelines.ZeroShotImageClassificationPipeline
27
+
28
+
29
+ ---
30
+
31
+
32
+ # Model card for CLIP ViT-L-14 trained DataComp-1B
33
+
34
+ # Table of Contents
35
+
36
+ 1. [Model Details](#model-details)
37
+ 2. [Uses](#uses)
38
+ 3. [Training Details](#training-details)
39
+ 4. [Evaluation](#evaluation)
40
+ 5. [Acknowledgements](#acknowledgements)
41
+ 6. [Citation](#citation)
42
+ 7. [How To Get Started With the Model](#how-to-get-started-with-the-model)
43
+
44
+
45
+ # Model Details
46
+
47
+ ## Model Description
48
+
49
+ A CLIP ViT-L/14 model trained with the DataComp-1B (https://github.com/mlfoundations/datacomp) using OpenCLIP (https://github.com/mlfoundations/open_clip).
50
+
51
+ Model training done on the [stability.ai](https://stability.ai/) cluster.
52
+
53
+ # Uses
54
+
55
+ As per the original [OpenAI CLIP model card](https://github.com/openai/CLIP/blob/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1/model-card.md), this model is intended as a research output for research communities. We hope that this model will enable researchers to better understand and explore zero-shot, arbitrary image classification. We also hope it can be used for interdisciplinary studies of the potential impact of such model.
56
+
57
+ The OpenAI CLIP paper includes a discussion of potential downstream impacts to provide an example for this sort of analysis. Additionally, the DataComp paper (https://arxiv.org/abs/2304.14108) include additional discussion as it relates specifically to the training dataset.
58
+
59
+ ## Direct Use
60
+
61
+ Zero-shot image classification, image and text retrieval, among others.
62
+
63
+ ## Downstream Use
64
+
65
+ Image classification and other image task fine-tuning, linear probe image classification, image generation guiding and conditioning, among others.
66
+
67
+ ## Out-of-Scope Use
68
+
69
+ As per the OpenAI models,
70
+
71
+ **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.
72
+
73
+ 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.
74
+
75
+ # Training Details
76
+
77
+ ## Training Data
78
+
79
+ This model was trained with the 1.4 Billion samples of the DataComp-1B dataset (https://arxiv.org/abs/2304.14108).
80
+
81
+ **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.
82
+
83
+ ## Training Procedure
84
+
85
+ Please see https://arxiv.org/abs/2304.14108.
86
+
87
+ # Evaluation
88
+
89
+ Evaluation done on 38 datasets, using the [DataComp repo](https://github.com/mlfoundations/datacomp) and the [LAION CLIP Benchmark](https://github.com/LAION-AI/CLIP_benchmark).
90
+
91
+ ## Testing Data, Factors & Metrics
92
+
93
+ ### Testing Data
94
+
95
+ The testing is performed on a suite of 38 datasets. See our paper for more details (https://arxiv.org/abs/2304.14108).
96
+
97
+ ## Results
98
+
99
+ The model achieves a 79.2% zero-shot top-1 accuracy on ImageNet-1k. See our paper for more details and results (https://arxiv.org/abs/2304.14108).
100
+
101
+ # Acknowledgements
102
+
103
+ Acknowledging [stability.ai](https://stability.ai/) for the compute used to train this model.
104
+
105
+ # Citation
106
+
107
+ **BibTeX:**
108
+
109
+ DataComp
110
+ ```bibtex
111
+ @article{datacomp,
112
+ title={DataComp: In search of the next generation of multimodal datasets},
113
+ 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},
114
+ journal={arXiv preprint arXiv:2304.14108},
115
+ year={2023}
116
+ }
117
+ ```
118
+
119
+
120
+ OpenAI CLIP paper
121
+ ```
122
+ @inproceedings{Radford2021LearningTV,
123
+ title={Learning Transferable Visual Models From Natural Language Supervision},
124
+ 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},
125
+ booktitle={ICML},
126
+ year={2021}
127
+ }
128
+ ```
129
+
130
+ OpenCLIP software
131
+ ```
132
+ @software{ilharco_gabriel_2021_5143773,
133
+ author = {Ilharco, Gabriel and
134
+ Wortsman, Mitchell and
135
+ Wightman, Ross and
136
+ Gordon, Cade and
137
+ Carlini, Nicholas and
138
+ Taori, Rohan and
139
+ Dave, Achal and
140
+ Shankar, Vaishaal and
141
+ Namkoong, Hongseok and
142
+ Miller, John and
143
+ Hajishirzi, Hannaneh and
144
+ Farhadi, Ali and
145
+ Schmidt, Ludwig},
146
+ title = {OpenCLIP},
147
+ month = jul,
148
+ year = 2021,
149
+ note = {If you use this software, please cite it as below.},
150
+ publisher = {Zenodo},
151
+ version = {0.1},
152
+ doi = {10.5281/zenodo.5143773},
153
+ url = {https://doi.org/10.5281/zenodo.5143773}
154
+ }
155
+ ```
156
+
157
+ # How to Get Started with the Model
158
+
159
+ See https://github.com/mlfoundations/open_clip
config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_attn_implementation_autoset": true,
3
+ "_name_or_path": "laion/CLIP-ViT-L-14-DataComp.XL-s13B-b90K",
4
+ "architectures": [
5
+ "CLIPModel"
6
+ ],
7
+ "initializer_factor": 1.0,
8
+ "logit_scale_init_value": 2.6592,
9
+ "model_type": "clip",
10
+ "projection_dim": 768,
11
+ "text_config": {
12
+ "bos_token_id": 0,
13
+ "eos_token_id": 2,
14
+ "hidden_act": "gelu",
15
+ "hidden_size": 768,
16
+ "intermediate_size": 3072,
17
+ "model_type": "clip_text_model",
18
+ "num_attention_heads": 12,
19
+ "torch_dtype": "float32"
20
+ },
21
+ "torch_dtype": "float32",
22
+ "transformers_version": "4.49.0",
23
+ "vision_config": {
24
+ "hidden_act": "gelu",
25
+ "hidden_size": 1024,
26
+ "intermediate_size": 4096,
27
+ "model_type": "clip_vision_model",
28
+ "num_attention_heads": 16,
29
+ "num_hidden_layers": 24,
30
+ "patch_size": 14,
31
+ "torch_dtype": "float32"
32
+ }
33
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
onnx/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c785d93de1757f29621409bf6e7e62d6773db359804b8da2524d0d9358fb0099
3
+ size 1711243249
onnx/model_bnb4.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:20b1bd90102e64f1f5e9465c91fff402d550609b4b9a48571cee79b6a0f7a38e
3
+ size 376493371
onnx/model_fp16.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:397d0263c2582ff1cbfb166ba16f76be231b1a29f662f38fa560a4a3fb22409e
3
+ size 856010689
onnx/model_int8.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8b8a098f6504f1a172f874c29dbdf52082921212861f7a2c2ef344796aafd37c
3
+ size 432337400
onnx/model_q4.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:05348069af4b70f8ac802dea9d8cba38fbc1323f7e32971714d90271d1783b3b
3
+ size 400760453
onnx/model_q4f16.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1904add6a365a44c356508b1b6f280c30d04c96a115d8a9c9042af8f333a182e
3
+ size 297860793
onnx/model_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba25791d887ebcdb6abb0325c9d911173656af059443a92771efed7c0cc6f889
3
+ size 432337400
onnx/model_uint8.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba25791d887ebcdb6abb0325c9d911173656af059443a92771efed7c0cc6f889
3
+ size 432337400
preprocessor_config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "crop_size": {
3
+ "height": 224,
4
+ "width": 224
5
+ },
6
+ "do_center_crop": true,
7
+ "do_convert_rgb": true,
8
+ "do_normalize": true,
9
+ "do_rescale": true,
10
+ "do_resize": true,
11
+ "image_mean": [
12
+ 0.48145466,
13
+ 0.4578275,
14
+ 0.40821073
15
+ ],
16
+ "image_processor_type": "CLIPFeatureExtractor",
17
+ "image_std": [
18
+ 0.26862954,
19
+ 0.26130258,
20
+ 0.27577711
21
+ ],
22
+ "resample": 3,
23
+ "rescale_factor": 0.00392156862745098,
24
+ "size": {
25
+ "shortest_edge": 224
26
+ }
27
+ }
quantize_config.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "modes": [
3
+ "fp16",
4
+ "q8",
5
+ "int8",
6
+ "uint8",
7
+ "q4",
8
+ "q4f16",
9
+ "bnb4"
10
+ ],
11
+ "per_channel": true,
12
+ "reduce_range": true,
13
+ "block_size": null,
14
+ "is_symmetric": true,
15
+ "accuracy_level": null,
16
+ "quant_type": 1,
17
+ "op_block_list": null
18
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|startoftext|>",
4
+ "lstrip": false,
5
+ "normalized": true,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": false,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": {
17
+ "content": "<|endoftext|>",
18
+ "lstrip": false,
19
+ "normalized": false,
20
+ "rstrip": false,
21
+ "single_word": false
22
+ },
23
+ "unk_token": {
24
+ "content": "<|endoftext|>",
25
+ "lstrip": false,
26
+ "normalized": false,
27
+ "rstrip": false,
28
+ "single_word": false
29
+ }
30
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "49406": {
5
+ "content": "<|startoftext|>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "49407": {
13
+ "content": "<|endoftext|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ }
20
+ },
21
+ "bos_token": "<|startoftext|>",
22
+ "clean_up_tokenization_spaces": false,
23
+ "do_lower_case": true,
24
+ "eos_token": "<|endoftext|>",
25
+ "errors": "replace",
26
+ "extra_special_tokens": {},
27
+ "model_max_length": 77,
28
+ "pad_token": "<|endoftext|>",
29
+ "processor_class": "CLIPProcessor",
30
+ "tokenizer_class": "CLIPTokenizer",
31
+ "unk_token": "<|endoftext|>"
32
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff