Skip to content

frameworks.sam2.services.predictor

predictor

Classes:

Name Description
SAM2ModelPredictor

SAM2ModelPredictor(predictor)

Methods:

Name Description
pre_process_dataset

Collects image file paths from the dataset.

preprocess_images
preprocess
run_inference
post_process

Converts mask predictions to polygons and associates them with their scores.

Attributes:

Name Type Description
predictor

predictor = predictor instance-attribute

pre_process_dataset(dataset)

Collects image file paths from the dataset.

Parameters:

Name Type Description Default
dataset
CocoDataset

Dataset object containing image directory.

required

Returns:

Type Description
list[ndarray]

list[str]: List of full paths to image files.

preprocess_images(image_list)

preprocess(image)

run_inference(point_coords=None, point_labels=None, box=None, mask_input=None, multimask_output=True)

post_process(results)

Converts mask predictions to polygons and associates them with their scores.

Parameters:

Name Type Description Default
results
list[dict]

List of dictionaries with keys "segmentation" and "score".

required

Returns:

Type Description
list[dict]

list[dict]: List of {"polygon": [...], "score": float} dictionaries.