-
-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathconvert_sam3.sh
More file actions
executable file
·32 lines (27 loc) · 859 Bytes
/
Copy pathconvert_sam3.sh
File metadata and controls
executable file
·32 lines (27 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# Export SAM3 ViT-H to ONNX.
#
# Requirements:
# - sam3 submodule initialised: git submodule update --init sam3
# - osam installed for CLIP tokenisation: pip install osam
#
# Optional: pass --simplify to run onnxsim after export (reduces some
# redundant ops; vision_pos_enc_0/1 may be removed from the decoder).
set -euo pipefail
OUTPUT_DIR="${1:-output_models/sam3}"
SIMPLIFY="${SIMPLIFY:-}"
echo "Exporting SAM3 ViT-H to ONNX → $OUTPUT_DIR"
if [ -n "$SIMPLIFY" ]; then
python -m samexporter.export_sam3 \
--output_dir "$OUTPUT_DIR" \
--opset 18 \
--simplify
else
python -m samexporter.export_sam3 \
--output_dir "$OUTPUT_DIR" \
--opset 18
fi
echo "Done – models written to $OUTPUT_DIR/"
echo " sam3_image_encoder.onnx"
echo " sam3_language_encoder.onnx"
echo " sam3_decoder.onnx"