Reference for ultralytics/models/sam/modules/sam.py
Note
Full source code for this file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/sam/modules/sam.py. Help us fix any issues you see by submitting a Pull Request 🛠️. Thank you 🙏!
ultralytics.models.sam.modules.sam.Sam
Bases: Module
Source code in ultralytics/models/sam/modules/sam.py
__init__(image_encoder, prompt_encoder, mask_decoder, pixel_mean=(123.675, 116.28, 103.53), pixel_std=(58.395, 57.12, 57.375))
SAM predicts object masks from an image and input prompts.
Note
All forward() operations moved to SAMPredictor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_encoder |
ImageEncoderViT
|
The backbone used to encode the image into image embeddings that allow for efficient mask prediction. |
required |
prompt_encoder |
PromptEncoder
|
Encodes various types of input prompts. |
required |
mask_decoder |
MaskDecoder
|
Predicts masks from the image embeddings and encoded prompts. |
required |
pixel_mean |
list(float
|
Mean values for normalizing pixels in the input image. |
(123.675, 116.28, 103.53)
|
pixel_std |
list(float
|
Std values for normalizing pixels in the input image. |
(58.395, 57.12, 57.375)
|