brails.processors.vlm_segmenter.segment_anything.utils.amg module
- class brails.processors.vlm_segmenter.segment_anything.utils.amg.MaskData(**kwargs)
Bases:
objectA structure for storing masks and their related data in batched format. Implements basic filtering and concatenation.
- cat(new_stats)
- filter(keep)
- items()
- to_numpy()
- brails.processors.vlm_segmenter.segment_anything.utils.amg.area_from_rle(rle)
- brails.processors.vlm_segmenter.segment_anything.utils.amg.batch_iterator(batch_size, *args)
- brails.processors.vlm_segmenter.segment_anything.utils.amg.batched_mask_to_box(masks)
Calculates boxes in XYXY format around masks. Return [0,0,0,0] for an empty mask. For input shape C1xC2x…xHxW, the output shape is C1xC2x…x4.
- brails.processors.vlm_segmenter.segment_anything.utils.amg.box_xyxy_to_xywh(box_xyxy)
- brails.processors.vlm_segmenter.segment_anything.utils.amg.build_all_layer_point_grids(n_per_side, n_layers, scale_per_layer)
Generates point grids for all crop layers.
- brails.processors.vlm_segmenter.segment_anything.utils.amg.build_point_grid(n_per_side)
Generates a 2D grid of points evenly spaced in [0,1]x[0,1].
- brails.processors.vlm_segmenter.segment_anything.utils.amg.calculate_stability_score(masks, mask_threshold, threshold_offset)
Computes the stability score for a batch of masks. The stability score is the IoU between the binary masks obtained by thresholding the predicted mask logits at high and low values.
- brails.processors.vlm_segmenter.segment_anything.utils.amg.coco_encode_rle(uncompressed_rle)
- brails.processors.vlm_segmenter.segment_anything.utils.amg.generate_crop_boxes(im_size, n_layers, overlap_ratio)
Generates a list of crop boxes of different sizes. Each layer has (2**i)**2 boxes for the ith layer.
- brails.processors.vlm_segmenter.segment_anything.utils.amg.is_box_near_crop_edge(boxes, crop_box, orig_box, atol=20.0)
Filter masks at the edge of a crop, but not at the edge of the original image.
- brails.processors.vlm_segmenter.segment_anything.utils.amg.mask_to_rle_pytorch(tensor)
Encodes masks to an uncompressed RLE, in the format expected by pycoco tools.
- brails.processors.vlm_segmenter.segment_anything.utils.amg.remove_small_regions(mask, area_thresh, mode)
Removes small disconnected regions and holes in a mask. Returns the mask and an indicator of if the mask has been modified.
- brails.processors.vlm_segmenter.segment_anything.utils.amg.rle_to_mask(rle)
Compute a binary mask from an uncompressed RLE.
- brails.processors.vlm_segmenter.segment_anything.utils.amg.uncrop_boxes_xyxy(boxes, crop_box)
- brails.processors.vlm_segmenter.segment_anything.utils.amg.uncrop_masks(masks, crop_box, orig_h, orig_w)
- brails.processors.vlm_segmenter.segment_anything.utils.amg.uncrop_points(points, crop_box)