brails.processors.vlm_segmenter.segment_anything.modeling.mask_decoder_hq module
- class brails.processors.vlm_segmenter.segment_anything.modeling.mask_decoder_hq.MLP(input_dim: int, hidden_dim: int, output_dim: int, num_layers: int, sigmoid_output: bool = False)
Bases:
Module
- forward(x)
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class brails.processors.vlm_segmenter.segment_anything.modeling.mask_decoder_hq.MaskDecoderHQ(*, transformer_dim: int, transformer: ~torch.nn.modules.module.Module, num_multimask_outputs: int = 3, activation: ~typing.Type[~torch.nn.modules.module.Module] = <class 'torch.nn.modules.activation.GELU'>, iou_head_depth: int = 3, iou_head_hidden_dim: int = 256, vit_dim: int = 1024)
Bases:
Module
- forward(image_embeddings: Tensor, image_pe: Tensor, sparse_prompt_embeddings: Tensor, dense_prompt_embeddings: Tensor, multimask_output: bool, hq_token_only: bool, interm_embeddings: Tensor) Tuple[Tensor, Tensor]
Predict masks given image and prompt embeddings.
- Arguments:
image_embeddings (torch.Tensor): the embeddings from the ViT image encoder image_pe (torch.Tensor): positional encoding with the shape of image_embeddings sparse_prompt_embeddings (torch.Tensor): the embeddings of the points and boxes dense_prompt_embeddings (torch.Tensor): the embeddings of the mask inputs multimask_output (bool): Whether to return multiple masks or a single
mask.
- Returns:
torch.Tensor: batched predicted masks torch.Tensor: batched predictions of mask quality
- predict_masks(image_embeddings: Tensor, image_pe: Tensor, sparse_prompt_embeddings: Tensor, dense_prompt_embeddings: Tensor, hq_features: Tensor) Tuple[Tensor, Tensor]
Predicts masks. See ‘forward’ for more details.