core.services.model.utils¶
utils
¶
Functions:
Name | Description |
---|---|
build_model_impl |
Instantiate and initialize a model object within the current Picsellia pipeline context. |
evaluate_model_impl |
Run evaluation of model predictions using the appropriate evaluation strategy based on inference type. |
build_model_impl(context, model_cls, pretrained_weights_name=None, trained_weights_name=None, config_name=None, exported_weights_name=None)
¶
Instantiate and initialize a model object within the current Picsellia pipeline context.
This function supports both training and processing contexts and uses the appropriate model version to build the model. It also downloads any associated model weights (pretrained, trained, exported).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
PicselliaProcessingContext | PicselliaTrainingContext | LocalProcessingContext | LocalTrainingContext
|
The current pipeline context, which must be either a training or processing context. |
required |
|
type[TModel]
|
The model class to instantiate. |
required |
|
str
|
The name of the pretrained weights to download. |
None
|
|
str
|
The name of the trained weights to download. |
None
|
|
str
|
The name of the model configuration file. |
None
|
|
str
|
The name of the exported weights for inference. |
None
|
Returns:
Name | Type | Description |
---|---|---|
TModel |
TModel
|
An instance of the initialized model with weights downloaded. |
evaluate_model_impl(context, picsellia_predictions, inference_type, assets, output_dir, training_labelmap=None)
¶
Run evaluation of model predictions using the appropriate evaluation strategy based on inference type.
This function leverages Picsellia's ModelEvaluator
to:
- Compare predictions to ground truth.
- Compute classification metrics for classification tasks.
- Compute COCO metrics for detection and segmentation tasks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
PicselliaProcessingContext | PicselliaTrainingContext | LocalProcessingContext | LocalTrainingContext
|
The current pipeline context, expected to contain an experiment. |
required |
|
list[PicselliaClassificationPrediction] | list[PicselliaRectanglePrediction] | list[PicselliaPolygonPrediction] | list[PicselliaOCRPrediction]
|
List of predictions generated by the model, matching the inference type. |
required |
|
InferenceType
|
The type of model inference performed (e.g., classification, detection). |
required |
|
list[Asset] | MultiAsset
|
Ground truth assets against which predictions are evaluated. |
required |
|
str
|
The directory where evaluation metrics and results will be written. |
required |
|
dict[str, str] | None
|
Optional mapping of training labels for evaluation alignment. |
None
|