This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| build: | |
| gpu: true | |
| cuda: "12.1" | |
| python_version: "3.11" | |
| python_packages: | |
| - "torch==2.4.0" | |
| - "torchvision==0.19.0" | |
| - "onnxruntime-gpu==1.20.0" | |
| - "Pillow==10.4.0" | |
| - "numpy==1.26.4" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // lib/sam2-decoder.ts | |
| // Browser-side decoder for SAM2 hybrid deployment. | |
| // Loads sam2.1_hiera_large.decoder.onnx (~16 MB) via onnxruntime-web on WebGPU. | |
| // Pairs with the encoder bundle produced by the companion notebook. | |
| // Full article: https://jeanrojas.com/blog/splitting-sam2-encoder-decoder | |
| import * as ort from "onnxruntime-web/webgpu"; | |
| export interface Embedding { | |
| imageEmbed: ort.Tensor; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Cell 1 — pin a working torch + the ONNX toolchain. | |
| pip install --quiet \ | |
| torch==2.4.0 \ | |
| torchvision==0.19.0 \ | |
| onnx onnxscript onnxsim onnxruntime samexporter | |
| pip install --quiet git+https://github.com/facebookresearch/segment-anything-2.git |