Skip to content

Converter

Description

netspresso.converter.v2.converter.ConverterV2

Bases: NetsPressoBase

__init__(token_handler, user_info)

Initialize the Converter.

cancel_conversion_task(conversion_task_id)

Cancel the conversion task with given conversion task uuid.

Parameters:

Name Type Description Default
conversion_task_id str

Convert task UUID of the convert task.

required

Raises:

Type Description
e

If an error occurs during the task cancel.

Returns:

Name Type Description
ConversionTask ConvertTask

Model conversion task dictionary.

convert_model(input_model_path, output_dir, target_framework, target_device_name, target_data_type=DataType.FP16, target_software_version=None, input_layer=None, dataset_path=None, wait_until_done=True, sleep_interval=30)

Convert a model to the specified framework.

Parameters:

Name Type Description Default
input_model_path str

The file path where the model is located.

required
output_dir str

The local folder path to save the converted model.

required
target_framework Union[str, Framework]

The target framework name.

required
target_device_name Union[str, DeviceName]

Target device name. Required if target_device is not specified.

required
target_data_type Union[str, DataType]

Data type of the model. Default is DataType.FP16.

FP16
target_software_version Union[str, SoftwareVersion]

Target software version. Required if target_device_name is one of the Jetson devices.

None
input_layer InputShape

Target input shape for conversion (e.g., dynamic batch to static batch).

None
dataset_path str

Path to the dataset. Useful for certain conversions.

None
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.

True

Raises:

Type Description
e

If an error occurs during the model conversion.

Returns:

Name Type Description
ConverterMetadata ConverterMetadata

Convert metadata.

get_conversion_task(conversion_task_id)

Get the conversion task information with given conversion task uuid.

Parameters:

Name Type Description Default
conversion_task_id str

Convert task UUID of the convert task.

required

Raises:

Type Description
e

If an error occurs during the model conversion.

Returns:

Name Type Description
ConversionTask ConvertTask

Model conversion task dictionary.

Examples

Converting a model to TensorRT on Jetson AGX Orin

from netspresso import NetsPresso
from netspresso.enums import DeviceName, Framework, SoftwareVersion


# Login with API key (recommended)
# Get your API token from: https://account.netspresso.ai/api-token
netspresso = NetsPresso(api_key="YOUR_API_KEY")

# Note: Email/password login will be deprecated soon
# netspresso = NetsPresso(email="YOUR_EMAIL", password="YOUR_PASSWORD")

converter = netspresso.converter_v2()
conversion_task = converter.convert_model(
   input_model_path="./examples/sample_models/test.onnx",
   output_dir="./outputs/converted/TENSORRT_JETSON_AGX_ORIN_JETPACK_5_0_1",
   target_framework=Framework.TENSORRT,
   target_device_name=DeviceName.JETSON_AGX_ORIN,
   target_software_version=SoftwareVersion.JETPACK_5_0_1,
)