otx.tools.auto_configurator#
Auto-Configurator class & util functions for OTX Auto-Configuration.
Classes
|
This Class is used to configure the OTXDataModule, OTXModel, Optimizer, and Scheduler with OTX Default. |
- class otx.tools.auto_configurator.AutoConfigurator(data_root: str | Path | PathLike | None = None, task: OTXTaskType | None = None, model_config_path: str | Path | PathLike | None = None)[source]#
Bases:
object
This Class is used to configure the OTXDataModule, OTXModel, Optimizer, and Scheduler with OTX Default.
- Parameters:
data_root (PathLike | None, optional) – The root directory for data storage. Defaults to None.
task (OTXTaskType | None, optional) – The current task. Defaults to None.
model_name (str | None, optional) – Name of the model to use as the default. If None, the default model will be used. Defaults to None.
Example
The following examples show how to use the AutoConfigurator class.
>>> auto_configurator = AutoConfigurator( ... data_root=<dataset/path>, ... task=<OTXTaskType>, ... )
# If task is None, the task will be configured based on the data root. >>> auto_configurator = AutoConfigurator( … data_root=<dataset/path>, … )
- get_datamodule(data_root: str | Path | PathLike | None = None) OTXDataModule [source]#
Returns an instance of OTXDataModule with the configured data root.
- Returns:
An instance of OTXDataModule.
- Return type:
OTXDataModule | None
- get_model(model_name: str | None = None, label_info: LabelInfo | int | list[str] | None = None, data_input_params: DataInputParams | None = None) OTXModel [source]#
Retrieves the OTXModel instance based on the provided model name and meta information.
- Parameters:
model_name (str | None) – The name of the model to retrieve. If None, the default model will be used.
label_info (LabelInfoTypes | None) – The meta information about the labels. If provided, the number of classes will be updated in the model’s configuration.
data_input_params (DataInputParams | None) – The data input parameters containing the input size, input mean and std.
- Returns:
The instantiated OTXModel instance.
- Return type:
OTXModel
Example
The following examples show how to get the OTXModel class.
# If model_name is None, the default model will be used from task. >>> auto_configurator.get_model( … label_info=<LabelInfo>, … )
# If model_name is str, the default config file is changed. >>> auto_configurator.get_model( … model_name=<model_name, str>, … label_info=<LabelInfo>, … )
- get_ov_model(model_name: PathLike, task: OTXTaskType | None = None) OVModel [source]#
Retrieves the OVModel instance based on the given model name and label information.
- Parameters:
- Returns:
The OVModel instance.
- Return type:
- Raises:
NotImplementedError – If the OVModel for the given task is not supported.
- update_ov_subset_pipeline(datamodule: OTXDataModule, subset: str = 'test', task: OTXTaskType | None = None) OTXDataModule [source]#
Returns an OTXDataModule object with OpenVINO subset transforms applied.
- Parameters:
datamodule (OTXDataModule) – The original OTXDataModule object.
subset (str, optional) – The subset to update. Defaults to “test”.
- Returns:
The modified OTXDataModule object with OpenVINO subset transforms applied.
- Return type:
- property config: dict#
Retrieves the configuration for the auto configurator.
- Returns:
The configuration as a dict object.
- Return type:
- property task: OTXTaskType#
Returns the current task.
- Raises:
RuntimeError – If there are no ready tasks.
- Returns:
The current task.
- Return type: