anuragpradhan commited on
Commit
6f3a64d
·
verified ·
1 Parent(s): 449bcfa

Add SmolVLM2-500M sidecar pipeline (DepthBridge + ObjectAnchorProjector)

Browse files
README.md ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: HuggingFaceTB/SmolVLM2-500M-Video-Instruct
4
+ tags:
5
+ - smolvlm
6
+ - depth-estimation
7
+ - object-detection
8
+ - multimodal
9
+ - sidecar-pipeline
10
+ ---
11
+
12
+ # SmolVLM2-500M-Video-Instruct + Sidecar Pipeline
13
+
14
+ This model extends [SmolVLM2-500M-Video-Instruct](HuggingFaceTB/SmolVLM2-500M-Video-Instruct) with two
15
+ lightweight sidecar modules for grounded spatial reasoning:
16
+
17
+ | Module | Params | Purpose |
18
+ |---|---|---|
19
+ | **DepthBridge** | ~760 K | Fuses Depth-Anything-V2-Metric depth maps into SigLIP patch tokens via a gated residual |
20
+ | **ObjectAnchorProjector** | ~1.3 K | Projects YOLOv8-World CLIP embeddings into LM anchor tokens |
21
+
22
+ ## Sidecar config flags
23
+
24
+ ```python
25
+ config.depth_integration = True # enables DepthBridge
26
+ config.object_integration = True # enables ObjectAnchorProjector (train first)
27
+ ```
28
+
29
+ ## Loading
30
+
31
+ ```python
32
+ from transformers import AutoProcessor, AutoModelForImageTextToText
33
+
34
+ model = AutoModelForImageTextToText.from_pretrained("anuragpradhan/SmolVLM2-500M-DepthAwareVLM")
35
+ processor = AutoProcessor.from_pretrained("anuragpradhan/SmolVLM2-500M-DepthAwareVLM")
36
+ ```
37
+
38
+ ## Fine-tuning note
39
+
40
+ DepthBridge gate α is initialised at 0.0 (depth is inactive until trained).
41
+ Run `model.freeze_base_models()` to train only the sidecar modules.
chat_template.jinja ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ <|im_start|>{% for message in messages %}{{message['role'] | capitalize}}{% if message['content'][0]['type'] == 'image' %}{{':'}}{% else %}{{': '}}{% endif %}{% for line in message['content'] %}{% if line['type'] == 'text' %}{{line['text']}}{% elif line['type'] == 'image' %}{{ '<image>' }}{% endif %}{% endfor %}<end_of_utterance>
2
+ {% endfor %}{% if add_generation_prompt %}{{ 'Assistant:' }}{% endif %}
config.json ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "SmolVLMForConditionalGeneration"
4
+ ],
5
+ "depth_gate_init": 0.0,
6
+ "depth_hidden_dim": 256,
7
+ "depth_integration": true,
8
+ "dtype": "float32",
9
+ "image_token_id": 49190,
10
+ "max_objects": 20,
11
+ "model_type": "smolvlm",
12
+ "object_feature_dim": 512,
13
+ "object_integration": true,
14
+ "pad_token_id": 128002,
15
+ "scale_factor": 4,
16
+ "text_config": {
17
+ "_flash_attn_2_enabled": true,
18
+ "_name_or_path": "None",
19
+ "architectures": [
20
+ "VLlama3ForCausalLM"
21
+ ],
22
+ "attention_bias": false,
23
+ "attention_dropout": 0.0,
24
+ "bos_token_id": 1,
25
+ "dtype": "float32",
26
+ "eos_token_id": 2,
27
+ "head_dim": 64,
28
+ "hidden_act": "silu",
29
+ "hidden_size": 960,
30
+ "initializer_range": 0.02,
31
+ "intermediate_size": 2560,
32
+ "is_llama_config": true,
33
+ "max_position_embeddings": 8192,
34
+ "mlp_bias": false,
35
+ "model_type": "llama",
36
+ "neftune_noise_alpha": 0.0,
37
+ "num_attention_heads": 15,
38
+ "num_hidden_layers": 32,
39
+ "num_key_value_heads": 5,
40
+ "pad_token_id": 2,
41
+ "perceiver_config": {
42
+ "_attn_implementation_autoset": false,
43
+ "_name_or_path": "",
44
+ "add_cross_attention": false,
45
+ "architectures": null,
46
+ "attention_dropout": 0.0,
47
+ "bad_words_ids": null,
48
+ "begin_suppress_tokens": null,
49
+ "bos_token_id": null,
50
+ "chunk_size_feed_forward": 0,
51
+ "cross_attention_hidden_size": null,
52
+ "decoder_start_token_id": null,
53
+ "diversity_penalty": 0.0,
54
+ "do_sample": false,
55
+ "early_stopping": false,
56
+ "encoder_no_repeat_ngram_size": 0,
57
+ "eos_token_id": null,
58
+ "exponential_decay_length_penalty": null,
59
+ "finetuning_task": null,
60
+ "forced_bos_token_id": null,
61
+ "forced_eos_token_id": null,
62
+ "hidden_act": "silu",
63
+ "id2label": {
64
+ "0": "LABEL_0",
65
+ "1": "LABEL_1"
66
+ },
67
+ "is_decoder": false,
68
+ "is_encoder_decoder": false,
69
+ "label2id": {
70
+ "LABEL_0": 0,
71
+ "LABEL_1": 1
72
+ },
73
+ "length_penalty": 1.0,
74
+ "max_length": 20,
75
+ "min_length": 0,
76
+ "model_type": "vllama3",
77
+ "no_repeat_ngram_size": 0,
78
+ "num_beam_groups": 1,
79
+ "num_beams": 1,
80
+ "num_key_value_heads": 1,
81
+ "num_return_sequences": 1,
82
+ "output_attentions": false,
83
+ "output_hidden_states": false,
84
+ "output_scores": false,
85
+ "pad_token_id": null,
86
+ "prefix": null,
87
+ "problem_type": null,
88
+ "pruned_heads": {},
89
+ "qk_layer_norms_perceiver": false,
90
+ "remove_invalid_values": false,
91
+ "repetition_penalty": 1.0,
92
+ "resampler_depth": 6,
93
+ "resampler_head_dim": 96,
94
+ "resampler_n_heads": 16,
95
+ "resampler_n_latents": 64,
96
+ "return_dict": true,
97
+ "return_dict_in_generate": false,
98
+ "sep_token_id": null,
99
+ "suppress_tokens": null,
100
+ "task_specific_params": null,
101
+ "temperature": 1.0,
102
+ "tf_legacy_loss": false,
103
+ "tie_encoder_decoder": false,
104
+ "tie_word_embeddings": true,
105
+ "tokenizer_class": null,
106
+ "top_k": 50,
107
+ "top_p": 1.0,
108
+ "torch_dtype": null,
109
+ "torchscript": false,
110
+ "transformers_version": "4.46.0",
111
+ "typical_p": 1.0,
112
+ "use_bfloat16": false
113
+ },
114
+ "pixel_shuffle_factor": 4,
115
+ "pretraining_tp": 1,
116
+ "qk_layer_norms": false,
117
+ "rms_norm_eps": 1e-05,
118
+ "rope_interleaved": false,
119
+ "rope_parameters": {
120
+ "rope_theta": 100000,
121
+ "rope_type": "default"
122
+ },
123
+ "tie_word_embeddings": false,
124
+ "transformers.js_config": {
125
+ "kv_cache_dtype": {
126
+ "fp16": "float16",
127
+ "q4f16": "float16"
128
+ }
129
+ },
130
+ "use_cache": true,
131
+ "use_resampler": false,
132
+ "vocab_size": 49280
133
+ },
134
+ "tie_word_embeddings": false,
135
+ "transformers.js_config": {
136
+ "kv_cache_dtype": {
137
+ "fp16": "float16",
138
+ "q4f16": "float16"
139
+ }
140
+ },
141
+ "transformers_version": "5.8.0.dev0",
142
+ "use_cache": false,
143
+ "use_reentrant_checkpointing": false,
144
+ "vision_config": {
145
+ "attention_dropout": 0.0,
146
+ "dtype": "float32",
147
+ "hidden_act": "gelu_pytorch_tanh",
148
+ "hidden_size": 768,
149
+ "image_size": 512,
150
+ "initializer_range": 0.02,
151
+ "intermediate_size": 3072,
152
+ "layer_norm_eps": 1e-06,
153
+ "max_image_size": {
154
+ "longest_edge": 512
155
+ },
156
+ "model_type": "smolvlm_vision",
157
+ "num_attention_heads": 12,
158
+ "num_channels": 3,
159
+ "num_hidden_layers": 12,
160
+ "patch_size": 16,
161
+ "size": {
162
+ "longest_edge": 2048
163
+ },
164
+ "tie_word_embeddings": false,
165
+ "use_base_siglip": false
166
+ },
167
+ "vocab_size": 49280
168
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": 49279,
5
+ "pad_token_id": 2,
6
+ "transformers_version": "5.8.0.dev0"
7
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fad09e4f72fe9b68a9d96c49ce3076346137f8a6e996973cbe73a1c3cab241bf
3
+ size 2033036156
processor_config.json ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "do_convert_rgb": true,
4
+ "do_image_splitting": true,
5
+ "do_normalize": true,
6
+ "do_pad": true,
7
+ "do_rescale": true,
8
+ "do_resize": true,
9
+ "image_mean": [
10
+ 0.5,
11
+ 0.5,
12
+ 0.5
13
+ ],
14
+ "image_processor_type": "SmolVLMImageProcessor",
15
+ "image_std": [
16
+ 0.5,
17
+ 0.5,
18
+ 0.5
19
+ ],
20
+ "max_image_size": {
21
+ "longest_edge": 512
22
+ },
23
+ "resample": 1,
24
+ "rescale_factor": 0.00392156862745098,
25
+ "size": {
26
+ "longest_edge": 2048
27
+ },
28
+ "video_sampling": {
29
+ "fps": 1,
30
+ "max_frames": 64,
31
+ "video_size": {
32
+ "longest_edge": 512
33
+ }
34
+ }
35
+ },
36
+ "image_seq_len": 64,
37
+ "processor_class": "SmolVLMProcessor",
38
+ "video_processor": {
39
+ "do_convert_rgb": true,
40
+ "do_image_splitting": true,
41
+ "do_normalize": true,
42
+ "do_pad": true,
43
+ "do_rescale": true,
44
+ "do_resize": true,
45
+ "do_sample_frames": false,
46
+ "fps": 1,
47
+ "image_mean": [
48
+ 0.5,
49
+ 0.5,
50
+ 0.5
51
+ ],
52
+ "image_std": [
53
+ 0.5,
54
+ 0.5,
55
+ 0.5
56
+ ],
57
+ "max_image_size": {
58
+ "longest_edge": 512
59
+ },
60
+ "num_frames": 64,
61
+ "resample": 1,
62
+ "rescale_factor": 0.00392156862745098,
63
+ "return_metadata": false,
64
+ "size": {
65
+ "longest_edge": 2048
66
+ },
67
+ "video_processor_type": "SmolVLMVideoProcessor",
68
+ "video_sampling": {
69
+ "fps": 1,
70
+ "max_frames": 64,
71
+ "video_size": {
72
+ "longest_edge": 2048
73
+ }
74
+ }
75
+ }
76
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": "<|im_start|>",
5
+ "clean_up_tokenization_spaces": false,
6
+ "end_of_utterance_token": "<end_of_utterance>",
7
+ "eos_token": "<end_of_utterance>",
8
+ "errors": "replace",
9
+ "fake_image_token": "<fake_token_around_image>",
10
+ "global_image_token": "<global-img>",
11
+ "image_token": "<image>",
12
+ "is_local": false,
13
+ "legacy": false,
14
+ "local_files_only": false,
15
+ "model_max_length": 8192,
16
+ "model_specific_special_tokens": {
17
+ "end_of_utterance_token": "<end_of_utterance>",
18
+ "fake_image_token": "<fake_token_around_image>",
19
+ "global_image_token": "<global-img>",
20
+ "image_token": "<image>"
21
+ },
22
+ "pad_token": "<|im_end|>",
23
+ "processor_class": "SmolVLMProcessor",
24
+ "tokenizer_class": "GPT2Tokenizer",
25
+ "truncation_side": "left",
26
+ "unk_token": "<|endoftext|>",
27
+ "vocab_size": 49152
28
+ }