karelnagel / sam-rs

Meta Segment Anything model (SAM), rewritten in rust using Burn.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Converting models

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:

  1. Load the weights in python
  2. Convert them into json a json file that can be read by the rust code
  3. Rust loads the model from that json file
  4. Rust saves the model as a binary file, to minimize file size and optimize for faster load.
  5. (You can delete the json file in ~/Documents/sam-models/<name>)

About

Meta Segment Anything model (SAM), rewritten in rust using Burn.


Languages

Language:Jupyter Notebook 92.9%Language:Rust 6.8%Language:TypeScript 0.3%Language:Python 0.0%Language:HTML 0.0%Language:JavaScript 0.0%Language:CSS 0.0%