Tutorial — Multi-modal AI
Segment images with SAM 2
The segmentation runtime exposes SAM 2 base/large, EdgeSAM, and MobileSAM. Pass point or box prompts; the encoder caches per-image embeddings and the decoder returns mask data.
- Level
- Intermediate
- Time
- ~15 min
- Prerequisites
- Tenzro CLI installed, sample image
- Stack
- CLI · JSON-RPC
01
Load SAM 2
SAM 2 is under Meta's commercial-custom terms — accept the license once.
curl -X POST https://rpc.tenzro.network -H 'content-type: application/json' -d '{"jsonrpc":"2.0","id":1,"method":"tenzro_loadSegmentationModel","params":["sam2-base"]}'02
Run a point-prompted segmentation
Pass coordinate triples as x,y,label where label is 1=foreground, 0=background.
tenzro segment image.png \
--model sam2-base \
--points "412,310,1" --points "120,500,0"03
Run a box-prompted segmentation
Pass a single bounding box for object-level masks.
tenzro segment image.png \
--model sam2-large \
--box "120,80,540,420"04
Call from JSON-RPC
The RPC method returns mask bytes plus IOU scores.
curl -s https://rpc.tenzro.network -H 'content-type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"tenzro_segment","params":{"model":"sam2-base","image_b64":"...","prompts":[{"type":"point","x":412,"y":310,"label":1}]}}'Related