PromptSegmentor¶
- class PromptSegmentor(model=None)[source]¶
Engine for prompt-based segmentation of WSIs.
This class is designed to work with the SAM model architecture. It allows for interactive segmentation by providing point and bounding box coordinates as prompts. The model is intended to be used with image tiles selected interactively in some way and provided as np.arrays. At least one of either point_coords or box_coords must be provided to guide segmentation.
- Parameters:
model (SAM) – Model architecture to use. If None, defaults to SAM.
Initializes the PromptSegmentor.
Methods
Calculates the microns per pixel for a fixed area of an image.
Run inference on image patches with prompts.
- calc_mpp(area_dims, base_mpp, fixed_size=1500)[source]¶
Calculates the microns per pixel for a fixed area of an image.
- run(images, point_coords=None, box_coords=None, save_dir=None, device='cpu')[source]¶
Run inference on image patches with prompts.
- Parameters:
images (list) – List of image patch arrays to run inference on.
point_coords (np.ndarray) – N_im x N_points x 2 array of point coordinates for each image patch.
box_coords (np.ndarray) – N_im x N_boxes x 4 array of bounding box coordinates for each image patch.
save_dir (str or Path) – Directory to save the output databases.
device (str) – Device to run inference on.
- Returns:
Paths to the saved output databases.
- Return type:
list[Path]