vietanhdev
commited on
Commit
•
cd5a2fa
1
Parent(s):
cf3d69d
Add zip models
Browse files
.gitattributes
CHANGED
@@ -33,3 +33,7 @@ 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 |
+
sam2_hiera_base_plus.zip filter=lfs diff=lfs merge=lfs -text
|
37 |
+
sam2_hiera_large.zip filter=lfs diff=lfs merge=lfs -text
|
38 |
+
sam2_hiera_small.zip filter=lfs diff=lfs merge=lfs -text
|
39 |
+
sam2_hiera_tiny.zip filter=lfs diff=lfs merge=lfs -text
|
sam2_hiera_tiny_decoder.onnx → sam2_hiera_base_plus.zip
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c56282103c2bf99bdab07d2dddb1be67c03d71659ade3f9dcf1d7001fda582fb
|
3 |
+
size 360422777
|
sam2_hiera_tiny_encoder.onnx → sam2_hiera_large.zip
RENAMED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a967ef6e54794e9494c8b71201766532b7b2929fe18f56b8e63940e97dc671ac
|
3 |
+
size 910003530
|
sam2_hiera_small.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4ef9047eb7fc7e36041c88a9f968c3c0b1d1640b88ef66d754b7d558a10cee38
|
3 |
+
size 183345019
|
sam2_hiera_tiny.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7454c3afd835b2acaad863afe3acb11f4e4af039c96e886989ad3873a338e1ec
|
3 |
+
size 154902833
|
zip_models.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import zipfile
|
3 |
+
import yaml
|
4 |
+
|
5 |
+
version = "20240803"
|
6 |
+
base_name_to_model_name = {
|
7 |
+
"sam2_hiera_tiny": "Segment Anything 2 (Hiera-Tiny)",
|
8 |
+
"sam2_hiera_small": "Segment Anything 2 (Hiera-Small)",
|
9 |
+
"sam2_hiera_base_plus": "Segment Anything 2 (Hiera-Base+)",
|
10 |
+
"sam2_hiera_large": "Segment Anything 2 (Hiera-Large)",
|
11 |
+
}
|
12 |
+
|
13 |
+
model_list = {}
|
14 |
+
onnx_files = [f for f in os.listdir(".") if f.endswith(".onnx")]
|
15 |
+
for onnx_file in onnx_files:
|
16 |
+
model_base_name, model_part, _ = onnx_file.split(".")
|
17 |
+
if model_base_name not in model_list:
|
18 |
+
model_list[model_base_name] = {}
|
19 |
+
model_list[model_base_name]["type"] = "segment_anything"
|
20 |
+
model_list[model_base_name]["input_size"] = 1024
|
21 |
+
model_list[model_base_name]["max_width"] = 1024
|
22 |
+
model_list[model_base_name]["max_height"] = 1024
|
23 |
+
if model_part == "encoder":
|
24 |
+
model_list[model_base_name]["encoder_model_path"] = onnx_file
|
25 |
+
elif model_part == "decoder":
|
26 |
+
model_list[model_base_name]["decoder_model_path"] = onnx_file
|
27 |
+
model_list[model_base_name]["basename"] = model_base_name
|
28 |
+
model_list[model_base_name]["name"] = model_base_name + "_" + version
|
29 |
+
model_list[model_base_name]["display_name"] = base_name_to_model_name[model_base_name]
|
30 |
+
|
31 |
+
for model in model_list.values():
|
32 |
+
output_zip = model.pop("basename") + ".zip"
|
33 |
+
with zipfile.ZipFile(output_zip, "w") as z:
|
34 |
+
z.write(model["encoder_model_path"])
|
35 |
+
z.write(model["decoder_model_path"])
|
36 |
+
# Save config in yaml
|
37 |
+
with z.open("config.yaml", "w") as f:
|
38 |
+
f.write(yaml.dump(model).encode("utf-8"))
|