lazyslide_models.segmentation.SAM

lazyslide_models.segmentation.SAM#

class SAM(variant='facebook/sam-vit-base', model_path=None, token=None)#

Bases: SegmentationModel

sam GitHub Paper 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).