frameworks.ultralytics.services.model.predictor.segmentation¶
segmentation
¶
Classes:
Name | Description |
---|---|
UltralyticsSegmentationModelPredictor |
A predictor class that handles model inference and result post-processing for segmentation tasks |
UltralyticsSegmentationModelPredictor(model)
¶
Bases: ModelPredictor[UltralyticsModel]
A predictor class that handles model inference and result post-processing for segmentation tasks using the Ultralytics framework.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
UltralyticsModel
|
The model used to perform inference. |
required |
Methods:
Name | Description |
---|---|
run_inference_on_batches |
Runs inference on each batch of images. |
post_process_batches |
Converts raw predictions into PicselliaPolygonPrediction objects for each image. |
format_predictions |
Extracts and formats segmentation predictions into Picsellia types. |
format_polygons |
Converts a polygon array to a list of integer coordinates. |
pre_process_dataset |
Extracts all image paths from the dataset's image directory. |
prepare_batches |
|
get_picsellia_label |
Get or create a PicselliaLabel from a dataset category name. |
get_picsellia_confidence |
Wrap a confidence score in a PicselliaConfidence object. |
get_picsellia_rectangle |
Create a PicselliaRectangle from bounding box coordinates. |
Attributes:
Name | Type | Description |
---|---|---|
model |
TModel
|
|
model = model
instance-attribute
¶
run_inference_on_batches(image_batches)
¶
Runs inference on each batch of images.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
list[list[str]]
|
A list of image path batches. |
required |
Returns:
Type | Description |
---|---|
list[Results]
|
list[Results]: The list of inference results for each batch. |
post_process_batches(image_batches, batch_results, dataset)
¶
Converts raw predictions into PicselliaPolygonPrediction objects for each image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
list[list[str]]
|
The original image path batches. |
required |
|
list[Results]
|
The inference results for each batch. |
required |
|
TBaseDataset
|
Dataset used to retrieve asset metadata. |
required |
Returns:
Type | Description |
---|---|
list[PicselliaPolygonPrediction]
|
list[PicselliaPolygonPrediction]: Structured predictions ready for evaluation/logging. |
format_predictions(prediction, dataset)
¶
Extracts and formats segmentation predictions into Picsellia types.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Results
|
A single inference result containing segmentation masks. |
required |
|
TBaseDataset
|
Dataset used to resolve labels. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
tuple[list[PicselliaPolygon], list[PicselliaLabel], list[PicselliaConfidence]]
|
Lists of PicselliaPolygon, PicselliaLabel, and PicselliaConfidence. |
format_polygons(polygon)
staticmethod
¶
Converts a polygon array to a list of integer coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
ndarray
|
Polygon mask as an array of coordinates. |
required |
Returns:
Type | Description |
---|---|
list[list[int]]
|
list[list[int]]: Polygon represented as a list of integer point pairs. |
pre_process_dataset(dataset)
¶
Extracts all image paths from the dataset's image directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
TBaseDataset
|
The dataset object containing the image directory. |
required |
Returns:
Type | Description |
---|---|
list[str]
|
list[str]: A list of file paths to the dataset images. |
prepare_batches(image_paths, batch_size)
¶
get_picsellia_label(category_name, dataset)
¶
Get or create a PicselliaLabel from a dataset category name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
str
|
The name of the label category. |
required |
|
TBaseDataset
|
Dataset that provides label access. |
required |
Returns:
Name | Type | Description |
---|---|---|
PicselliaLabel |
PicselliaLabel
|
Wrapped label object. |
get_picsellia_confidence(confidence)
¶
Wrap a confidence score in a PicselliaConfidence object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
float
|
Prediction confidence score. |
required |
Returns:
Name | Type | Description |
---|---|---|
PicselliaConfidence |
PicselliaConfidence
|
Wrapped confidence object. |
get_picsellia_rectangle(x, y, w, h)
¶
Create a PicselliaRectangle from bounding box coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
int
|
Top-left x-coordinate. |
required |
|
int
|
Top-left y-coordinate. |
required |
|
int
|
Width of the box. |
required |
|
int
|
Height of the box. |
required |
Returns:
Name | Type | Description |
---|---|---|
PicselliaRectangle |
PicselliaRectangle
|
Rectangle wrapper for object detection. |