Upload processor
Browse files- preprocessor_config.json +36 -0
- processing_vlm.py +39 -0
- processor_config.json +6 -0
- special_tokens_map.json +30 -0
- tokenizer.json +0 -0
- tokenizer.model +3 -0
- tokenizer_config.json +49 -0
preprocessor_config.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"auto_map": {
|
| 3 |
+
"AutoProcessor": "processing_vlm.VLMProcessor"
|
| 4 |
+
},
|
| 5 |
+
"crop_size": {
|
| 6 |
+
"height": 336,
|
| 7 |
+
"width": 336
|
| 8 |
+
},
|
| 9 |
+
"data_format": "channels_first",
|
| 10 |
+
"default_to_square": false,
|
| 11 |
+
"device": null,
|
| 12 |
+
"do_center_crop": true,
|
| 13 |
+
"do_convert_rgb": true,
|
| 14 |
+
"do_normalize": true,
|
| 15 |
+
"do_rescale": true,
|
| 16 |
+
"do_resize": true,
|
| 17 |
+
"image_mean": [
|
| 18 |
+
0.48145466,
|
| 19 |
+
0.4578275,
|
| 20 |
+
0.40821073
|
| 21 |
+
],
|
| 22 |
+
"image_processor_type": "CLIPImageProcessorFast",
|
| 23 |
+
"image_std": [
|
| 24 |
+
0.26862954,
|
| 25 |
+
0.26130258,
|
| 26 |
+
0.27577711
|
| 27 |
+
],
|
| 28 |
+
"input_data_format": null,
|
| 29 |
+
"processor_class": "VLMProcessor",
|
| 30 |
+
"resample": 3,
|
| 31 |
+
"rescale_factor": 0.00392156862745098,
|
| 32 |
+
"return_tensors": null,
|
| 33 |
+
"size": {
|
| 34 |
+
"shortest_edge": 336
|
| 35 |
+
}
|
| 36 |
+
}
|
processing_vlm.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any
|
| 2 |
+
|
| 3 |
+
from transformers import AutoImageProcessor, AutoProcessor, AutoTokenizer, ProcessorMixin
|
| 4 |
+
|
| 5 |
+
from .configuration_vlm import VLMConfig
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class VLMProcessor(ProcessorMixin):
|
| 9 |
+
attributes: list[str] = ["image_processor", "tokenizer"]
|
| 10 |
+
image_processor_class: str = "AutoImageProcessor"
|
| 11 |
+
tokenizer_class: str = "AutoTokenizer"
|
| 12 |
+
|
| 13 |
+
def __init__(
|
| 14 |
+
self,
|
| 15 |
+
image_processor: AutoImageProcessor = None,
|
| 16 |
+
tokenizer: AutoTokenizer = None,
|
| 17 |
+
**kwargs: Any,
|
| 18 |
+
):
|
| 19 |
+
super().__init__(image_processor, tokenizer, **kwargs)
|
| 20 |
+
|
| 21 |
+
@classmethod
|
| 22 |
+
def from_names(cls, image_processor_name: str, tokenizer_name: str, **kwargs: Any):
|
| 23 |
+
image_processor_args = {
|
| 24 |
+
k: v for k, v in kwargs.items() if k in ["trust_remote_code", "use_fast"]
|
| 25 |
+
}
|
| 26 |
+
tokenizer_args = {
|
| 27 |
+
k: v
|
| 28 |
+
for k, v in kwargs.items()
|
| 29 |
+
if k in ["trust_remote_code", "use_fast", "model_max_length", "padding_side"]
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
tokenizer = AutoTokenizer.from_pretrained(tokenizer_name, **tokenizer_args)
|
| 33 |
+
image_processor = AutoImageProcessor.from_pretrained(
|
| 34 |
+
image_processor_name, **image_processor_args
|
| 35 |
+
)
|
| 36 |
+
return cls(image_processor=image_processor, tokenizer=tokenizer)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
AutoProcessor.register(VLMConfig, VLMProcessor)
|
processor_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"auto_map": {
|
| 3 |
+
"AutoProcessor": "processing_vlm.VLMProcessor"
|
| 4 |
+
},
|
| 5 |
+
"processor_class": "VLMProcessor"
|
| 6 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<s>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"eos_token": {
|
| 10 |
+
"content": "</s>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": {
|
| 17 |
+
"content": "<unk>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
},
|
| 23 |
+
"unk_token": {
|
| 24 |
+
"content": "<unk>",
|
| 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.model
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9e556afd44213b6bd1be2b850ebbbd98f5481437a8021afaf58ee7fb1818d347
|
| 3 |
+
size 499723
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_bos_token": true,
|
| 3 |
+
"add_eos_token": false,
|
| 4 |
+
"add_prefix_space": null,
|
| 5 |
+
"added_tokens_decoder": {
|
| 6 |
+
"0": {
|
| 7 |
+
"content": "<unk>",
|
| 8 |
+
"lstrip": false,
|
| 9 |
+
"normalized": false,
|
| 10 |
+
"rstrip": false,
|
| 11 |
+
"single_word": false,
|
| 12 |
+
"special": true
|
| 13 |
+
},
|
| 14 |
+
"1": {
|
| 15 |
+
"content": "<s>",
|
| 16 |
+
"lstrip": false,
|
| 17 |
+
"normalized": false,
|
| 18 |
+
"rstrip": false,
|
| 19 |
+
"single_word": false,
|
| 20 |
+
"special": true
|
| 21 |
+
},
|
| 22 |
+
"2": {
|
| 23 |
+
"content": "</s>",
|
| 24 |
+
"lstrip": false,
|
| 25 |
+
"normalized": false,
|
| 26 |
+
"rstrip": false,
|
| 27 |
+
"single_word": false,
|
| 28 |
+
"special": true
|
| 29 |
+
}
|
| 30 |
+
},
|
| 31 |
+
"auto_map": {
|
| 32 |
+
"AutoProcessor": "processing_vlm.VLMProcessor"
|
| 33 |
+
},
|
| 34 |
+
"bos_token": "<s>",
|
| 35 |
+
"clean_up_tokenization_spaces": false,
|
| 36 |
+
"eos_token": "</s>",
|
| 37 |
+
"extra_special_tokens": {},
|
| 38 |
+
"legacy": false,
|
| 39 |
+
"model_max_length": 2048,
|
| 40 |
+
"pad_token": "<unk>",
|
| 41 |
+
"padding_side": "left",
|
| 42 |
+
"processor_class": "VLMProcessor",
|
| 43 |
+
"sp_model_kwargs": {},
|
| 44 |
+
"spaces_between_special_tokens": false,
|
| 45 |
+
"tokenizer_class": "LlamaTokenizer",
|
| 46 |
+
"torch_dtype": "auto",
|
| 47 |
+
"unk_token": "<unk>",
|
| 48 |
+
"use_default_system_prompt": false
|
| 49 |
+
}
|