otx.cli.utils.io#

Utils for model io operations.

Functions

get_explain_dataset_from_filelist(image_files)

Get explain dataset with empty annotation.

get_image_files(root_dir)

Recursively get all image file paths from given root_dir.

read_binary(path)

Loads binary data stored at path.

read_deployed_model(model_configuration, ...)

Reads a deployed model from disk and returns a ModelEntity object.

read_label_schema(path)

Reads serialized LabelSchema and returns deserialized LabelSchema.

read_model(model_configuration, path, ...)

Creates ModelEntity based on model_configuration and data stored at path.

read_openvino_model(model_configuration, ...)

Reads an OpenVINO model from disk and returns a ModelEntity object.

read_pytorch_model(model_configuration, ...)

Reads a PyTorch model from disk and returns a ModelEntity object.

save_model_data(model, folder)

Saves model data to folder.

save_saliency_output(process_saliency_maps, ...)

Saves processed saliency map (with image overlay) or raw saliency map.

otx.cli.utils.io.get_explain_dataset_from_filelist(image_files: list)[source]#

Get explain dataset with empty annotation.

otx.cli.utils.io.get_image_files(root_dir: str) List[Tuple[str, str]] | None[source]#

Recursively get all image file paths from given root_dir.

otx.cli.utils.io.read_binary(path: str) bytes[source]#

Loads binary data stored at path.

Parameters:

path (str) – A path where to load data from.

Returns:

Binary data.

Return type:

bytes

otx.cli.utils.io.read_deployed_model(model_configuration: ModelConfiguration, path: str, train_dataset: DatasetEntity) ModelEntity[source]#

Reads a deployed model from disk and returns a ModelEntity object.

otx.cli.utils.io.read_label_schema(path: str) LabelSchemaEntity[source]#

Reads serialized LabelSchema and returns deserialized LabelSchema.

Parameters:

path (str) – Path to model. It assmues that the label_schema.json is at the same location as the model.

Returns:

Desetialized LabelSchemaEntity.

Return type:

LabelSchemaEntity

otx.cli.utils.io.read_model(model_configuration: ModelConfiguration, path: str, train_dataset: DatasetEntity) ModelEntity[source]#

Creates ModelEntity based on model_configuration and data stored at path.

Parameters:
Returns:

ModelEntity object.

Return type:

ModelEntity

otx.cli.utils.io.read_openvino_model(model_configuration: ModelConfiguration, path: str, train_dataset: DatasetEntity) ModelEntity[source]#

Reads an OpenVINO model from disk and returns a ModelEntity object.

otx.cli.utils.io.read_pytorch_model(model_configuration: ModelConfiguration, path: str, train_dataset: DatasetEntity) ModelEntity[source]#

Reads a PyTorch model from disk and returns a ModelEntity object.

otx.cli.utils.io.save_model_data(model: ModelEntity, folder: str) None[source]#

Saves model data to folder. Folder is created if it does not exist.

Parameters:
  • model (ModelEntity) – The model to save.

  • folder (str) – Path to output folder.

otx.cli.utils.io.save_saliency_output(process_saliency_maps: bool, img: array, saliency_map: array, save_dir: str, fname: str, weight: float = 0.3) None[source]#

Saves processed saliency map (with image overlay) or raw saliency map.