nmndeep commited on
Commit
1306acb
·
verified ·
1 Parent(s): d14f9d0

from authentic CLIPS

Browse files

Everything copied from clip-s barring the .bin and .safetensors

README.md CHANGED
@@ -1,8 +1,47 @@
1
  ---
2
- tags:
3
- - clip
4
- library_name: open_clip
5
- pipeline_tag: zero-shot-image-classification
6
- license: mit
7
  ---
8
- # Model card for CLIC-CLIPS-ViT-L-14-224-PixelProse
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - UCSC-VLAA/Recap-DataComp-1B
 
 
5
  ---
6
+ # Model Card for ViT-L-14-CLIPS-224-Recap-DataComp-1B
7
+
8
+ ## Model Details
9
+
10
+ <!-- Provide the basic links for the model. -->
11
+
12
+ - **Repository:** https://github.com/UCSC-VLAA/CLIPS
13
+ - **Paper:** https://arxiv.org/abs/2411.16828
14
+ - **Project Page:** https://ucsc-vlaa.github.io/CLIPS/
15
+
16
+ ## Model Usage
17
+ ### With OpenCLIP
18
+ #### Note: We made modifications to the tokenizer implementation in open_clip/tokenizer.py.
19
+ #### For more details, refer to https://github.com/UCSC-VLAA/CLIPS.
20
+
21
+ ```
22
+ import torch
23
+ import torch.nn.functional as F
24
+ from urllib.request import urlopen
25
+ from PIL import Image
26
+ from open_clip import create_model_from_pretrained, get_tokenizer
27
+
28
+ model, preprocess = create_model_from_pretrained('hf-hub:UCSC-VLAA/ViT-L-14-CLIPS-224-Recap-DataComp-1B')
29
+ tokenizer = get_tokenizer('hf-hub:UCSC-VLAA/ViT-L-14-CLIPS-224-Recap-DataComp-1B')
30
+
31
+ image = Image.open(urlopen(
32
+ 'https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/beignets-task-guide.png'
33
+ ))
34
+ image = preprocess(image).unsqueeze(0)
35
+
36
+ text = tokenizer(["a diagram", "a dog", "a cat", "a beignet"], context_length=model.context_length)
37
+
38
+ with torch.no_grad(), torch.cuda.amp.autocast():
39
+ image_features = model.encode_image(image)
40
+ text_features = model.encode_text(text)
41
+ image_features = F.normalize(image_features, dim=-1)
42
+ text_features = F.normalize(text_features, dim=-1)
43
+
44
+ text_probs = (100.0 * image_features @ text_features.T).softmax(dim=-1)
45
+
46
+ print("Label probs:", text_probs) # prints: [[0., 0., 0., 1.0]]
47
+ ```
open_clip_config.json CHANGED
@@ -10,8 +10,8 @@
10
  "pool_type": "avg",
11
  "final_ln_after_pool": true,
12
  "norm_kwargs": {
13
- "eps": 1e-06
14
- }
15
  },
16
  "text_cfg": {
17
  "context_length": 80,
@@ -29,22 +29,22 @@
29
  "approximate": "tanh"
30
  },
31
  "norm_kwargs": {
32
- "eps": 1e-06
33
- }
34
  }
35
  },
36
  "preprocess_cfg": {
37
  "mean": [
38
- 0.48145466,
39
- 0.4578275,
40
- 0.40821073
41
  ],
42
  "std": [
43
- 0.26862954,
44
- 0.26130258,
45
- 0.27577711
46
  ],
47
- "interpolation": "bicubic",
48
- "resize_mode": "shortest"
49
  }
50
  }
 
10
  "pool_type": "avg",
11
  "final_ln_after_pool": true,
12
  "norm_kwargs": {
13
+ "eps": 1e-6
14
+ }
15
  },
16
  "text_cfg": {
17
  "context_length": 80,
 
29
  "approximate": "tanh"
30
  },
31
  "norm_kwargs": {
32
+ "eps": 1e-6
33
+ }
34
  }
35
  },
36
  "preprocess_cfg": {
37
  "mean": [
38
+ 0.485,
39
+ 0.456,
40
+ 0.406
41
  ],
42
  "std": [
43
+ 0.229,
44
+ 0.224,
45
+ 0.225
46
  ],
47
+ "interpolation": "bilinear",
48
+ "resize_mode": "squash"
49
  }
50
  }
special_tokens_map.json CHANGED
@@ -1,6 +1,7 @@
1
  {
2
- "bos_token": "<|startoftext|>",
3
- "eos_token": "<|endoftext|>",
4
- "pad_token": "<|endoftext|>",
5
- "unk_token": "<|endoftext|>"
 
6
  }
 
1
  {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
  }
tokenizer.json CHANGED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json CHANGED
@@ -1,31 +1,56 @@
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": true,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  "rstrip": false,
17
  "single_word": false,
18
  "special": true
19
  }
20
  },
21
- "additional_special_tokens": [],
22
- "bos_token": "<|startoftext|>",
23
- "clean_up_tokenization_spaces": true,
24
  "do_lower_case": true,
25
- "eos_token": "<|endoftext|>",
26
- "errors": "replace",
27
- "model_max_length": 77,
28
- "pad_token": "<|endoftext|>",
29
- "tokenizer_class": "CLIPTokenizer",
30
- "unk_token": "<|endoftext|>"
 
 
 
31
  }
 
1
  {
 
2
  "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
  "lstrip": false,
6
+ "normalized": false,
7
  "rstrip": false,
8
  "single_word": false,
9
  "special": true
10
  },
11
+ "100": {
12
+ "content": "[UNK]",
13
  "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
  "rstrip": false,
40
  "single_word": false,
41
  "special": true
42
  }
43
  },
44
+ "clean_up_tokenization_spaces": false,
45
+ "cls_token": "[CLS]",
 
46
  "do_lower_case": true,
47
+ "extra_special_tokens": {},
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 512,
50
+ "pad_token": "[PAD]",
51
+ "sep_token": "[SEP]",
52
+ "strip_accents": null,
53
+ "tokenize_chinese_chars": true,
54
+ "tokenizer_class": "BertTokenizer",
55
+ "unk_token": "[UNK]"
56
  }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff