Xuban commited on
Commit
c30b06e
·
verified ·
1 Parent(s): 4f2da19

Rehost SAM-2.1 Hiera Tiny weights

Browse files
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
NOTICE ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ LibreSAM2 weights
2
+ ------------------
3
+
4
+ This product contains weights derived from SAM-2.1 Hiera Tiny
5
+ (https://huggingface.co/facebook/sam2.1-hiera-tiny) and SAM 2
6
+ (https://github.com/facebookresearch/sam2).
7
+ Copyright (c) Meta Platforms, Inc. and affiliates.
8
+ Licensed under the Apache License, Version 2.0.
9
+
10
+ The learned parameters are unchanged from upstream.
README.md ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ pipeline_tag: mask-generation
5
+ tags:
6
+ - libreyolo
7
+ - sam2
8
+ - promptable-segmentation
9
+ - image-segmentation
10
+ base_model: facebook/sam2.1-hiera-tiny
11
+ ---
12
+
13
+ # LibreSAM2tiny
14
+
15
+ SAM-2.1 Hiera Tiny rehosted for LibreYOLO's `LibreSAM` promptable segmentation tier.
16
+
17
+ ## Source
18
+
19
+ Derived from [`facebook/sam2.1-hiera-tiny`](https://huggingface.co/facebook/sam2.1-hiera-tiny) at commit
20
+ `de431c4043854a71d8101e17995dfe596bf101a5` and the Apache-2.0
21
+ [`facebookresearch/sam2`](https://github.com/facebookresearch/sam2) source
22
+ release.
23
+
24
+ ## Modifications
25
+
26
+ Learned parameters are unchanged. The upstream Transformers-compatible snapshot
27
+ files are mirrored here for LibreYOLO distribution. This repository adds
28
+ LibreYOLO model-card packaging plus `LICENSE` and `NOTICE` files for Apache-2.0
29
+ redistribution.
30
+
31
+ ## Usage
32
+
33
+ ```python
34
+ from libreyolo import LibreSAM
35
+
36
+ model = LibreSAM("sam2-tiny")
37
+ result = model("image.jpg", points=[500, 375], labels=[1])
38
+ ```
39
+
40
+ ## License
41
+
42
+ Apache License 2.0. See [`LICENSE`](./LICENSE) and [`NOTICE`](./NOTICE).
config.json ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Sam2VideoModel"
4
+ ],
5
+ "enable_occlusion_spatial_embedding": true,
6
+ "enable_temporal_pos_encoding_for_object_pointers": true,
7
+ "image_size": 1024,
8
+ "initializer_range": 0.02,
9
+ "mask_decoder_config": {
10
+ "attention_downsample_rate": 2,
11
+ "dynamic_multimask_stability_delta": 0.05,
12
+ "dynamic_multimask_stability_thresh": 0.98,
13
+ "dynamic_multimask_via_stability": true,
14
+ "hidden_act": "gelu",
15
+ "hidden_size": 256,
16
+ "iou_head_depth": 3,
17
+ "iou_head_hidden_dim": 256,
18
+ "mlp_dim": 2048,
19
+ "model_type": "",
20
+ "num_attention_heads": 8,
21
+ "num_hidden_layers": 2,
22
+ "num_multimask_outputs": 3
23
+ },
24
+ "mask_downsampler_embed_dim": 256,
25
+ "mask_downsampler_hidden_act": "gelu",
26
+ "mask_downsampler_kernel_size": 3,
27
+ "mask_downsampler_padding": 1,
28
+ "mask_downsampler_stride": 2,
29
+ "mask_downsampler_total_stride": 16,
30
+ "max_object_pointers_in_encoder": 16,
31
+ "memory_attention_downsample_rate": 1,
32
+ "memory_attention_dropout": 0.1,
33
+ "memory_attention_feed_forward_hidden_act": "relu",
34
+ "memory_attention_feed_forward_hidden_size": 2048,
35
+ "memory_attention_hidden_size": 256,
36
+ "memory_attention_num_attention_heads": 1,
37
+ "memory_attention_num_layers": 4,
38
+ "memory_attention_rope_dropout": 0.1,
39
+ "memory_attention_rope_feat_sizes": [
40
+ 64,
41
+ 64
42
+ ],
43
+ "memory_attention_rope_theta": 10000,
44
+ "memory_encoder_hidden_size": 256,
45
+ "memory_encoder_output_channels": 64,
46
+ "memory_fuser_embed_dim": 256,
47
+ "memory_fuser_hidden_act": "gelu",
48
+ "memory_fuser_intermediate_dim": 1024,
49
+ "memory_fuser_kernel_size": 7,
50
+ "memory_fuser_layer_scale_init_value": 1e-06,
51
+ "memory_fuser_num_layers": 2,
52
+ "memory_fuser_padding": 3,
53
+ "model_type": "sam2_video",
54
+ "multimask_max_pt_num": 1,
55
+ "multimask_min_pt_num": 0,
56
+ "multimask_output_for_tracking": true,
57
+ "multimask_output_in_sam": true,
58
+ "num_maskmem": 7,
59
+ "prompt_encoder_config": {
60
+ "hidden_act": "gelu",
61
+ "hidden_size": 256,
62
+ "image_size": 1024,
63
+ "layer_norm_eps": 1e-06,
64
+ "mask_input_channels": 16,
65
+ "model_type": "",
66
+ "num_point_embeddings": 4,
67
+ "patch_size": 16,
68
+ "scale": 1
69
+ },
70
+ "sigmoid_bias_for_mem_enc": -10.0,
71
+ "sigmoid_scale_for_mem_enc": 20.0,
72
+ "torch_dtype": "float32",
73
+ "transformers_version": "4.56.0.dev0",
74
+ "vision_config": {
75
+ "backbone_channel_list": [
76
+ 768,
77
+ 384,
78
+ 192,
79
+ 96
80
+ ],
81
+ "backbone_config": {
82
+ "_name_or_path": "",
83
+ "add_cross_attention": false,
84
+ "architectures": null,
85
+ "bad_words_ids": null,
86
+ "begin_suppress_tokens": null,
87
+ "blocks_per_stage": [
88
+ 1,
89
+ 2,
90
+ 7,
91
+ 2
92
+ ],
93
+ "bos_token_id": null,
94
+ "chunk_size_feed_forward": 0,
95
+ "cross_attention_hidden_size": null,
96
+ "decoder_start_token_id": null,
97
+ "diversity_penalty": 0.0,
98
+ "do_sample": false,
99
+ "early_stopping": false,
100
+ "embed_dim_per_stage": [
101
+ 96,
102
+ 192,
103
+ 384,
104
+ 768
105
+ ],
106
+ "encoder_no_repeat_ngram_size": 0,
107
+ "eos_token_id": null,
108
+ "exponential_decay_length_penalty": null,
109
+ "finetuning_task": null,
110
+ "forced_bos_token_id": null,
111
+ "forced_eos_token_id": null,
112
+ "global_attention_blocks": [
113
+ 5,
114
+ 7,
115
+ 9
116
+ ],
117
+ "hidden_act": "gelu",
118
+ "hidden_size": 96,
119
+ "id2label": {
120
+ "0": "LABEL_0",
121
+ "1": "LABEL_1"
122
+ },
123
+ "image_size": [
124
+ 1024,
125
+ 1024
126
+ ],
127
+ "initializer_range": 0.02,
128
+ "is_decoder": false,
129
+ "is_encoder_decoder": false,
130
+ "label2id": {
131
+ "LABEL_0": 0,
132
+ "LABEL_1": 1
133
+ },
134
+ "layer_norm_eps": 1e-06,
135
+ "length_penalty": 1.0,
136
+ "max_length": 20,
137
+ "min_length": 0,
138
+ "mlp_ratio": 4.0,
139
+ "model_type": "sam2_hiera_det_model",
140
+ "no_repeat_ngram_size": 0,
141
+ "num_attention_heads": 1,
142
+ "num_attention_heads_per_stage": [
143
+ 1,
144
+ 2,
145
+ 4,
146
+ 8
147
+ ],
148
+ "num_beam_groups": 1,
149
+ "num_beams": 1,
150
+ "num_channels": 3,
151
+ "num_query_pool_stages": 3,
152
+ "num_return_sequences": 1,
153
+ "output_attentions": false,
154
+ "output_hidden_states": false,
155
+ "output_scores": false,
156
+ "pad_token_id": null,
157
+ "patch_kernel_size": [
158
+ 7,
159
+ 7
160
+ ],
161
+ "patch_padding": [
162
+ 3,
163
+ 3
164
+ ],
165
+ "patch_stride": [
166
+ 4,
167
+ 4
168
+ ],
169
+ "prefix": null,
170
+ "problem_type": null,
171
+ "pruned_heads": {},
172
+ "query_stride": [
173
+ 2,
174
+ 2
175
+ ],
176
+ "remove_invalid_values": false,
177
+ "repetition_penalty": 1.0,
178
+ "return_dict": true,
179
+ "return_dict_in_generate": false,
180
+ "sep_token_id": null,
181
+ "suppress_tokens": null,
182
+ "task_specific_params": null,
183
+ "temperature": 1.0,
184
+ "tf_legacy_loss": false,
185
+ "tie_encoder_decoder": false,
186
+ "tie_word_embeddings": true,
187
+ "tokenizer_class": null,
188
+ "top_k": 50,
189
+ "top_p": 1.0,
190
+ "torch_dtype": null,
191
+ "torchscript": false,
192
+ "typical_p": 1.0,
193
+ "use_bfloat16": false,
194
+ "window_positional_embedding_background_size": [
195
+ 7,
196
+ 7
197
+ ],
198
+ "window_size_per_stage": [
199
+ 8,
200
+ 4,
201
+ 14,
202
+ 7
203
+ ]
204
+ },
205
+ "backbone_feature_sizes": [
206
+ [
207
+ 256,
208
+ 256
209
+ ],
210
+ [
211
+ 128,
212
+ 128
213
+ ],
214
+ [
215
+ 64,
216
+ 64
217
+ ]
218
+ ],
219
+ "fpn_hidden_size": 256,
220
+ "fpn_kernel_size": 1,
221
+ "fpn_padding": 0,
222
+ "fpn_stride": 1,
223
+ "fpn_top_down_levels": [
224
+ 2,
225
+ 3
226
+ ],
227
+ "hidden_act": "gelu",
228
+ "initializer_range": 0.02,
229
+ "layer_norm_eps": 1e-06,
230
+ "model_type": "sam2_vision_model",
231
+ "num_feature_levels": 3
232
+ }
233
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:48c14467e5cf9e51870511feb72c89688e82dd74523142c0538b663e193ac2a7
3
+ size 155908064
preprocessor_config.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "crop_size": null,
3
+ "data_format": "channels_first",
4
+ "default_to_square": true,
5
+ "device": null,
6
+ "disable_grouping": null,
7
+ "do_center_crop": null,
8
+ "do_convert_rgb": true,
9
+ "do_normalize": true,
10
+ "do_rescale": true,
11
+ "do_resize": true,
12
+ "image_mean": [
13
+ 0.485,
14
+ 0.456,
15
+ 0.406
16
+ ],
17
+ "image_processor_type": "Sam2ImageProcessorFast",
18
+ "image_std": [
19
+ 0.229,
20
+ 0.224,
21
+ 0.225
22
+ ],
23
+ "input_data_format": null,
24
+ "mask_size": {
25
+ "height": 256,
26
+ "width": 256
27
+ },
28
+ "processor_class": "Sam2VideoProcessor",
29
+ "resample": 2,
30
+ "rescale_factor": 0.00392156862745098,
31
+ "return_tensors": null,
32
+ "size": {
33
+ "height": 1024,
34
+ "width": 1024
35
+ }
36
+ }
processor_config.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "point_pad_value": -10,
3
+ "processor_class": "Sam2VideoProcessor",
4
+ "target_size": 1024
5
+ }
sam2.1_hiera_t.yaml ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # @package _global_
2
+
3
+ # Model
4
+ model:
5
+ _target_: sam2.modeling.sam2_base.SAM2Base
6
+ image_encoder:
7
+ _target_: sam2.modeling.backbones.image_encoder.ImageEncoder
8
+ scalp: 1
9
+ trunk:
10
+ _target_: sam2.modeling.backbones.hieradet.Hiera
11
+ embed_dim: 96
12
+ num_heads: 1
13
+ stages: [1, 2, 7, 2]
14
+ global_att_blocks: [5, 7, 9]
15
+ window_pos_embed_bkg_spatial_size: [7, 7]
16
+ neck:
17
+ _target_: sam2.modeling.backbones.image_encoder.FpnNeck
18
+ position_encoding:
19
+ _target_: sam2.modeling.position_encoding.PositionEmbeddingSine
20
+ num_pos_feats: 256
21
+ normalize: true
22
+ scale: null
23
+ temperature: 10000
24
+ d_model: 256
25
+ backbone_channel_list: [768, 384, 192, 96]
26
+ fpn_top_down_levels: [2, 3] # output level 0 and 1 directly use the backbone features
27
+ fpn_interp_model: nearest
28
+
29
+ memory_attention:
30
+ _target_: sam2.modeling.memory_attention.MemoryAttention
31
+ d_model: 256
32
+ pos_enc_at_input: true
33
+ layer:
34
+ _target_: sam2.modeling.memory_attention.MemoryAttentionLayer
35
+ activation: relu
36
+ dim_feedforward: 2048
37
+ dropout: 0.1
38
+ pos_enc_at_attn: false
39
+ self_attention:
40
+ _target_: sam2.modeling.sam.transformer.RoPEAttention
41
+ rope_theta: 10000.0
42
+ feat_sizes: [32, 32]
43
+ embedding_dim: 256
44
+ num_heads: 1
45
+ downsample_rate: 1
46
+ dropout: 0.1
47
+ d_model: 256
48
+ pos_enc_at_cross_attn_keys: true
49
+ pos_enc_at_cross_attn_queries: false
50
+ cross_attention:
51
+ _target_: sam2.modeling.sam.transformer.RoPEAttention
52
+ rope_theta: 10000.0
53
+ feat_sizes: [32, 32]
54
+ rope_k_repeat: True
55
+ embedding_dim: 256
56
+ num_heads: 1
57
+ downsample_rate: 1
58
+ dropout: 0.1
59
+ kv_in_dim: 64
60
+ num_layers: 4
61
+
62
+ memory_encoder:
63
+ _target_: sam2.modeling.memory_encoder.MemoryEncoder
64
+ out_dim: 64
65
+ position_encoding:
66
+ _target_: sam2.modeling.position_encoding.PositionEmbeddingSine
67
+ num_pos_feats: 64
68
+ normalize: true
69
+ scale: null
70
+ temperature: 10000
71
+ mask_downsampler:
72
+ _target_: sam2.modeling.memory_encoder.MaskDownSampler
73
+ kernel_size: 3
74
+ stride: 2
75
+ padding: 1
76
+ fuser:
77
+ _target_: sam2.modeling.memory_encoder.Fuser
78
+ layer:
79
+ _target_: sam2.modeling.memory_encoder.CXBlock
80
+ dim: 256
81
+ kernel_size: 7
82
+ padding: 3
83
+ layer_scale_init_value: 1e-6
84
+ use_dwconv: True # depth-wise convs
85
+ num_layers: 2
86
+
87
+ num_maskmem: 7
88
+ image_size: 1024
89
+ # apply scaled sigmoid on mask logits for memory encoder, and directly feed input mask as output mask
90
+ # SAM decoder
91
+ sigmoid_scale_for_mem_enc: 20.0
92
+ sigmoid_bias_for_mem_enc: -10.0
93
+ use_mask_input_as_output_without_sam: true
94
+ # Memory
95
+ directly_add_no_mem_embed: true
96
+ no_obj_embed_spatial: true
97
+ # use high-resolution feature map in the SAM mask decoder
98
+ use_high_res_features_in_sam: true
99
+ # output 3 masks on the first click on initial conditioning frames
100
+ multimask_output_in_sam: true
101
+ # SAM heads
102
+ iou_prediction_use_sigmoid: True
103
+ # cross-attend to object pointers from other frames (based on SAM output tokens) in the encoder
104
+ use_obj_ptrs_in_encoder: true
105
+ add_tpos_enc_to_obj_ptrs: true
106
+ proj_tpos_enc_in_obj_ptrs: true
107
+ use_signed_tpos_enc_to_obj_ptrs: true
108
+ only_obj_ptrs_in_the_past_for_eval: true
109
+ # object occlusion prediction
110
+ pred_obj_scores: true
111
+ pred_obj_scores_mlp: true
112
+ fixed_no_obj_ptr: true
113
+ # multimask tracking settings
114
+ multimask_output_for_tracking: true
115
+ use_multimask_token_for_obj_ptr: true
116
+ multimask_min_pt_num: 0
117
+ multimask_max_pt_num: 1
118
+ use_mlp_for_obj_ptr_proj: true
119
+ # Compilation flag
120
+ # HieraT does not currently support compilation, should always be set to False
121
+ compile_image_encoder: False
sam2.1_hiera_tiny.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7402e0d864fa82708a20fbd15bc84245c2f26dff0eb43a4b5b93452deb34be69
3
+ size 156008466
video_preprocessor_config.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "crop_size": null,
3
+ "data_format": "channels_first",
4
+ "default_to_square": true,
5
+ "device": null,
6
+ "do_center_crop": null,
7
+ "do_convert_rgb": true,
8
+ "do_normalize": true,
9
+ "do_pad": null,
10
+ "do_rescale": true,
11
+ "do_resize": true,
12
+ "do_sample_frames": null,
13
+ "fps": null,
14
+ "image_mean": [
15
+ 0.485,
16
+ 0.456,
17
+ 0.406
18
+ ],
19
+ "image_std": [
20
+ 0.229,
21
+ 0.224,
22
+ 0.225
23
+ ],
24
+ "input_data_format": null,
25
+ "num_frames": null,
26
+ "processor_class": "Sam2VideoProcessor",
27
+ "resample": 2,
28
+ "rescale_factor": 0.00392156862745098,
29
+ "size": {
30
+ "height": 1024,
31
+ "width": 1024
32
+ },
33
+ "size_divisor": null,
34
+ "video_metadata": null,
35
+ "video_processor_type": "Sam2VideoVideoProcessor"
36
+ }