brails.processors.vlm_segmenter.segment_anything.utils.onnx module
- class brails.processors.vlm_segmenter.segment_anything.utils.onnx.SamOnnxModel(model: Sam, return_single_mask: bool, use_stability_score: bool = False, return_extra_metrics: bool = False)
Bases:
Module
This model should not be called directly, but is used in ONNX export. It combines the prompt encoder, mask decoder, and mask postprocessing of Sam, with some functions modified to enable model tracing. Also supports extra options controlling what information. See the ONNX export script for details.
- forward(image_embeddings: Tensor, point_coords: Tensor, point_labels: Tensor, mask_input: Tensor, has_mask_input: Tensor, orig_im_size: Tensor)
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.
- mask_postprocessing(masks: Tensor, orig_im_size: Tensor) Tensor
- static resize_longest_image_size(input_image_size: Tensor, longest_side: int) Tensor
- select_masks(masks: Tensor, iou_preds: Tensor, num_points: int) Tuple[Tensor, Tensor]