Convert Model

convert_model(self, model: Union[str, netspresso.launcher.schemas.model.Model], input_shape: netspresso.launcher.schemas.model.InputShape, target_framework: Union[str, netspresso.launcher.schemas.ModelFramework], data_type: netspresso.launcher.schemas.DataType = 'FP16', target_device: netspresso.launcher.schemas.model.TargetDevice = None, wait_until_done: bool = True, target_device_name: netspresso.launcher.schemas.DeviceName = None, target_software_version: netspresso.launcher.schemas.SoftwareVersion = None) → netspresso.launcher.schemas.model.ConversionTask

Convert a model into the type the specific framework.

Parameters
  • model (str) – The uuid of the model or Launcher Model Object.

  • input_shape (InputShape) – target input shape to convert. (ex: dynamic batch to static batch)

  • target_framework (ModelFramework | str) – the target framework name.

  • data_type (DataType) – data type of the model.

  • target_device (TargetDevice) – target device. If it’s not set, target_device_name and target_software_version have to be set.

  • wait_until_done (bool) – if true, wait for the conversion result before returning the function. If false, request the conversion and return the function immediately.

  • target_device_name (DeviceName) – target device name. Necessary field if target_device is not given.

  • target_software_version (SoftwareVersion) – target_software_version. Necessary field if target_device_name is one of jetson devices.

Raises

e – If an error occurs while converting the model.

Returns

model conversion task object.

Return type

ConversionTask

Example

from netspresso.launcher import ModelConverter, ModelFramework, DeviceName, SoftwareVersion


converter = ModelConverter(email="YOUR_EMAIL", password="YOUR_PASSWORD")
model = converter.upload_model("YOUR_MODEL_PATH")
conversion_task = converter.convert_model(
    model=model,
    input_shape=model.input_shape,
    target_framework=ModelFramework.TENSORRT,
    target_device_name=DeviceName.JETSON_AGX_ORIN,
    target_software_version=SoftwareVersion.JETPACK_5_0_1,
    wait_until_done=True
)