https://github.com/kazuhito00/segment-anything-model-onnx-sample
segment-anything のエンコーダー/デコーダーをONNXに変換し、推論するサンプル
https://github.com/kazuhito00/segment-anything-model-onnx-sample
colaboratory onnx python sam segment-anything segment-anything-model
Last synced: 2 months ago
JSON representation
segment-anything のエンコーダー/デコーダーをONNXに変換し、推論するサンプル
- Host: GitHub
- URL: https://github.com/kazuhito00/segment-anything-model-onnx-sample
- Owner: Kazuhito00
- License: apache-2.0
- Created: 2024-04-10T16:38:18.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-10T17:05:41.000Z (over 1 year ago)
- Last Synced: 2025-07-22T00:59:01.936Z (3 months ago)
- Topics: colaboratory, onnx, python, sam, segment-anything, segment-anything-model
- Language: Jupyter Notebook
- Homepage:
- Size: 4.19 MB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Segment-Anything-Model-ONNX-Sample
[facebookresearch/segment-anything](https://github.com/facebookresearch/segment-anything) のエンコーダー/デコーダーをONNXに変換し、推論するサンプルです。
推論スクリプトは、前処理、後処理を含めPyTorch依存の処理は使用しない方針です。https://github.com/Kazuhito00/Segment-Anything-Model-ONNX-Sample/assets/37477845/18428108-49ef-4683-80c8-4ea2a4fce62c
# Usage
#### ONNX変換、推論テスト
[](https://colab.research.google.com/github/Kazuhito00/Segment-Anything-Model-ONNX-Sample/blob/main/Segment-Anything-Model-ONNX.ipynb)
Colaboratoryでノートブックを開き、上から順に実行してください。#### 簡易デモ
Colaboratoryノートブックで変換したONNXファイルを「onnx_model」ディレクトリに格納し、
以下コマンドでデモを起動してください。
左クリックでプロンプト座標を追加、右クリックでプロンプト座標を削除します。
また、キーボード1~3で、クリック時に追加する座標のタイプを変更します(1:対象座標、2:非対象座標、3:対象バウンディングボックス)
```
python demo.py
```
* --image
画像ファイルの指定
デフォルト:sample.png
* --encoder
エンコーダーONNXファイルのパス
デフォルト:onnx_model/vit_b_encoder.onnx
* --decoder
デコーダーONNXファイルのパス
デフォルト:onnx_model/vit_b_decoder.onnx# Note
サンプルの画像は[ぱくたそ](https://www.pakutaso.com/)様の「[トゲトゲのサボテンとハリネズミ](https://www.pakutaso.com/20190257050post-19488.html)」を使用しています。# License
Segment-Anything-Model-ONNX-Sample is under [Apache-2.0 license](LICENSE).# Author
高橋かずひと(https://twitter.com/KzhtTkhs)