Transformers
shunk031 commited on
Commit
c2d916f
·
verified ·
1 Parent(s): e4696b4

Upload processor

Browse files
preprocessor_config.json CHANGED
@@ -1,4 +1,7 @@
1
  {
 
 
 
2
  "crop_size": {
3
  "height": 224,
4
  "width": 224
@@ -19,7 +22,7 @@
19
  0.26130258,
20
  0.27577711
21
  ],
22
- "processor_class": "CLIPProcessor",
23
  "resample": 3,
24
  "rescale_factor": 0.00392156862745098,
25
  "size": {
 
1
  {
2
+ "auto_map": {
3
+ "AutoProcessor": "processing_longclip.LongCLIPProcessor"
4
+ },
5
  "crop_size": {
6
  "height": 224,
7
  "width": 224
 
22
  0.26130258,
23
  0.27577711
24
  ],
25
+ "processor_class": "LongCLIPProcessor",
26
  "resample": 3,
27
  "rescale_factor": 0.00392156862745098,
28
  "size": {
processing_longclip.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Union
2
+
3
+ from transformers import CLIPProcessor, CLIPTokenizer, CLIPTokenizerFast
4
+
5
+
6
+ class LongCLIPProcessor(CLIPProcessor):
7
+ tokenizer: Union[CLIPTokenizer, CLIPTokenizerFast]
8
+
9
+ def __call__(
10
+ self, text=None, short_text=None, images=None, return_tensors=None, **kwargs
11
+ ):
12
+ encoding = super().__call__(text, images, return_tensors, **kwargs)
13
+ if short_text is not None:
14
+ short_text_encoding = self.tokenizer(
15
+ short_text, return_tensors=return_tensors, **kwargs
16
+ )
17
+ encoding["short_input_ids"] = short_text_encoding.input_ids
18
+ encoding["short_attention_mask"] = short_text_encoding.attention_mask
19
+
20
+ return encoding
processor_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "auto_map": {
3
+ "AutoProcessor": "processing_longclip.LongCLIPProcessor"
4
+ },
5
+ "processor_class": "LongCLIPProcessor"
6
+ }
tokenizer_config.json CHANGED
@@ -18,6 +18,9 @@
18
  "special": true
19
  }
20
  },
 
 
 
21
  "bos_token": "<|startoftext|>",
22
  "clean_up_tokenization_spaces": false,
23
  "do_lower_case": true,
@@ -26,7 +29,7 @@
26
  "extra_special_tokens": {},
27
  "model_max_length": 248,
28
  "pad_token": "<|endoftext|>",
29
- "processor_class": "CLIPProcessor",
30
  "tokenizer_class": "CLIPTokenizer",
31
  "unk_token": "<|endoftext|>"
32
  }
 
18
  "special": true
19
  }
20
  },
21
+ "auto_map": {
22
+ "AutoProcessor": "processing_longclip.LongCLIPProcessor"
23
+ },
24
  "bos_token": "<|startoftext|>",
25
  "clean_up_tokenization_spaces": false,
26
  "do_lower_case": true,
 
29
  "extra_special_tokens": {},
30
  "model_max_length": 248,
31
  "pad_token": "<|endoftext|>",
32
+ "processor_class": "LongCLIPProcessor",
33
  "tokenizer_class": "CLIPTokenizer",
34
  "unk_token": "<|endoftext|>"
35
  }