SAM
SAM, or Segment Anything Model, is a pretrained promptable computer-vision model that generates segmentation masks for objects in images.
Deep Learning with PyTorch, Second Edition
A transformer-based image segmentation model designed to generalize to many objects and support prompt-driven, zero-shot mask prediction.
- How it is used
- Uses prompted segmentation to mark candidate nodule regions on CT images before classification.
- How deep it goes
- Explains the three components and works through pretrained inference, but does not implement SAM from scratch.
- Examples
- Demonstrates automatic masks on an image, a point-guided dog-nose mask, and candidate nodule masks on CT images.
- What you can do after
- Apply it via the Segment Anything library to generate automatic masks or point-prompted masks with pretrained weights.
Read how Deep Learning with PyTorch, Second Edition explains SAM →
Deep Learning with Python, Third Edition
A pretrained segmentation model available through KerasHub for prompting-based segmentation tasks.
- How it is used
- Deploys prompting-based image segmentation when labeled training data or a predefined object-class list is limiting.
- How deep it goes
- Explains the high-level architecture and demonstrates point and box inference, while deferring prompt-encoder and mask-decoder internals.
- Examples
- Demonstrates peach, banana, and mango segmentation using foreground points, alternative masks, and an approximate box.
- What you can do after
- Apply SAM through KerasHub to generate object masks from point or box prompts and inspect alternative predictions.
Read how Deep Learning with Python, Third Edition explains SAM →
Deep Learning with R, Third Edition
Segment Anything is a promptable image-segmentation model that generates segmentation masks from images and user-provided prompts.
- How it is used
- Applies pretrained promptable segmentation to objects selected by points or boxes.
- How deep it goes
- Explains inputs, embeddings, and major components while deferring prompt-encoder and mask-decoder details.
- Examples
- Demonstrates segmenting a mango with a box prompt and displaying the resulting mask.
- What you can do after
- Apply SAM via KerasHub to generate masks from images and point or box prompts.
Related concepts
- pretrained modelkind of · A pretrained model is a machine-learning model whose parameters were learned through prior training before it is used or adapted for a subsequent task.
- segmentation maskuses · A segmentation mask is an image-shaped array that assigns each pixel or spatial element to a class, object, region, or corresponding segmentation value.
- prompt encoderhas part · A prompt encoder is a model component that transforms an input prompt into an embedded numerical representation for downstream processing.
- point promptused by · A point prompt is an input specifying one or more locations in an image to guide segmentation toward relevant foreground, background, or target regions.
- visual encoderhas part · A visual encoder is a neural-network component that transforms images into numerical representations for comparison, generation, or downstream processing.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


