]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
sam : update documentation to provide executable example (#596)
authorJiří Podivín <redacted>
Thu, 2 Nov 2023 19:24:10 +0000 (20:24 +0100)
committerGitHub <redacted>
Thu, 2 Nov 2023 19:24:10 +0000 (21:24 +0200)
Also adds the example sample image to the repo to simplify replication.

Signed-off-by: Jiri Podivin <redacted>
examples/sam/README.md
examples/sam/example.jpg [new file with mode: 0644]

index 1e807c7405dd32075ab18c5da1e05fdd02c82bdd..1eef7e78624ef936687b744c806e255201a0c22b 100644 (file)
@@ -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 (file)
index 0000000..9d5116e
Binary files /dev/null and b/examples/sam/example.jpg differ