brails.processors.vlm_segmenter.grounded_sam_utils module

class brails.processors.vlm_segmenter.grounded_sam_utils.BoundingBox(xmin: int, ymin: int, xmax: int, ymax: int)

Bases: object

xmax: int
xmin: int
property xyxy: List[float]
ymax: int
ymin: int
class brails.processors.vlm_segmenter.grounded_sam_utils.DetectionResult(score: float, label: str, box: brails.processors.vlm_segmenter.grounded_sam_utils.BoundingBox, mask: Optional[<built-in function array>] = None)

Bases: object

box: BoundingBox
classmethod from_dict(detection_dict: Dict) DetectionResult
label: str
mask: array | None = None
score: float
brails.processors.vlm_segmenter.grounded_sam_utils.build_models(device='cuda:0')
brails.processors.vlm_segmenter.grounded_sam_utils.detect(image: Image, labels: List[str], threshold: float = 0.3, detector_id: str | None = None) List[Dict[str, Any]]

Use Grounding DINO to detect a set of labels in an image in a zero-shot fashion.

brails.processors.vlm_segmenter.grounded_sam_utils.run_on_one_image(img_source, output_dir, grounding_dino_model, sam_predictor, CLASS_TO_CODE, BOX_THRESHOLD=0.35, TEXT_THRESHOLD=0.25, NMS_THRESHOLD=0.8, visualize=False)
brails.processors.vlm_segmenter.grounded_sam_utils.segment(sam_predictor: SamPredictor, image: ndarray, xyxy: ndarray) ndarray
brails.processors.vlm_segmenter.grounded_sam_utils.show_binary_mask(mask, ax, label_code)
brails.processors.vlm_segmenter.grounded_sam_utils.show_box(box, ax)
brails.processors.vlm_segmenter.grounded_sam_utils.show_points(coords, labels, ax, marker_size=375)
brails.processors.vlm_segmenter.grounded_sam_utils.verify_and_download_models(download_url, filepath)