─░├žeri─če ge├ž

Referans i├žin ultralytics/models/sam/modules/sam.py

Not

Bu dosya https://github.com/ultralytics/ultralytics/blob/main/ ultralytics/models/ sam/modules/ sam.py adresinde mevcuttur. Bir sorun tespit ederseniz l├╝tfen bir ├çekme ─░ste─či ­čŤá´ŞĆ ile katk─▒da bulunarak d├╝zeltilmesine yard─▒mc─▒ olun. Te┼čekk├╝rler ­čÖĆ!



ultralytics.models.sam.modules.sam.Sam

├ťsler: Module

Sam (Segment Anything Model) nesne segmentasyon g├Ârevleri i├žin tasarlanm─▒┼čt─▒r. G├Âr├╝nt├╝ olu┼čturmak i├žin g├Âr├╝nt├╝ kodlay─▒c─▒lar─▒ kullan─▒r kat─▒┼čt─▒rmalar ve ├že┼čitli giri┼č istemlerini kodlamak i├žin istem kodlay─▒c─▒lar. Bu kat─▒┼čt─▒rmalar daha sonra maske taraf─▒ndan kullan─▒l─▒r nesne maskelerini tahmin etmek i├žin kod ├ž├Âz├╝c├╝.

Nitelikler:

─░sim Tip A├ž─▒klama
mask_threshold float

Maske tahmini i├žin e┼čik de─čeri.

image_format str

Giri┼č g├Âr├╝nt├╝s├╝n├╝n bi├žimi, varsay─▒lan 'RGB'dir.

image_encoder ImageEncoderViT

G├Âr├╝nt├╝y├╝ g├Âm├╝lere kodlamak i├žin kullan─▒lan omurga.

prompt_encoder PromptEncoder

├çe┼čitli t├╝rdeki giri┼č istemlerini kodlar.

mask_decoder MaskDecoder

G├Âr├╝nt├╝den nesne maskelerini ve h─▒zl─▒ kat─▒┼čt─▒rmalar─▒ tahmin eder.

pixel_mean List[float]

G├Âr├╝nt├╝ normalizasyonu i├žin ortalama piksel de─čerleri.

pixel_std List[float]

G├Âr├╝nt├╝ normalizasyonu i├žin standart sapma de─čerleri.

Kaynak kodu ultralytics/models/sam/modules/sam.py
class Sam(nn.Module):
    """
    Sam (Segment Anything Model) is designed for object segmentation tasks. It uses image encoders to generate image
    embeddings, and prompt encoders to encode various types of input prompts. These embeddings are then used by the mask
    decoder to predict object masks.

    Attributes:
        mask_threshold (float): Threshold value for mask prediction.
        image_format (str): Format of the input image, default is 'RGB'.
        image_encoder (ImageEncoderViT): The backbone used to encode the image into embeddings.
        prompt_encoder (PromptEncoder): Encodes various types of input prompts.
        mask_decoder (MaskDecoder): Predicts object masks from the image and prompt embeddings.
        pixel_mean (List[float]): Mean pixel values for image normalization.
        pixel_std (List[float]): Standard deviation values for image normalization.
    """

    mask_threshold: float = 0.0
    image_format: str = "RGB"

    def __init__(
        self,
        image_encoder: ImageEncoderViT,
        prompt_encoder: PromptEncoder,
        mask_decoder: MaskDecoder,
        pixel_mean: List[float] = (123.675, 116.28, 103.53),
        pixel_std: List[float] = (58.395, 57.12, 57.375),
    ) -> None:
        """
        Initialize the Sam class to predict object masks from an image and input prompts.

        Note:
            All forward() operations moved to SAMPredictor.

        Args:
            image_encoder (ImageEncoderViT): The backbone used to encode the image into image embeddings.
            prompt_encoder (PromptEncoder): Encodes various types of input prompts.
            mask_decoder (MaskDecoder): Predicts masks from the image embeddings and encoded prompts.
            pixel_mean (List[float], optional): Mean values for normalizing pixels in the input image. Defaults to
                (123.675, 116.28, 103.53).
            pixel_std (List[float], optional): Std values for normalizing pixels in the input image. Defaults to
                (58.395, 57.12, 57.375).
        """
        super().__init__()
        self.image_encoder = image_encoder
        self.prompt_encoder = prompt_encoder
        self.mask_decoder = mask_decoder
        self.register_buffer("pixel_mean", torch.Tensor(pixel_mean).view(-1, 1, 1), False)
        self.register_buffer("pixel_std", torch.Tensor(pixel_std).view(-1, 1, 1), False)

__init__(image_encoder, prompt_encoder, mask_decoder, pixel_mean=(123.675, 116.28, 103.53), pixel_std=(58.395, 57.12, 57.375))

Bir g├Âr├╝nt├╝den ve giri┼č istemlerinden nesne maskelerini tahmin etmek i├žin Sam s─▒n─▒f─▒n─▒ ba┼člat─▒n.

Not

T├╝m forward() i┼člemleri SAMPredictor'a ta┼č─▒nd─▒.

Parametreler:

─░sim Tip A├ž─▒klama Varsay─▒lan
image_encoder ImageEncoderViT

G├Âr├╝nt├╝y├╝ g├Âr├╝nt├╝ g├Âm├╝lerine kodlamak i├žin kullan─▒lan omurga.

gerekli
prompt_encoder PromptEncoder

├çe┼čitli t├╝rdeki giri┼č istemlerini kodlar.

gerekli
mask_decoder MaskDecoder

G├Âr├╝nt├╝ kat─▒┼čt─▒rmalar─▒ndan ve kodlanm─▒┼č istemlerden maskeleri tahmin eder.

gerekli
pixel_mean List[float]

Giri┼č g├Âr├╝nt├╝s├╝ndeki pikselleri normalle┼čtirmek i├žin ortalama de─čerler. Varsay─▒lan de─čer (123.675, 116.28, 103.53).

(123.675, 116.28, 103.53)
pixel_std List[float]

Girdi g├Âr├╝nt├╝s├╝ndeki pikselleri normalle┼čtirmek i├žin standart de─čerler. Varsay─▒lan de─čer (58.395, 57.12, 57.375).

(58.395, 57.12, 57.375)
Kaynak kodu ultralytics/models/sam/modules/sam.py
def __init__(
    self,
    image_encoder: ImageEncoderViT,
    prompt_encoder: PromptEncoder,
    mask_decoder: MaskDecoder,
    pixel_mean: List[float] = (123.675, 116.28, 103.53),
    pixel_std: List[float] = (58.395, 57.12, 57.375),
) -> None:
    """
    Initialize the Sam class to predict object masks from an image and input prompts.

    Note:
        All forward() operations moved to SAMPredictor.

    Args:
        image_encoder (ImageEncoderViT): The backbone used to encode the image into image embeddings.
        prompt_encoder (PromptEncoder): Encodes various types of input prompts.
        mask_decoder (MaskDecoder): Predicts masks from the image embeddings and encoded prompts.
        pixel_mean (List[float], optional): Mean values for normalizing pixels in the input image. Defaults to
            (123.675, 116.28, 103.53).
        pixel_std (List[float], optional): Std values for normalizing pixels in the input image. Defaults to
            (58.395, 57.12, 57.375).
    """
    super().__init__()
    self.image_encoder = image_encoder
    self.prompt_encoder = prompt_encoder
    self.mask_decoder = mask_decoder
    self.register_buffer("pixel_mean", torch.Tensor(pixel_mean).view(-1, 1, 1), False)
    self.register_buffer("pixel_std", torch.Tensor(pixel_std).view(-1, 1, 1), False)





Created 2023-11-12, Updated 2024-06-02
Authors: glenn-jocher (5), Burhan-Q (1)