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, hidden_dim, output_dim, num_layers, sigmoid_output=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, transformer, num_multimask_outputs=3, activation=<class 'torch.nn.modules.activation.GELU'>, iou_head_depth=3, iou_head_hidden_dim=256, vit_dim=1024)

Bases: Module

forward(image_embeddings, image_pe, sparse_prompt_embeddings, dense_prompt_embeddings, multimask_output, hq_token_only, interm_embeddings)

Predict masks given image and prompt embeddings.

Parameters:
  • 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:

batched predicted masks torch.Tensor: batched predictions of mask quality

Return type:

torch.Tensor

predict_masks(image_embeddings, image_pe, sparse_prompt_embeddings, dense_prompt_embeddings, hq_features)

Predicts masks. See ‘forward’ for more details.