brails.processors.vlm_segmenter.segment_anything.utils.transforms module
- class brails.processors.vlm_segmenter.segment_anything.utils.transforms.ResizeLongestSide(target_length)
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, original_size)
Expects a numpy array shape Bx4. Requires the original image size in (H, W) format.
- apply_boxes_torch(boxes, original_size)
Expects a torch tensor with shape Bx4. Requires the original image size in (H, W) format.
- apply_coords(coords, original_size)
Expects a numpy array of length 2 in the final dimension. Requires the original image size in (H, W) format.
- apply_coords_torch(coords, original_size)
Expects a torch tensor with length 2 in the last dimension. Requires the original image size in (H, W) format.
- apply_image(image)
Expects a numpy array with shape HxWxC in uint8 format.
- apply_image_torch(image)
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, oldw, long_side_length)
Compute the output size given input size and target long side length.