otx.tools.converter#

Converter for v1 config.

Classes

ConfigConverter()

Convert ModelTemplate for OTX v1 to OTX v2 recipe dictionary.

class otx.tools.converter.ConfigConverter[source]#

Bases: object

Convert ModelTemplate for OTX v1 to OTX v2 recipe dictionary.

This class is used to convert ModelTemplate for OTX v1 to OTX v2 recipe dictionary.

Example

The following examples show how to use the Converter class. We expect a config file with ModelTemplate information in json form.

Convert template.json to dictionary:

converter = ConfigConverter()
config = converter.convert("template.json")

Instantiate an object from the configuration dictionary:

engine, train_kwargs = converter.instantiate(
    config=config,
    work_dir="otx-workspace",
    data_root="tests/assets/car_tree_bug",
)

Train the model:

engine.train(**train_kwargs)
static convert(config_path: str, task: OTXTaskType | None = None) dict[source]#

Convert a configuration file to a default configuration dictionary.

Parameters:
  • config_path (str) – The path to the configuration file.

  • task (OTXTaskType | None) – Value to override the task.

Returns:

The default configuration dictionary.

Return type:

dict

static instantiate(config: dict, work_dir: str | Path | PathLike | None = None, data_root: str | Path | PathLike | None = None, **kwargs) tuple[Engine, dict[str, Any]][source]#

Instantiate an object from the configuration dictionary.

Parameters:
  • config (dict) – The configuration dictionary.

  • work_dir (PathLike) – Path to the working directory.

  • data_root (PathLike) – The root directory for data.

Returns:

A tuple containing the engine and the train kwargs dictionary.

Return type:

tuple