brails.processors.vlm_segmenter.segment_anything.utils.transforms module
- class brails.processors.vlm_segmenter.segment_anything.utils.transforms.ResizeLongestSide(target_length: int)
Bases:
object
Resizes images to longest side ‘target_length’, as well as provides methods for resizing coordinates and boxes. Provides methods for transforming both numpy array and batched torch tensors.
- apply_boxes(boxes: ndarray, original_size: Tuple[int, ...]) ndarray
Expects a numpy array shape Bx4. Requires the original image size in (H, W) format.
- apply_boxes_torch(boxes: Tensor, original_size: Tuple[int, ...]) Tensor
Expects a torch tensor with shape Bx4. Requires the original image size in (H, W) format.
- apply_coords(coords: ndarray, original_size: Tuple[int, ...]) ndarray
Expects a numpy array of length 2 in the final dimension. Requires the original image size in (H, W) format.
- apply_coords_torch(coords: Tensor, original_size: Tuple[int, ...]) Tensor
Expects a torch tensor with length 2 in the last dimension. Requires the original image size in (H, W) format.
- apply_image(image: ndarray) ndarray
Expects a numpy array with shape HxWxC in uint8 format.
- apply_image_torch(image: Tensor) Tensor
Expects batched images with shape BxCxHxW and float format. This transformation may not exactly match apply_image. apply_image is the transformation expected by the model.
- static get_preprocess_shape(oldh: int, oldw: int, long_side_length: int) Tuple[int, int]
Compute the output size given input size and target long side length.