core.services.model.predictor.model_predictor¶
model_predictor
¶
Classes:
Name | Description |
---|---|
ModelPredictor |
Abstract base class for model inference. |
ModelPredictor(model)
¶
Bases: ABC
, Generic[TModel]
Abstract base class for model inference.
Provides utility methods to standardize prediction outputs (labels, confidence, rectangles) into Picsellia-compatible structures.
Attributes:
Name | Type | Description |
---|---|---|
model |
TModel
|
The model instance used for inference. |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
TModel
|
The model context with loaded weights and configuration. |
required |
Methods:
Name | Description |
---|---|
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. |
model = model
instance-attribute
¶
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. |