From: Jiří Podivín Date: Thu, 2 Nov 2023 19:24:10 +0000 (+0100) Subject: sam : update documentation to provide executable example (#596) X-Git-Tag: upstream/0.0.1642~1203 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=4058f5bc987114ce539a4195583fb1f65edcb999;p=pkg%2Fggml%2Fsources%2Fggml sam : update documentation to provide executable example (#596) Also adds the example sample image to the repo to simplify replication. Signed-off-by: Jiri Podivin --- diff --git a/examples/sam/README.md b/examples/sam/README.md index 1e807c74..1eef7e78 100644 --- a/examples/sam/README.md +++ b/examples/sam/README.md @@ -27,26 +27,24 @@ cd ggml # Install Python dependencies python3 -m pip install -r requirements.txt +# Download PTH model +wget -P examples/sam/ https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth + # Convert PTH model to ggml -python convert-pth-to-ggml.py examples/sam/sam_vit_b_01ec64.pth . 1 +python examples/sam/convert-pth-to-ggml.py examples/sam/sam_vit_b_01ec64.pth examples/sam/ 1 # Build ggml + examples mkdir build && cd build cmake .. && make -j4 # run inference -./bin/sam -t 16 -i ../img.jpg -m examples/sam/ggml-model-f16.bin +./bin/sam -t 16 -i ../examples/sam/example.jpg -m ../examples/sam/ggml-model-f16.bin ``` ## Downloading and converting the model checkpoints You can download a [model checkpoint](https://github.com/facebookresearch/segment-anything/tree/main#model-checkpoints) and convert it to `ggml` format using the script `convert-pth-to-ggml.py`: -``` -# Convert PTH model to ggml -python convert-pth-to-ggml.py examples/sam/sam_vit_b_01ec64.pth . 1 -``` - ## Example output on M2 Ultra ``` $ ▶ make -j sam && time ./bin/sam -t 8 -i img.jpg diff --git a/examples/sam/example.jpg b/examples/sam/example.jpg new file mode 100644 index 00000000..9d5116e8 Binary files /dev/null and b/examples/sam/example.jpg differ