Run SAM 2 locally with OpenEye
Segment Anything Model 2 for precise object boundaries. Automatic mask generation for any object in any image. Used in scene graph construction and spatial reasoning. OpenEye, the open-source perception CLI, downloads SAM 2, runs it on your CPU or GPU, and returns structured JSON you can pipe into scripts, agents, and robots.
| Task | Segmentation |
|---|---|
| CLI id | sam2 |
| Creator | Meta AI |
| Weights | facebook/sam2-hiera-small (~150 MB) |
| Hardware | CPU, NVIDIA CUDA, Apple Silicon (MPS) |
| Install extra | openeye-sh[sam] |
1. Install
pipx install "openeye-sh[sam]"2. Pull SAM 2
openeye pull sam23. Run inference
Output is JSON on stdout, so it composes with jq and any other Unix tool.
openeye run sam2 photo.jpg --pretty4. Serve it as an API
Start a local server with REST and WebSocket endpoints for apps, agents, and live camera streams.
openeye serve sam2See the serve reference, REST endpoints, and Python SDK.