otx.api.entities.task_environment#

This module implements the TaskEnvironment entity.

Classes

TaskEnvironment(model_template, model, ...)

Defines the machine learning environment the task runs in.

class otx.api.entities.task_environment.TaskEnvironment(model_template: ModelTemplate, model: ModelEntity | None, hyper_parameters: ConfigurableParameters, label_schema: LabelSchemaEntity)[source]#

Bases: object

Defines the machine learning environment the task runs in.

Args: model_template (ModelTemplate): The model template used for this task model (Optional[ModelEntity]): Model to use; if not specified, the task must be either weight-less

or use pre-trained or randomly initialised weights.

hyper_parameters (ConfigurableParameters): Set of hyper parameters label_schema (LabelSchemaEntity): Label schema associated to this task

get_hyper_parameters(instance_of: Type[TypeVariable] | None = None) TypeVariable[source]#

Returns Configuration for the task, de-serialized as type specified in instance_of.

If the type of the configurable parameters is unknown, a generic ConfigurableParameters object with all available parameters can be obtained by calling method with instance_of = None.

Example

>>> self.get_hyper_parameters(instance_of=TorchSegmentationConfig)
TorchSegmentationConfig()
Parameters:

instance_of (Optional[Type[TypeVariable]]) – subtype of ModelConfig of the hyperparamters. Defaults to None.

Returns:

ConfigurableParameters entity

Return type:

TypeVariable

get_labels(include_empty: bool = False) List[LabelEntity][source]#

Return the labels in this task environment (based on the label schema).

Parameters:

include_empty (bool) – Include the empty label if True. Defaults to False.

Returns:

List of labels

Return type:

List[LabelEntity]

get_model_configuration() ModelConfiguration[source]#

Get the configuration needed to use the current model.

That is the current set of:
  • configurable parameters

  • labels

  • label schema

Returns:

Model configuration

Return type:

ModelConfiguration

set_hyper_parameters(hyper_parameters: ConfigurableParameters)[source]#

Sets the hyper parameters for the task.

Example

>>> self.set_hyper_parameters(hyper_parameters=TorchSegmentationParameters())
None
Parameters:

hyper_parameters (ConfigurationParameter) – ConfigurableParameters entity to assign to task