frameworks.ultralytics.services.model.predictor.object_detection¶
object_detection
¶
Classes:
Name | Description |
---|---|
UltralyticsDetectionModelPredictor |
A predictor class that handles inference and result formatting for object detection tasks |
UltralyticsDetectionModelPredictor(model)
¶
Bases: ModelPredictor[UltralyticsModel]
A predictor class that handles inference and result formatting for object detection tasks using the Ultralytics framework.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
UltralyticsModel
|
The detection model with its weights and configuration loaded. |
required |
Methods:
Name | Description |
---|---|
run_inference_on_batches |
Runs inference on each image batch using the model. |
post_process_batches |
Converts raw model outputs into structured rectangle predictions. |
format_predictions |
Transforms raw model predictions into Picsellia-compatible rectangle, label, and confidence objects. |
rescale_normalized_box |
Rescales a bounding box from normalized coordinates to pixel dimensions. |
cast_type_list_to_int |
Converts all values in a box list to integers. |
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 image batch using the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
list[list[str]]
|
A list of image batches. |
required |
Returns:
Type | Description |
---|---|
list[Results]
|
list[Results]: A list of inference result objects, one per batch. |
post_process_batches(image_batches, batch_results, dataset)
¶
Converts raw model outputs into structured rectangle predictions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
list[list[str]]
|
List of image batches. |
required |
|
list[Results]
|
Model predictions per batch. |
required |
|
TBaseDataset
|
Dataset context used for label resolution. |
required |
Returns:
Type | Description |
---|---|
list[PicselliaRectanglePrediction]
|
list[PicselliaRectanglePrediction]: Structured prediction results per image. |
format_predictions(asset, prediction, dataset)
¶
Transforms raw model predictions into Picsellia-compatible rectangle, label, and confidence objects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
Asset
|
The asset corresponding to the image. |
required |
|
Results
|
The prediction results for the image. |
required |
|
TBaseDataset
|
The dataset used to retrieve label mappings. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
tuple[list[PicselliaRectangle], list[PicselliaLabel], list[PicselliaConfidence]]
|
Lists of PicselliaRectangle, PicselliaLabel, and PicselliaConfidence objects. |
rescale_normalized_box(box, width, height)
staticmethod
¶
Rescales a bounding box from normalized coordinates to pixel dimensions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
list
|
Normalized box in [x_min, y_min, x_max, y_max] format. |
required |
|
int
|
Image width. |
required |
|
int
|
Image height. |
required |
Returns:
Type | Description |
---|---|
list[int]
|
list[int]: Rescaled box in [x, y, width, height] format. |
cast_type_list_to_int(box)
staticmethod
¶
Converts all values in a box list to integers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
list[float]
|
Bounding box coordinates. |
required |
Returns:
Type | Description |
---|---|
list[int]
|
list[int]: Bounding box with integer values. |
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. |