Upload 17 files
Browse files- .gitattributes +1 -0
- added_tokens.json +29 -0
- chat_template.json +3 -0
- config.json +44 -0
- configuration_umm.py +191 -0
- image_processing_umm.py +117 -0
- merges.txt +0 -0
- model-00001-of-00002.safetensors +3 -0
- model-00002-of-00002.safetensors +3 -0
- model.safetensors.index.json +0 -0
- modeling_umm.py +0 -0
- preprocessor_config.json +31 -0
- processing_umm.py +125 -0
- processor_config.json +6 -0
- special_tokens_map.json +31 -0
- tokenizer.json +3 -0
- tokenizer_config.json +253 -0
- vocab.json +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
added_tokens.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"</tool_call>": 151658,
|
| 3 |
+
"<im_end>": 151668,
|
| 4 |
+
"<im_start>": 151667,
|
| 5 |
+
"<image>": 151665,
|
| 6 |
+
"<image_gen>": 151666,
|
| 7 |
+
"<no_mean>": 151669,
|
| 8 |
+
"<tool_call>": 151657,
|
| 9 |
+
"<|box_end|>": 151649,
|
| 10 |
+
"<|box_start|>": 151648,
|
| 11 |
+
"<|endoftext|>": 151643,
|
| 12 |
+
"<|file_sep|>": 151664,
|
| 13 |
+
"<|fim_middle|>": 151660,
|
| 14 |
+
"<|fim_pad|>": 151662,
|
| 15 |
+
"<|fim_prefix|>": 151659,
|
| 16 |
+
"<|fim_suffix|>": 151661,
|
| 17 |
+
"<|im_end|>": 151645,
|
| 18 |
+
"<|im_start|>": 151644,
|
| 19 |
+
"<|image_pad|>": 151655,
|
| 20 |
+
"<|object_ref_end|>": 151647,
|
| 21 |
+
"<|object_ref_start|>": 151646,
|
| 22 |
+
"<|quad_end|>": 151651,
|
| 23 |
+
"<|quad_start|>": 151650,
|
| 24 |
+
"<|repo_name|>": 151663,
|
| 25 |
+
"<|video_pad|>": 151656,
|
| 26 |
+
"<|vision_end|>": 151653,
|
| 27 |
+
"<|vision_pad|>": 151654,
|
| 28 |
+
"<|vision_start|>": 151652
|
| 29 |
+
}
|
chat_template.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}"
|
| 3 |
+
}
|
config.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Cheers"
|
| 4 |
+
],
|
| 5 |
+
"auto_map": {
|
| 6 |
+
"AutoConfig": "configuration_umm.UMMConfig",
|
| 7 |
+
"AutoModel": "modeling_umm.UMMModel",
|
| 8 |
+
"AutoModelForCausalLM": "modeling_umm.Cheers"
|
| 9 |
+
},
|
| 10 |
+
"vae_encoder_config": {
|
| 11 |
+
"resolution": 512
|
| 12 |
+
},
|
| 13 |
+
"vae_decoder_config": {
|
| 14 |
+
"resolution": 512
|
| 15 |
+
},
|
| 16 |
+
"vision_representation_config": {
|
| 17 |
+
"attention_dropout": 0.0,
|
| 18 |
+
"hidden_act": "gelu_pytorch_tanh",
|
| 19 |
+
"hidden_size": 1152,
|
| 20 |
+
"image_size": 512,
|
| 21 |
+
"intermediate_size": 4304,
|
| 22 |
+
"layer_norm_eps": 1e-06,
|
| 23 |
+
"model_type": "umm",
|
| 24 |
+
"num_attention_heads": 16,
|
| 25 |
+
"num_channels": 3,
|
| 26 |
+
"num_hidden_layers": 27,
|
| 27 |
+
"num_patches": 1024,
|
| 28 |
+
"patch_size": 16
|
| 29 |
+
},
|
| 30 |
+
"text_config":{
|
| 31 |
+
"hidden_size": 1536,
|
| 32 |
+
"intermediate_size": 8960,
|
| 33 |
+
"max_window_layers": 21,
|
| 34 |
+
"num_attention_heads": 12,
|
| 35 |
+
"num_key_value_heads": 2,
|
| 36 |
+
"sliding_window": 32768,
|
| 37 |
+
"tie_word_embeddings": true,
|
| 38 |
+
"vocab_size": 151936,
|
| 39 |
+
"max_position_embeddings": 32768
|
| 40 |
+
},
|
| 41 |
+
"model_type": "umm",
|
| 42 |
+
"torch_dtype": "bfloat16",
|
| 43 |
+
"transformers_version": "4.51.3"
|
| 44 |
+
}
|
configuration_umm.py
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 2 |
+
from transformers.modeling_rope_utils import rope_config_validation
|
| 3 |
+
from transformers.utils import logging
|
| 4 |
+
|
| 5 |
+
logger = logging.get_logger(__name__)
|
| 6 |
+
|
| 7 |
+
class VAEEncoderConfig(PretrainedConfig):
|
| 8 |
+
model_type = "umm"
|
| 9 |
+
base_config_key = "vae_encoder_config"
|
| 10 |
+
|
| 11 |
+
def __init__(
|
| 12 |
+
self,
|
| 13 |
+
resolution=256,
|
| 14 |
+
in_channels=3,
|
| 15 |
+
ch=128,
|
| 16 |
+
ch_mult=[1,2,4,4],
|
| 17 |
+
num_res_blocks=2,
|
| 18 |
+
z_channels=32,
|
| 19 |
+
**kwargs
|
| 20 |
+
):
|
| 21 |
+
self.resolution = resolution
|
| 22 |
+
self.in_channels = in_channels
|
| 23 |
+
self.ch = ch
|
| 24 |
+
self.ch_mult = ch_mult
|
| 25 |
+
self.num_res_blocks = num_res_blocks
|
| 26 |
+
self.z_channels = z_channels
|
| 27 |
+
super().__init__(**kwargs)
|
| 28 |
+
|
| 29 |
+
class VAEDecoderConfig(PretrainedConfig):
|
| 30 |
+
model_type = "umm"
|
| 31 |
+
base_config_key = "vae_decoder_config"
|
| 32 |
+
|
| 33 |
+
def __init__(
|
| 34 |
+
self,
|
| 35 |
+
ch=128,
|
| 36 |
+
out_ch=3,
|
| 37 |
+
ch_mult=[1,2,4,4],
|
| 38 |
+
num_res_blocks=2,
|
| 39 |
+
in_channels=3,
|
| 40 |
+
resolution=256,
|
| 41 |
+
z_channels=32,
|
| 42 |
+
**kwargs
|
| 43 |
+
):
|
| 44 |
+
self.resolution = resolution
|
| 45 |
+
self.in_channels = in_channels
|
| 46 |
+
self.ch = ch
|
| 47 |
+
self.out_ch = out_ch
|
| 48 |
+
self.ch_mult = ch_mult
|
| 49 |
+
self.num_res_blocks = num_res_blocks
|
| 50 |
+
self.z_channels = z_channels
|
| 51 |
+
super().__init__(**kwargs)
|
| 52 |
+
|
| 53 |
+
class Siglip2VisionConfig(PretrainedConfig):
|
| 54 |
+
model_type = "umm"
|
| 55 |
+
base_config_key = "vision_representation_config"
|
| 56 |
+
|
| 57 |
+
def __init__(
|
| 58 |
+
self,
|
| 59 |
+
hidden_size=768,
|
| 60 |
+
intermediate_size=3072,
|
| 61 |
+
num_hidden_layers=12,
|
| 62 |
+
num_attention_heads=12,
|
| 63 |
+
num_channels=3,
|
| 64 |
+
image_size=256,
|
| 65 |
+
patch_size=16,
|
| 66 |
+
hidden_act="gelu_pytorch_tanh",
|
| 67 |
+
layer_norm_eps=1e-6,
|
| 68 |
+
attention_dropout=0.0,
|
| 69 |
+
**kwargs,
|
| 70 |
+
):
|
| 71 |
+
super().__init__(**kwargs)
|
| 72 |
+
|
| 73 |
+
self.hidden_size = hidden_size
|
| 74 |
+
self.intermediate_size = intermediate_size
|
| 75 |
+
self.num_hidden_layers = num_hidden_layers
|
| 76 |
+
self.num_attention_heads = num_attention_heads
|
| 77 |
+
self.num_channels = num_channels
|
| 78 |
+
self.patch_size = patch_size
|
| 79 |
+
self.attention_dropout = attention_dropout
|
| 80 |
+
self.layer_norm_eps = layer_norm_eps
|
| 81 |
+
self.hidden_act = hidden_act
|
| 82 |
+
self.image_size = image_size
|
| 83 |
+
|
| 84 |
+
class Qwen2Config(PretrainedConfig):
|
| 85 |
+
model_type = "umm"
|
| 86 |
+
base_config_key = "text_config"
|
| 87 |
+
|
| 88 |
+
def __init__(
|
| 89 |
+
self,
|
| 90 |
+
vocab_size=152064,
|
| 91 |
+
hidden_size=3584,
|
| 92 |
+
intermediate_size=18944,
|
| 93 |
+
num_hidden_layers=28,
|
| 94 |
+
num_attention_heads=28,
|
| 95 |
+
num_key_value_heads=4,
|
| 96 |
+
hidden_act="silu",
|
| 97 |
+
max_position_embeddings=131072,
|
| 98 |
+
initializer_range=0.02,
|
| 99 |
+
rms_norm_eps=1e-6,
|
| 100 |
+
use_cache=True,
|
| 101 |
+
tie_word_embeddings=False,
|
| 102 |
+
rope_theta=1000000.0,
|
| 103 |
+
rope_scaling=None,
|
| 104 |
+
use_sliding_window=False,
|
| 105 |
+
sliding_window=131072,
|
| 106 |
+
max_window_layers=28,
|
| 107 |
+
layer_types=None,
|
| 108 |
+
attention_dropout=0.0,
|
| 109 |
+
**kwargs,
|
| 110 |
+
):
|
| 111 |
+
self.vocab_size = vocab_size
|
| 112 |
+
self.max_position_embeddings = max_position_embeddings
|
| 113 |
+
self.hidden_size = hidden_size
|
| 114 |
+
self.intermediate_size = intermediate_size
|
| 115 |
+
self.num_hidden_layers = num_hidden_layers
|
| 116 |
+
self.num_attention_heads = num_attention_heads
|
| 117 |
+
self.use_sliding_window = use_sliding_window
|
| 118 |
+
self.sliding_window = sliding_window if self.use_sliding_window else None
|
| 119 |
+
self.max_window_layers = max_window_layers
|
| 120 |
+
# for backward compatibility
|
| 121 |
+
if num_key_value_heads is None:
|
| 122 |
+
num_key_value_heads = num_attention_heads
|
| 123 |
+
|
| 124 |
+
self.num_key_value_heads = num_key_value_heads
|
| 125 |
+
self.hidden_act = hidden_act
|
| 126 |
+
self.initializer_range = initializer_range
|
| 127 |
+
self.rms_norm_eps = rms_norm_eps
|
| 128 |
+
self.use_cache = use_cache
|
| 129 |
+
self.rope_theta = rope_theta
|
| 130 |
+
self.rope_scaling = rope_scaling
|
| 131 |
+
self.attention_dropout = attention_dropout
|
| 132 |
+
# Validate the correctness of rotary position embeddings parameters
|
| 133 |
+
# BC: if there is a 'type' field, move it to 'rope_type'.
|
| 134 |
+
if self.rope_scaling is not None and "type" in self.rope_scaling:
|
| 135 |
+
self.rope_scaling["rope_type"] = self.rope_scaling["type"]
|
| 136 |
+
rope_config_validation(self)
|
| 137 |
+
|
| 138 |
+
self.layer_types = layer_types
|
| 139 |
+
if self.layer_types is None:
|
| 140 |
+
self.layer_types = [
|
| 141 |
+
"sliding_attention"
|
| 142 |
+
if self.sliding_window is not None and i >= self.max_window_layers
|
| 143 |
+
else "full_attention"
|
| 144 |
+
for i in range(self.num_hidden_layers)
|
| 145 |
+
]
|
| 146 |
+
|
| 147 |
+
super().__init__(
|
| 148 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 149 |
+
**kwargs,
|
| 150 |
+
)
|
| 151 |
+
|
| 152 |
+
class UMMConfig(PretrainedConfig):
|
| 153 |
+
model_type = "umm"
|
| 154 |
+
sub_configs = {
|
| 155 |
+
"vision_representation_config": Siglip2VisionConfig,
|
| 156 |
+
"vae_encoder_config": VAEEncoderConfig,
|
| 157 |
+
"vae_decoder_config": VAEDecoderConfig,
|
| 158 |
+
"text_config": Qwen2Config,
|
| 159 |
+
}
|
| 160 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 161 |
+
def __init__(
|
| 162 |
+
self,
|
| 163 |
+
vision_representation_config=None,
|
| 164 |
+
vae_encoder_config=None,
|
| 165 |
+
vae_decoder_config=None,
|
| 166 |
+
text_config=None,
|
| 167 |
+
**kwargs,
|
| 168 |
+
):
|
| 169 |
+
if isinstance(vision_representation_config, dict):
|
| 170 |
+
self.vision_representation_config = self.sub_configs["vision_representation_config"](**vision_representation_config)
|
| 171 |
+
elif vision_representation_config is None:
|
| 172 |
+
self.vision_representation_config = self.sub_configs["vision_representation_config"]()
|
| 173 |
+
|
| 174 |
+
if isinstance(vae_encoder_config, dict):
|
| 175 |
+
self.vae_encoder_config = self.sub_configs["vae_encoder_config"](**vae_encoder_config)
|
| 176 |
+
elif vae_encoder_config is None:
|
| 177 |
+
self.vae_encoder_config = self.sub_configs["vae_encoder_config"]()
|
| 178 |
+
|
| 179 |
+
if isinstance(vae_decoder_config, dict):
|
| 180 |
+
self.vae_decoder_config = self.sub_configs["vae_decoder_config"](**vae_decoder_config)
|
| 181 |
+
elif vae_decoder_config is None:
|
| 182 |
+
self.vae_decoder_config = self.sub_configs["vae_decoder_config"]()
|
| 183 |
+
|
| 184 |
+
if isinstance(text_config, dict):
|
| 185 |
+
self.text_config = self.sub_configs["text_config"](**text_config)
|
| 186 |
+
elif text_config is None:
|
| 187 |
+
self.text_config = self.sub_configs["text_config"]()
|
| 188 |
+
|
| 189 |
+
super().__init__(**kwargs)
|
| 190 |
+
|
| 191 |
+
__all__ = ["UMMConfig"]
|
image_processing_umm.py
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from networkx import to_numpy_array
|
| 2 |
+
import numpy as np
|
| 3 |
+
import torch
|
| 4 |
+
from PIL import Image, ImageOps
|
| 5 |
+
import math
|
| 6 |
+
from functools import partial, reduce
|
| 7 |
+
from transformers.image_transforms import (
|
| 8 |
+
convert_to_rgb,
|
| 9 |
+
center_crop,
|
| 10 |
+
normalize,
|
| 11 |
+
rescale,
|
| 12 |
+
resize,
|
| 13 |
+
to_channel_dimension_format,
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
from transformers.image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
|
| 17 |
+
from transformers.image_utils import ImageInput, ChannelDimension, PILImageResampling, to_numpy_array
|
| 18 |
+
|
| 19 |
+
class UMMImageProcessor(BaseImageProcessor):
|
| 20 |
+
model_input_names = ["pixel_values", "grid_hws"]
|
| 21 |
+
def __init__(
|
| 22 |
+
self,
|
| 23 |
+
image_mean=(0.5, 0.5, 0.5),
|
| 24 |
+
image_std=(0.5, 0.5, 0.5),
|
| 25 |
+
size=(256, 256),
|
| 26 |
+
crop_size = None,
|
| 27 |
+
resample=PILImageResampling.BICUBIC,
|
| 28 |
+
rescale_factor=1 / 255,
|
| 29 |
+
data_format=ChannelDimension.FIRST,
|
| 30 |
+
scale_resolution=256,
|
| 31 |
+
patch_size=16,
|
| 32 |
+
**kwargs,
|
| 33 |
+
):
|
| 34 |
+
super().__init__(**kwargs)
|
| 35 |
+
crop_size = crop_size if crop_size is not None else {"height": 256, "width": 256}
|
| 36 |
+
crop_size = get_size_dict(crop_size, default_to_square=True, param_name="crop_size")
|
| 37 |
+
self.image_mean = image_mean
|
| 38 |
+
self.image_std = image_std
|
| 39 |
+
self.size = size
|
| 40 |
+
self.resample = resample
|
| 41 |
+
self.rescale_factor = rescale_factor
|
| 42 |
+
self.data_format = data_format
|
| 43 |
+
self.crop_size = crop_size
|
| 44 |
+
self.scale_resolution = scale_resolution
|
| 45 |
+
self.patch_size = patch_size
|
| 46 |
+
|
| 47 |
+
def preprocess(self, image, max_resolution=None, return_tensors = 'pt', und=True, **kwargs) -> BatchFeature:
|
| 48 |
+
if max_resolution is not None:
|
| 49 |
+
scale_resolution = max_resolution
|
| 50 |
+
else:
|
| 51 |
+
scale_resolution = self.scale_resolution
|
| 52 |
+
if image is not None:
|
| 53 |
+
pixel_values, grid_hws = [], []
|
| 54 |
+
if und:
|
| 55 |
+
image = self._preprocess_und(image, scale_resolution)
|
| 56 |
+
else:
|
| 57 |
+
image = self._preprocess_gen(image, scale_resolution)
|
| 58 |
+
if not torch.is_tensor(image):
|
| 59 |
+
image = torch.tensor(image)
|
| 60 |
+
_,H,W = image.shape
|
| 61 |
+
grid_h = int(H // self.patch_size)
|
| 62 |
+
grid_w = int(W // self.patch_size)
|
| 63 |
+
grid_hw = (grid_h, grid_w)
|
| 64 |
+
pixel_values = torch.stack([image], dim=0)
|
| 65 |
+
grid_hws = torch.tensor([grid_hw])
|
| 66 |
+
data = {
|
| 67 |
+
"pixel_values": pixel_values,
|
| 68 |
+
"grid_hws": grid_hws
|
| 69 |
+
}
|
| 70 |
+
return BatchFeature(data=data, tensor_type=return_tensors)
|
| 71 |
+
|
| 72 |
+
def _preprocess_gen(self, source_image, scale_resolution):
|
| 73 |
+
w, h = source_image.size
|
| 74 |
+
scale = scale_resolution / min(h, w)
|
| 75 |
+
new_h = int(round(h * scale))
|
| 76 |
+
new_w = int(round(w * scale))
|
| 77 |
+
source_image = source_image.resize((new_w, new_h), Image.Resampling.BICUBIC)
|
| 78 |
+
source_image = [source_image]
|
| 79 |
+
transforms = [
|
| 80 |
+
convert_to_rgb,
|
| 81 |
+
to_numpy_array,
|
| 82 |
+
]
|
| 83 |
+
transforms.append(partial(center_crop, size=(scale_resolution, scale_resolution)))
|
| 84 |
+
transforms.append(partial(rescale, scale=self.rescale_factor, data_format=self.data_format))
|
| 85 |
+
transforms.append(partial(to_channel_dimension_format, channel_dim=self.data_format, input_channel_dim=self.data_format))
|
| 86 |
+
image = reduce(lambda x, f: [*map(f, x)], transforms, source_image)
|
| 87 |
+
return image[0] if len(image) == 1 else image
|
| 88 |
+
|
| 89 |
+
def _preprocess_und(self, source_image, scale_resolution):
|
| 90 |
+
w, h = source_image.size
|
| 91 |
+
scale = min(scale_resolution / h, scale_resolution / w)
|
| 92 |
+
new_h = int(round(h * scale))
|
| 93 |
+
new_w = int(round(w * scale))
|
| 94 |
+
resized_image = source_image.resize((new_w, new_h), Image.Resampling.BICUBIC)
|
| 95 |
+
|
| 96 |
+
pad_w = scale_resolution - new_w
|
| 97 |
+
pad_h = scale_resolution - new_h
|
| 98 |
+
|
| 99 |
+
left = pad_w // 2
|
| 100 |
+
right = pad_w - left
|
| 101 |
+
top = pad_h // 2
|
| 102 |
+
bottom = pad_h - top
|
| 103 |
+
|
| 104 |
+
new_image = ImageOps.expand(resized_image, border=(left, top, right, bottom), fill=(0,0,0))
|
| 105 |
+
# new_image.save("test_path")
|
| 106 |
+
source_image = [new_image]
|
| 107 |
+
transforms = [
|
| 108 |
+
convert_to_rgb,
|
| 109 |
+
to_numpy_array
|
| 110 |
+
]
|
| 111 |
+
transforms.append(partial(rescale, scale=self.rescale_factor, data_format=self.data_format))
|
| 112 |
+
transforms.append(partial(to_channel_dimension_format, channel_dim=self.data_format, input_channel_dim=self.data_format))
|
| 113 |
+
image = reduce(lambda x, f: [*map(f, x)], transforms, source_image)
|
| 114 |
+
return image[0] if len(image) == 1 else image
|
| 115 |
+
|
| 116 |
+
__all__ = ["UMMImageProcessor"]
|
| 117 |
+
|
merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
model-00001-of-00002.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6bb63d4dfb159e73c509431f5b0501a4bd0027e293014493fe0686c74c6f6675
|
| 3 |
+
size 4994193826
|
model-00002-of-00002.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3801e501b3546a7d43b2e02bb198467b447c00e9feba1c353c138d4451d3b65a
|
| 3 |
+
size 615404776
|
model.safetensors.index.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
modeling_umm.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
preprocessor_config.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"auto_map": {
|
| 3 |
+
"AutoImageProcessor": "image_processing_umm.UMMImageProcessor",
|
| 4 |
+
"AutoProcessor": "processing_umm.UMMProcessor"
|
| 5 |
+
},
|
| 6 |
+
"crop_size": {
|
| 7 |
+
"height": 256,
|
| 8 |
+
"width": 256
|
| 9 |
+
},
|
| 10 |
+
"data_format": "channels_first",
|
| 11 |
+
"image_mean": [
|
| 12 |
+
0.5,
|
| 13 |
+
0.5,
|
| 14 |
+
0.5
|
| 15 |
+
],
|
| 16 |
+
"image_processor_type": "UMMImageProcessor",
|
| 17 |
+
"image_std": [
|
| 18 |
+
0.5,
|
| 19 |
+
0.5,
|
| 20 |
+
0.5
|
| 21 |
+
],
|
| 22 |
+
"patch_size": 16,
|
| 23 |
+
"processor_class": "UMMProcessor",
|
| 24 |
+
"resample": 3,
|
| 25 |
+
"rescale_factor": 0.00392156862745098,
|
| 26 |
+
"scale_resolution": 512,
|
| 27 |
+
"size": [
|
| 28 |
+
256,
|
| 29 |
+
256
|
| 30 |
+
]
|
| 31 |
+
}
|
processing_umm.py
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from PIL import Image
|
| 2 |
+
from scipy import special
|
| 3 |
+
import torch
|
| 4 |
+
import numpy as np
|
| 5 |
+
from math import e
|
| 6 |
+
from param import output
|
| 7 |
+
from transformers.feature_extraction_utils import BatchFeature
|
| 8 |
+
from transformers.processing_utils import ProcessorMixin
|
| 9 |
+
|
| 10 |
+
class UMMProcessor(ProcessorMixin):
|
| 11 |
+
attributes = ["image_processor", "tokenizer"]
|
| 12 |
+
image_processor_class = "AutoImageProcessor"
|
| 13 |
+
tokenizer_class = ("Qwen2Tokenizer", "Qwen2TokenizerFast")
|
| 14 |
+
|
| 15 |
+
def __init__(self, image_processor=None, tokenizer=None, chat_template=None, **kwargs):
|
| 16 |
+
self.image_token = "<image>" if not hasattr(tokenizer, "image_token") else tokenizer.image_token
|
| 17 |
+
if getattr(tokenizer, "image_token_id", None):
|
| 18 |
+
self.image_token_id = tokenizer.image_token_id
|
| 19 |
+
else:
|
| 20 |
+
tokenizer.add_tokens(["<image>"], special_tokens=True)
|
| 21 |
+
self.image_token_id = -200
|
| 22 |
+
|
| 23 |
+
self.image_gen_token = "<image_gen>" if not hasattr(tokenizer, "image_gen_token") else tokenizer.image_gen_token
|
| 24 |
+
if getattr(tokenizer, "image_gen_token_id", None):
|
| 25 |
+
self.image_gen_token_id = tokenizer.image_gen_token_id
|
| 26 |
+
else:
|
| 27 |
+
tokenizer.add_tokens(["<image_gen>"], special_tokens=True)
|
| 28 |
+
self.image_gen_token_id = -300
|
| 29 |
+
|
| 30 |
+
self.image_gen_start_token = "<im_start>" if not hasattr(tokenizer, "image_gen_start") else tokenizer.image_gen_start
|
| 31 |
+
if getattr(tokenizer, "image_gen_start_token_id", None):
|
| 32 |
+
self.image_gen_start_token_id = tokenizer.image_gen_start_token_id
|
| 33 |
+
else:
|
| 34 |
+
tokenizer.add_tokens(["<im_start>"], special_tokens=True)
|
| 35 |
+
self.image_gen_start_token_id = tokenizer.convert_tokens_to_ids(self.image_gen_start_token)
|
| 36 |
+
|
| 37 |
+
self.image_gen_end_token = "<im_end>" if not hasattr(tokenizer, "image_gen_end") else tokenizer.image_gen_end
|
| 38 |
+
if getattr(tokenizer, "image_gen_end_token_id", None):
|
| 39 |
+
self.image_gen_end_token_id = tokenizer.image_gen_end_token_id
|
| 40 |
+
else:
|
| 41 |
+
tokenizer.add_tokens(["<im_end>"], special_tokens=True)
|
| 42 |
+
self.image_gen_end_token_id = tokenizer.convert_tokens_to_ids(self.image_gen_end_token)
|
| 43 |
+
|
| 44 |
+
self.no_mean_token = "<no_mean>" if not hasattr(tokenizer, "no_mean") else tokenizer.no_mean
|
| 45 |
+
if getattr(tokenizer, "no_mean_id", None):
|
| 46 |
+
self.no_mean_token_id = tokenizer.no_mean_id
|
| 47 |
+
else:
|
| 48 |
+
tokenizer.add_tokens(["<no_mean>"], special_tokens=True)
|
| 49 |
+
self.no_mean_token_id = tokenizer.convert_tokens_to_ids(self.no_mean_token)
|
| 50 |
+
|
| 51 |
+
if chat_template is None and hasattr(tokenizer, "chat_template"):
|
| 52 |
+
chat_template = tokenizer.chat_template
|
| 53 |
+
super().__init__(image_processor, tokenizer, chat_template=chat_template)
|
| 54 |
+
|
| 55 |
+
def __call__(self, images=None, text=None, max_resolution=None, add_im_start_id=False, **kwargs):
|
| 56 |
+
if "padding" not in kwargs:
|
| 57 |
+
kwargs["padding"] = True
|
| 58 |
+
if "truncation" not in kwargs:
|
| 59 |
+
kwargs["truncation"] = True
|
| 60 |
+
if not isinstance(text, list):
|
| 61 |
+
text = [text]
|
| 62 |
+
text = text.copy()
|
| 63 |
+
return_tensors = kwargs.pop("return_tensors", None)
|
| 64 |
+
text_inputs = self.tokenizer(text, **kwargs, return_tensors=return_tensors)
|
| 65 |
+
img_token_id = self.tokenizer.convert_tokens_to_ids(self.image_token)
|
| 66 |
+
img_gen_token_id = self.tokenizer.convert_tokens_to_ids(self.image_gen_token)
|
| 67 |
+
if add_im_start_id:
|
| 68 |
+
B, T = text_inputs["input_ids"].shape
|
| 69 |
+
new_input_ids = torch.full((B, T+1), self.tokenizer.pad_token_id)
|
| 70 |
+
new_input_ids[:, :T] = text_inputs["input_ids"]
|
| 71 |
+
is_valid = (text_inputs["input_ids"] != self.tokenizer.pad_token_id)
|
| 72 |
+
valid_len = is_valid.sum(dim=1)
|
| 73 |
+
else:
|
| 74 |
+
new_input_ids = text_inputs["input_ids"]
|
| 75 |
+
|
| 76 |
+
t = []
|
| 77 |
+
und_gen_mask_list = []
|
| 78 |
+
for i, ids in enumerate(text_inputs["input_ids"]):
|
| 79 |
+
for j, token_id in enumerate(ids):
|
| 80 |
+
if token_id == img_token_id:
|
| 81 |
+
new_input_ids[i][j] = self.image_token_id
|
| 82 |
+
t.append(torch.tensor([1.0]))
|
| 83 |
+
und_gen_mask_list.append(1)
|
| 84 |
+
elif token_id == img_gen_token_id:
|
| 85 |
+
new_input_ids[i][j] = self.image_gen_token_id
|
| 86 |
+
t.append(torch.rand(1))
|
| 87 |
+
und_gen_mask_list.append(0)
|
| 88 |
+
|
| 89 |
+
image_inputs = {}
|
| 90 |
+
pixel_values, grid_hws = [], []
|
| 91 |
+
if images is not None:
|
| 92 |
+
image_idx = 0
|
| 93 |
+
for per_images in images if isinstance(images, list) else [images]:
|
| 94 |
+
if per_images is None:
|
| 95 |
+
dummy_image = Image.fromarray(np.random.randint(0, 256, (256, 256, 3), dtype=np.uint8))
|
| 96 |
+
image_info = self.image_processor(images=dummy_image)
|
| 97 |
+
else:
|
| 98 |
+
for per_image in per_images if isinstance(per_images, list) else[per_images]:
|
| 99 |
+
if und_gen_mask_list[image_idx] == 0:
|
| 100 |
+
image_info = self.image_processor(images=per_image, max_resolution=max_resolution, und=False)
|
| 101 |
+
else:
|
| 102 |
+
image_info = self.image_processor(images=per_image, max_resolution=max_resolution)
|
| 103 |
+
image_idx += 1
|
| 104 |
+
pixel_values.append(image_info.pixel_values)
|
| 105 |
+
grid_hws.append(image_info.grid_hws)
|
| 106 |
+
pixel_values = torch.concat(pixel_values, dim=0)
|
| 107 |
+
grid_hws = torch.concat(grid_hws, dim=0)
|
| 108 |
+
image_inputs.update({'pixel_values': pixel_values, 'grid_hws': grid_hws})
|
| 109 |
+
|
| 110 |
+
if len(t) > 0:
|
| 111 |
+
t = torch.cat(t)
|
| 112 |
+
image_inputs.update({"t":t})
|
| 113 |
+
if add_im_start_id:
|
| 114 |
+
for b in range(B):
|
| 115 |
+
pos = valid_len[b].item()
|
| 116 |
+
new_input_ids[b, pos] = self.image_gen_start_token_id
|
| 117 |
+
attention_mask = torch.cat([
|
| 118 |
+
text_inputs["attention_mask"],
|
| 119 |
+
(new_input_ids[:, -1] != self.tokenizer.pad_token_id).long().unsqueeze(1)
|
| 120 |
+
], dim=1)
|
| 121 |
+
text_inputs["attention_mask"] = attention_mask
|
| 122 |
+
text_inputs["input_ids"] = new_input_ids
|
| 123 |
+
return BatchFeature(data={**text_inputs, **image_inputs}, tensor_type=return_tensors)
|
| 124 |
+
|
| 125 |
+
__all__ = ["UMMProcessor"]
|
processor_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"auto_map": {
|
| 3 |
+
"AutoProcessor": "processing_umm.UMMProcessor"
|
| 4 |
+
},
|
| 5 |
+
"processor_class": "UMMProcessor"
|
| 6 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"additional_special_tokens": [
|
| 3 |
+
"<|im_start|>",
|
| 4 |
+
"<|im_end|>",
|
| 5 |
+
"<|object_ref_start|>",
|
| 6 |
+
"<|object_ref_end|>",
|
| 7 |
+
"<|box_start|>",
|
| 8 |
+
"<|box_end|>",
|
| 9 |
+
"<|quad_start|>",
|
| 10 |
+
"<|quad_end|>",
|
| 11 |
+
"<|vision_start|>",
|
| 12 |
+
"<|vision_end|>",
|
| 13 |
+
"<|vision_pad|>",
|
| 14 |
+
"<|image_pad|>",
|
| 15 |
+
"<|video_pad|>"
|
| 16 |
+
],
|
| 17 |
+
"eos_token": {
|
| 18 |
+
"content": "<|im_end|>",
|
| 19 |
+
"lstrip": false,
|
| 20 |
+
"normalized": false,
|
| 21 |
+
"rstrip": false,
|
| 22 |
+
"single_word": false
|
| 23 |
+
},
|
| 24 |
+
"pad_token": {
|
| 25 |
+
"content": "<|endoftext|>",
|
| 26 |
+
"lstrip": false,
|
| 27 |
+
"normalized": false,
|
| 28 |
+
"rstrip": false,
|
| 29 |
+
"single_word": false
|
| 30 |
+
}
|
| 31 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6cdeaf96cae42805c80ab30a98d263acfb34725a026765b21a21e33245203966
|
| 3 |
+
size 11422826
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_bos_token": false,
|
| 3 |
+
"add_prefix_space": false,
|
| 4 |
+
"added_tokens_decoder": {
|
| 5 |
+
"151643": {
|
| 6 |
+
"content": "<|endoftext|>",
|
| 7 |
+
"lstrip": false,
|
| 8 |
+
"normalized": false,
|
| 9 |
+
"rstrip": false,
|
| 10 |
+
"single_word": false,
|
| 11 |
+
"special": true
|
| 12 |
+
},
|
| 13 |
+
"151644": {
|
| 14 |
+
"content": "<|im_start|>",
|
| 15 |
+
"lstrip": false,
|
| 16 |
+
"normalized": false,
|
| 17 |
+
"rstrip": false,
|
| 18 |
+
"single_word": false,
|
| 19 |
+
"special": true
|
| 20 |
+
},
|
| 21 |
+
"151645": {
|
| 22 |
+
"content": "<|im_end|>",
|
| 23 |
+
"lstrip": false,
|
| 24 |
+
"normalized": false,
|
| 25 |
+
"rstrip": false,
|
| 26 |
+
"single_word": false,
|
| 27 |
+
"special": true
|
| 28 |
+
},
|
| 29 |
+
"151646": {
|
| 30 |
+
"content": "<|object_ref_start|>",
|
| 31 |
+
"lstrip": false,
|
| 32 |
+
"normalized": false,
|
| 33 |
+
"rstrip": false,
|
| 34 |
+
"single_word": false,
|
| 35 |
+
"special": true
|
| 36 |
+
},
|
| 37 |
+
"151647": {
|
| 38 |
+
"content": "<|object_ref_end|>",
|
| 39 |
+
"lstrip": false,
|
| 40 |
+
"normalized": false,
|
| 41 |
+
"rstrip": false,
|
| 42 |
+
"single_word": false,
|
| 43 |
+
"special": true
|
| 44 |
+
},
|
| 45 |
+
"151648": {
|
| 46 |
+
"content": "<|box_start|>",
|
| 47 |
+
"lstrip": false,
|
| 48 |
+
"normalized": false,
|
| 49 |
+
"rstrip": false,
|
| 50 |
+
"single_word": false,
|
| 51 |
+
"special": true
|
| 52 |
+
},
|
| 53 |
+
"151649": {
|
| 54 |
+
"content": "<|box_end|>",
|
| 55 |
+
"lstrip": false,
|
| 56 |
+
"normalized": false,
|
| 57 |
+
"rstrip": false,
|
| 58 |
+
"single_word": false,
|
| 59 |
+
"special": true
|
| 60 |
+
},
|
| 61 |
+
"151650": {
|
| 62 |
+
"content": "<|quad_start|>",
|
| 63 |
+
"lstrip": false,
|
| 64 |
+
"normalized": false,
|
| 65 |
+
"rstrip": false,
|
| 66 |
+
"single_word": false,
|
| 67 |
+
"special": true
|
| 68 |
+
},
|
| 69 |
+
"151651": {
|
| 70 |
+
"content": "<|quad_end|>",
|
| 71 |
+
"lstrip": false,
|
| 72 |
+
"normalized": false,
|
| 73 |
+
"rstrip": false,
|
| 74 |
+
"single_word": false,
|
| 75 |
+
"special": true
|
| 76 |
+
},
|
| 77 |
+
"151652": {
|
| 78 |
+
"content": "<|vision_start|>",
|
| 79 |
+
"lstrip": false,
|
| 80 |
+
"normalized": false,
|
| 81 |
+
"rstrip": false,
|
| 82 |
+
"single_word": false,
|
| 83 |
+
"special": true
|
| 84 |
+
},
|
| 85 |
+
"151653": {
|
| 86 |
+
"content": "<|vision_end|>",
|
| 87 |
+
"lstrip": false,
|
| 88 |
+
"normalized": false,
|
| 89 |
+
"rstrip": false,
|
| 90 |
+
"single_word": false,
|
| 91 |
+
"special": true
|
| 92 |
+
},
|
| 93 |
+
"151654": {
|
| 94 |
+
"content": "<|vision_pad|>",
|
| 95 |
+
"lstrip": false,
|
| 96 |
+
"normalized": false,
|
| 97 |
+
"rstrip": false,
|
| 98 |
+
"single_word": false,
|
| 99 |
+
"special": true
|
| 100 |
+
},
|
| 101 |
+
"151655": {
|
| 102 |
+
"content": "<|image_pad|>",
|
| 103 |
+
"lstrip": false,
|
| 104 |
+
"normalized": false,
|
| 105 |
+
"rstrip": false,
|
| 106 |
+
"single_word": false,
|
| 107 |
+
"special": true
|
| 108 |
+
},
|
| 109 |
+
"151656": {
|
| 110 |
+
"content": "<|video_pad|>",
|
| 111 |
+
"lstrip": false,
|
| 112 |
+
"normalized": false,
|
| 113 |
+
"rstrip": false,
|
| 114 |
+
"single_word": false,
|
| 115 |
+
"special": true
|
| 116 |
+
},
|
| 117 |
+
"151657": {
|
| 118 |
+
"content": "<tool_call>",
|
| 119 |
+
"lstrip": false,
|
| 120 |
+
"normalized": false,
|
| 121 |
+
"rstrip": false,
|
| 122 |
+
"single_word": false,
|
| 123 |
+
"special": false
|
| 124 |
+
},
|
| 125 |
+
"151658": {
|
| 126 |
+
"content": "</tool_call>",
|
| 127 |
+
"lstrip": false,
|
| 128 |
+
"normalized": false,
|
| 129 |
+
"rstrip": false,
|
| 130 |
+
"single_word": false,
|
| 131 |
+
"special": false
|
| 132 |
+
},
|
| 133 |
+
"151659": {
|
| 134 |
+
"content": "<|fim_prefix|>",
|
| 135 |
+
"lstrip": false,
|
| 136 |
+
"normalized": false,
|
| 137 |
+
"rstrip": false,
|
| 138 |
+
"single_word": false,
|
| 139 |
+
"special": false
|
| 140 |
+
},
|
| 141 |
+
"151660": {
|
| 142 |
+
"content": "<|fim_middle|>",
|
| 143 |
+
"lstrip": false,
|
| 144 |
+
"normalized": false,
|
| 145 |
+
"rstrip": false,
|
| 146 |
+
"single_word": false,
|
| 147 |
+
"special": false
|
| 148 |
+
},
|
| 149 |
+
"151661": {
|
| 150 |
+
"content": "<|fim_suffix|>",
|
| 151 |
+
"lstrip": false,
|
| 152 |
+
"normalized": false,
|
| 153 |
+
"rstrip": false,
|
| 154 |
+
"single_word": false,
|
| 155 |
+
"special": false
|
| 156 |
+
},
|
| 157 |
+
"151662": {
|
| 158 |
+
"content": "<|fim_pad|>",
|
| 159 |
+
"lstrip": false,
|
| 160 |
+
"normalized": false,
|
| 161 |
+
"rstrip": false,
|
| 162 |
+
"single_word": false,
|
| 163 |
+
"special": false
|
| 164 |
+
},
|
| 165 |
+
"151663": {
|
| 166 |
+
"content": "<|repo_name|>",
|
| 167 |
+
"lstrip": false,
|
| 168 |
+
"normalized": false,
|
| 169 |
+
"rstrip": false,
|
| 170 |
+
"single_word": false,
|
| 171 |
+
"special": false
|
| 172 |
+
},
|
| 173 |
+
"151664": {
|
| 174 |
+
"content": "<|file_sep|>",
|
| 175 |
+
"lstrip": false,
|
| 176 |
+
"normalized": false,
|
| 177 |
+
"rstrip": false,
|
| 178 |
+
"single_word": false,
|
| 179 |
+
"special": false
|
| 180 |
+
},
|
| 181 |
+
"151665": {
|
| 182 |
+
"content": "<image>",
|
| 183 |
+
"lstrip": false,
|
| 184 |
+
"normalized": false,
|
| 185 |
+
"rstrip": false,
|
| 186 |
+
"single_word": false,
|
| 187 |
+
"special": true
|
| 188 |
+
},
|
| 189 |
+
"151666": {
|
| 190 |
+
"content": "<image_gen>",
|
| 191 |
+
"lstrip": false,
|
| 192 |
+
"normalized": false,
|
| 193 |
+
"rstrip": false,
|
| 194 |
+
"single_word": false,
|
| 195 |
+
"special": true
|
| 196 |
+
},
|
| 197 |
+
"151667": {
|
| 198 |
+
"content": "<im_start>",
|
| 199 |
+
"lstrip": false,
|
| 200 |
+
"normalized": false,
|
| 201 |
+
"rstrip": false,
|
| 202 |
+
"single_word": false,
|
| 203 |
+
"special": true
|
| 204 |
+
},
|
| 205 |
+
"151668": {
|
| 206 |
+
"content": "<im_end>",
|
| 207 |
+
"lstrip": false,
|
| 208 |
+
"normalized": false,
|
| 209 |
+
"rstrip": false,
|
| 210 |
+
"single_word": false,
|
| 211 |
+
"special": true
|
| 212 |
+
},
|
| 213 |
+
"151669": {
|
| 214 |
+
"content": "<no_mean>",
|
| 215 |
+
"lstrip": false,
|
| 216 |
+
"normalized": false,
|
| 217 |
+
"rstrip": false,
|
| 218 |
+
"single_word": false,
|
| 219 |
+
"special": true
|
| 220 |
+
}
|
| 221 |
+
},
|
| 222 |
+
"additional_special_tokens": [
|
| 223 |
+
"<|im_start|>",
|
| 224 |
+
"<|im_end|>",
|
| 225 |
+
"<|object_ref_start|>",
|
| 226 |
+
"<|object_ref_end|>",
|
| 227 |
+
"<|box_start|>",
|
| 228 |
+
"<|box_end|>",
|
| 229 |
+
"<|quad_start|>",
|
| 230 |
+
"<|quad_end|>",
|
| 231 |
+
"<|vision_start|>",
|
| 232 |
+
"<|vision_end|>",
|
| 233 |
+
"<|vision_pad|>",
|
| 234 |
+
"<|image_pad|>",
|
| 235 |
+
"<|video_pad|>"
|
| 236 |
+
],
|
| 237 |
+
"auto_map": {
|
| 238 |
+
"AutoProcessor": "processing_umm.UMMProcessor"
|
| 239 |
+
},
|
| 240 |
+
"bos_token": null,
|
| 241 |
+
"chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
|
| 242 |
+
"clean_up_tokenization_spaces": false,
|
| 243 |
+
"eos_token": "<|im_end|>",
|
| 244 |
+
"errors": "replace",
|
| 245 |
+
"extra_special_tokens": {},
|
| 246 |
+
"model_max_length": 131072,
|
| 247 |
+
"pad_token": "<|endoftext|>",
|
| 248 |
+
"padding_side": "right",
|
| 249 |
+
"processor_class": "UMMProcessor",
|
| 250 |
+
"split_special_tokens": false,
|
| 251 |
+
"tokenizer_class": "Qwen2Tokenizer",
|
| 252 |
+
"unk_token": null
|
| 253 |
+
}
|
vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|