otx.api.entities.model#

This file defines the ModelConfiguration, ModelEntity and Model classes.

Classes

ModelConfiguration(configurable_parameters, ...)

This class represents the task configuration which was used to generate a specific model.

ModelEntity(train_dataset, configuration, *)

Represents the Entity of a Model.

ModelFormat(value)

Indicate the format of the model.

ModelOptimizationType(value)

Represents optimization type that is used to optimize the model.

ModelPrecision(value)

Represents the ModelPrecision of a Model.

OptimizationMethod(value)

Represents optimization method that is used to optimize the model.

class otx.api.entities.model.ModelConfiguration(configurable_parameters: ConfigurableParameters, label_schema: LabelSchemaEntity)[source]#

Bases: object

This class represents the task configuration which was used to generate a specific model.

Those are the parameters that a task may need in order to use the model.

Parameters:
  • configurable_parameters – Task configurable parameters used to generate the model

  • label_schema – Label schema inside the project used to generate the model

get_label_schema() LabelSchemaEntity[source]#

Get the LabelSchema.

class otx.api.entities.model.ModelEntity(train_dataset: DatasetEntity, configuration: ModelConfiguration, *, creation_date: datetime | None = None, performance: Performance | None = None, previous_trained_revision: ModelEntity | None = None, previous_revision: ModelEntity | None = None, version: int = 1, tags: List[str] | None = None, model_format: ModelFormat = ModelFormat.OPENVINO, training_duration: float = 0.0, model_adapters: Dict[str, ModelAdapter] | None = None, exportable_code_adapter: ExportableCodeAdapter | None = None, precision: List[ModelPrecision] | None = None, latency: int = 0, fps_throughput: int = 0, target_device: TargetDevice = TargetDevice.CPU, target_device_type: str | None = None, optimization_type: ModelOptimizationType = ModelOptimizationType.NONE, optimization_methods: List[OptimizationMethod] = None, optimization_objectives: Dict[str, str] = None, performance_improvement: Dict[str, float] = None, model_size_reduction: float = 0.0, _id: ID | None = None, has_xai: bool = False)[source]#

Bases: object

Represents the Entity of a Model.

delete_data(key: str)[source]#

This function is used to delete data sources that are on the filesystem.

If the key exists the model adapter will be appended to a list of model adapter that will be removed once the model is saved by the repo. Note that an optimized model must contain at least 1 DataSource otherwise you are left with an invalid optimized model.

get_data(key: str) bytes[source]#

Fetches byte data for a certain model.

Parameters:

key – key to fetch data for

Returns:

data for the key.

Return type:

bytes

is_optimized() bool[source]#

Returns a boolean indicating if the model has been optimized or not.

set_data(key: str, data: bytes | IDataSource, skip_deletion=False)[source]#

Sets the data for a specified key, either from a binary blob or from a data source.

If the key already exists it appends existing data url to a list of urls that will be removed upon saving the model. Skip deletion parameter should only be true if replacing bytes data with a file.

property configuration: ModelConfiguration#

Gets or sets the configuration of the Model.

property creation_date: datetime#

Gets or sets the creation_date of the Model.

property exportable_code: bytes | None#

Get the exportable_code from the exportable code adapter.

property exportable_code_adapter: ExportableCodeAdapter | None#

Returns the exportable code adapter.

property fps_throughput: int#

Get or set the throughput of the model.

Unit is frames per second (fps)

property has_xai: float#

Get or set the xAI flag.

property id: ID#

DEPRECATED.

property id_: ID#

Gets or sets the id of a Model.

property latency: int#

Get or set the latency of the model.

Unit is milliseconds (ms)

property model_adapters: Dict[str, ModelAdapter]#

Returns the dictionary of model adapters for each data key.

property model_format: ModelFormat#

Gets the model format.

property model_size_reduction: float#

Get or set the reduction in model size by optimizing.

property optimization_methods: List[OptimizationMethod] | None#

Get or set the optimization methods used on the model.

property optimization_objectives: Dict[str, str] | None#

Get or set the optimization level of the model.

property optimization_type: ModelOptimizationType#

Get or set the optimization type used for the model.

property performance: Performance#

Gets or sets the current Performance of the Model.

property performance_improvement: Dict[str, float] | None#

Get or set the performance improvement of the model.

property precision: List[ModelPrecision]#

Get or set the precision for the model.

This has effect on accuracy, latency and throughput of the model.

property previous_revision: None | ModelEntity#

Gets or sets the previous model.

property previous_trained_revision: None | ModelEntity#

Gets or sets the previous model.

Returns:

None if no previous_trained_revision has been created

property tags: List[str]#

Gets or sets the tags of the Model.

property target_device: TargetDevice#

Get or set the device on which the model will be deployed.

property target_device_type: str | None#

Get or set the type of the target device used by the model.

property train_dataset: DatasetEntity#

Gets or sets the current Training Dataset.

property training_duration: float#

Gets or sets the current training duration.

property version: int#

Gets or sets the version.

class otx.api.entities.model.ModelFormat(value)[source]#

Bases: IntEnum

Indicate the format of the model.

class otx.api.entities.model.ModelOptimizationType(value)[source]#

Bases: IntEnum

Represents optimization type that is used to optimize the model.

class otx.api.entities.model.ModelPrecision(value)[source]#

Bases: IntEnum

Represents the ModelPrecision of a Model.

class otx.api.entities.model.OptimizationMethod(value)[source]#

Bases: IntEnum

Represents optimization method that is used to optimize the model.