Skip to main content

Run Segment Anything with ONNX models

Project description

segment-anything-onnx

Use ONNX models for Segment Anything inference.

Special thanks to:

Usage from Source

  1. Clone Segment Anything ONNX from Github
    git clone git@github.com:whatstyle-ai/segment-anything-onnx.git
    cd segment-anything-onnx
    pip install -e .
    
  2. Use the SAM Exporter to generate the ONNX models
  3. Copy the ONNX models to the segment-anything-onnx/models directory
  4. Predict some masks
    cd segment-anything-onnx
    ./demo.sh
    

Usage from pip install

  1. Use the SAM Exporter to generate the ONNX models, or obtain the ONNX models from another source
  2. Copy the ONNX models to a "models" directory, such as:
    models/sam_vit_l_0b3195.decoder.onnx
    
  3. Install Segment Anything ONNX using pip:
    pip install segment-anything-onnx
    
  4. 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

segment_anything_onnx-0.0.3.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

segment_anything_onnx-0.0.3-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

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

Hashes for segment_anything_onnx-0.0.3.tar.gz
Algorithm Hash digest
SHA256 a8b0a2476df593b053ea1726891879fddc06b967c4b985ac17ce8283137a95d9
MD5 ede4fe0eb897842933e1e2879e962f75
BLAKE2b-256 5f76e717fdbdcb85a3422e9307423a286e1e0db3c8759370b21fcd8df5021b79

See more details on using hashes here.

File details

Details for the file segment_anything_onnx-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for segment_anything_onnx-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ce1aeed31530b45c4b32be5d60b310af7ab4d7ed150608cdc4e9a7a5208058ac
MD5 4e7c5e84b40ab791d9f123558d1e8050
BLAKE2b-256 6729031dea2c8d70113d8c55d8f5e5e4364f452c752545a690f57bf57b7639c3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page