To convert models, drop the model file into sam-convert
folder, and run cargo run --release -- <vit_h | vit_b | vit_l | test> <file_name> <?skip_python>
. The converted model will be in the same folder as the original model, with the same name, but with the extension .bin.gz
. It will take quite a long time, and needs some disk space (the middle json file is up to 16 GB for larger models).
This will:
- Load the weights in python
- Convert them into json a json file that can be read by the rust code
- Rust loads the model from that json file
- Rust saves the model as a binary file, to minimize file size and optimize for faster load.
- (You can delete the json file in
~/Documents/sam-models/<name>
)