Run Segment Anything with ONNX models
Project description
segment-anything-onnx
Use ONNX models for Segment Anything inference.
Special thanks to:
- Viet-Anh NGUYEN for creating the SAM Exporter libraries from which these files are derived.
- The Segment Anything team at Meta AI Research
Usage from Source
- Clone Segment Anything ONNX from Github
git clone git@github.com:whatstyle-ai/segment-anything-onnx.git cd segment-anything-onnx pip install -e .
- Use the SAM Exporter to generate the ONNX models
- Copy the ONNX models to the segment-anything-onnx/models directory
- Predict some masks
cd segment-anything-onnx ./demo.sh
Usage from pip install
- Use the SAM Exporter to generate the ONNX models, or obtain the ONNX models from another source
- Copy the ONNX models to a "models" directory, such as:
models/sam_vit_l_0b3195.decoder.onnx
- Install Segment Anything ONNX using pip:
pip install segment-anything-onnx
- Predict a mask:
from segment_anything_onnx import predict_masks image = cv2.imread('args.image') prompt = json.load(open(args.prompt)) predict_masks( 'models/sam_vit_l_0b3195.encoder.onnx', 'models/sam_vit_l_0b3195.decoder.onnx', image, prompt, options )
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file segment_anything_onnx-0.0.3.tar.gz.
File metadata
- Download URL: segment_anything_onnx-0.0.3.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8b0a2476df593b053ea1726891879fddc06b967c4b985ac17ce8283137a95d9
|
|
| MD5 |
ede4fe0eb897842933e1e2879e962f75
|
|
| BLAKE2b-256 |
5f76e717fdbdcb85a3422e9307423a286e1e0db3c8759370b21fcd8df5021b79
|
File details
Details for the file segment_anything_onnx-0.0.3-py3-none-any.whl.
File metadata
- Download URL: segment_anything_onnx-0.0.3-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce1aeed31530b45c4b32be5d60b310af7ab4d7ed150608cdc4e9a7a5208058ac
|
|
| MD5 |
4e7c5e84b40ab791d9f123558d1e8050
|
|
| BLAKE2b-256 |
6729031dea2c8d70113d8c55d8f5e5e4364f452c752545a690f57bf57b7639c3
|