SAM is a pretrained segmentation model for identifying objects at pixel level from prompts rather than a fixed class list. Its broad capability comes from training on 11 million images, more than 1 billion masks, and diverse natural-image objects. section 11.3 section 11.4
Segmenting an object with a point
Load SAM through KerasHub's ImageSegmenter, provide an image, a foreground point, and its label, then inspect the returned masks. A point on a peach produces a good mask; a point on a banana can produce alternatives, including a mask covering both bananas. section 11.3.1 section 11.3.4
Use SAM with these prompt patterns:
- Point prompts select an object with foreground points labeled 1; add background points labeled 0 when the intended region is ambiguous. section 11.3.4
- Box prompts provide approximate top-left and bottom-right corners around the target object; precise boundaries are unnecessary. section 11.3.5
- Each prompt can return four 256 × 256 candidate masks ranked by predicted match quality. section 11.3.4
SAM combines an image encoder, a prompt encoder, and a mask decoder. The image becomes an embedding, the prompt becomes an embedded vector, and the decoder predicts masks for the indicated object. Its architecture is explained at a high level rather than through encoder or decoder internals. section 11.3.2
import keras_hub model = keras_hub.models.ImageSegmenter.from_preset("sam_huge_sa1b")
The KerasHub initialization listing shows the shortest path to downloading the sam_huge_sa1b preset and creating an ImageSegmenter. section 11.3.1


