otx.core.exporter.native#
Class definition for native model exporter used in OTX.
Classes
|
Exporter that uses native torch and OpenVINO conversion tools. |
- class otx.core.exporter.native.OTXNativeModelExporter(task_level_export_parameters: TaskLevelExportParameters, input_size: tuple[int, ...], mean: tuple[float, float, float] = (0.0, 0.0, 0.0), std: tuple[float, float, float] = (1.0, 1.0, 1.0), resize_mode: Literal['crop', 'standard', 'fit_to_window', 'fit_to_window_letterbox'] = 'standard', pad_value: int = 0, swap_rgb: bool = False, via_onnx: bool = False, onnx_export_configuration: dict[str, Any] | None = None, output_names: list[str] | None = None, input_names: list[str] | None = None)[source]#
Bases:
OTXModelExporter
Exporter that uses native torch and OpenVINO conversion tools.
- to_onnx(model: OTXModel, output_dir: Path, base_model_name: str = 'exported_model', precision: OTXPrecisionType = OTXPrecisionType.FP32, embed_metadata: bool = True) Path [source]#
Export the given PyTorch model to ONNX format and save it to the specified output directory.
- Parameters:
model (OTXModel) – The PyTorch model to be exported.
output_dir (Path) – The directory where the ONNX model will be saved.
base_model_name (str, optional) – The base name for the exported model. Defaults to “exported_model”.
precision (OTXPrecisionType, optional) – The precision type for the exported model.
OTXPrecisionType.FP32. (Defaults to) –
embed_metadata (bool, optional) – Whether to embed metadata in the ONNX model. Defaults to True.
- Returns:
The path to the saved ONNX model.
- Return type:
Path