Skip to content

Commit

Permalink
#306 Add onnx to dlc convert & Samsung Galaxy S24 Ultra device (#311)
Browse files Browse the repository at this point in the history
Co-authored-by: soyoung.ko <[email protected]>
  • Loading branch information
Only-bottle and soyoungKo authored Jul 31, 2024
1 parent 2f3e17f commit a6ad4ab
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 2 deletions.
56 changes: 56 additions & 0 deletions examples/converter & benchmarker/v2/onnx2dlc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from netspresso import NetsPresso
from netspresso.enums import DeviceName, Framework, DataType, SoftwareVersion

###
# Available target frameworks for conversion with onnx models
#
# Framework.TENSORRT <-- For NVIDIA Devices
# Framework.OPENVINO <-- For Intel CPUs
# Framework.TENSORFLOW_LITE <-- For the devices like Raspberry Pi devices
# Framework.DRPAI <-- For Renesas Devices like RZ/V2M, RZ/V2L
# Framework.DLC <-- For GALAXY_S24_ULTRA
#

###
# Available devices for Framework.DLC (target_framework)
#
# DeviceName.GALAXY_S24_ULTRA
#

EMAIL = "YOUR_EMAIL"
PASSWORD = "YOUR_PASSWORD"

netspresso = NetsPresso(email=EMAIL, password=PASSWORD)

# 1. Declare converter
converter = netspresso.converter_v2()

# 2. Set variables for convert
INPUT_MODEL_PATH = "./examples/sample_models/yolo-fastest.onnx"
OUTPUT_DIR = "./outputs/converted/DLC_GALAXY_S24_ULTRA"
TARGET_FRAMEWORK = Framework.DLC
TARGET_DEVICE_NAME = DeviceName.GALAXY_S24_ULTRA
TARGET_DATA_TYPE = DataType.FP32
TARGET_SOFTWARE_VERSION = SoftwareVersion.SNPE_2_20

# 3. Run convert
conversion_task = converter.convert_model(
input_model_path=INPUT_MODEL_PATH,
output_dir=OUTPUT_DIR,
target_framework=TARGET_FRAMEWORK,
target_device_name=TARGET_DEVICE_NAME,
target_data_type=TARGET_DATA_TYPE,
target_software_version=TARGET_SOFTWARE_VERSION,
)
print(conversion_task)

# 4. Declare benchmarker
benchmarker = netspresso.benchmarker_v2()

# 5. Run benchmark
benchmark_task = benchmarker.benchmark_model(
input_model_path=conversion_task.converted_model_path,
target_device_name=TARGET_DEVICE_NAME,
target_software_version=TARGET_SOFTWARE_VERSION,
)
print(f"model inference latency: {benchmark_task.benchmark_result.latency} ms")
8 changes: 6 additions & 2 deletions netspresso/enums/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class DeviceName(str, Enum):
ARM_ETHOS_U_SERIES = "Arm Virtual Hardware Ethos-U Series"
NXP_iMX93 = "nxp_imx93_ethos_u65"
ARDUINO_NICLA_VISION = "arduino_nicla_vision"
GALAXY_S24_ULTRA = "Samsung_Galaxy-S24-Ultra_Snapdragon-8-Gen3"

@classmethod
def create_literal(cls):
Expand All @@ -52,7 +53,8 @@ def create_literal(cls):
"Ensemble-E7-DevKit-Gen2",
"Arm Virtual Hardware Ethos-U Series",
"nxp_imx93_ethos_u65",
"arduino_nicla_vision"
"arduino_nicla_vision",
"Samsung_Galaxy-S24-Ultra_Snapdragon-8-Gen3"
]

JETSON_DEVICES = [
Expand Down Expand Up @@ -98,10 +100,11 @@ class SoftwareVersion(str, Enum):
JETPACK_5_0_1 = "5.0.1-b118"
JETPACK_5_0_2 = "5.0.2-b231"
JETPACK_6_0 = "6.0-b52"
SNPE_2_20 = "2.20.0"

@classmethod
def create_literal(cls):
return Literal["4.4.1-b50", "4.6-b199", "5.0.1-b118", "5.0.2-b231", "6.0-b52"]
return Literal["4.4.1-b50", "4.6-b199", "5.0.1-b118", "5.0.2-b231", "6.0-b52", "2.20.0"]


class DisplaySoftwareVersion(str, Enum):
Expand All @@ -110,6 +113,7 @@ class DisplaySoftwareVersion(str, Enum):
JETPACK_5_0_1 = "Jetpack 5.0.1"
JETPACK_5_0_2 = "Jetpack 5.0.2"
JETPACK_6_0 = "Jetpack 6.0"
SNPE_2_20 = "SNPE 2.20.0"


class HardwareType(str, Enum):
Expand Down
2 changes: 2 additions & 0 deletions netspresso/enums/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Framework(str, Enum):
OPENVINO = "openvino"
TENSORFLOW_LITE = "tensorflow_lite"
DRPAI = "drpai"
DLC = "dlc"

@classmethod
def create_compressor_literal(cls):
Expand All @@ -26,6 +27,7 @@ def create_launcher_literal(cls):
"drpai",
"keras",
"saved_model",
"dlc"
]


Expand Down
1 change: 1 addition & 0 deletions netspresso/utils/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"drpai": ".zip",
"openvino": ".zip",
"tensorrt": ".trt",
"dlc": ".dlc"
}


Expand Down

0 comments on commit a6ad4ab

Please sign in to comment.