lazyslide.models.segmentation.SAM#
- class SAM(variant='facebook/sam-vit-base', model_path=None, token=None)#
Bases:
SegmentationModelGitHub Paper FLOPs: 975.67G Apache 2.0 SAM model for image segmentation
- get_image_embedding(image)#
Get the image embedding from the SAM model.
- Returns:
torch.Tensor: Image embedding tensor of shape (1, C, H, W).
- segment(image, image_embedding=None, input_points=None, input_labels=None, input_boxes=None, segmentation_maps=None, multimask_output=False)#
Segment the input image using the SAM model.
- Args:
image (torch.Tensor): Input image tensor of shape (C, H, W).
- Returns:
torch.Tensor: Segmentation mask tensor of shape (H, W).
- supported_output()#
Returns the supported output types for the SAM model.