This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] AM62A7:如何对.onnx 文件使用 edgeai-tidl-tools 我训练过导出 am62a7可用模型.bin 文件

Guru**** 2393725 points
Other Parts Discussed in Thread: AM62A7

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1491920/am62a7-how-to-use-edgeai-tidl-tools-for-the-onnx-file-i-trained-export-the-am62a7-usable-model-bin-file

器件型号:AM62A7

工具与软件:

我目前正在使用的平台是 ti am62a7

我对 am62a7使用 PROCESSOR-SDK-LINUX AM62A 版本:09.02.00.05
我使用 edgeai-tidl-tools 版本 rel_10_01
我想使用已训练的现有.onnx 文件
转换为 am62a7的模块文件
我在以下目录中找到了转换程序
edgeai-tidl-tools/tools/AM62A/tidl_tools/tidl_model_import.out
如何使用此程序将.onnx 文件转换为 am62a7可以使用的.bin 文件?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Martin:

    我们很乐意帮助您使用 edgeai-tidl-tools 来编译模型。

    首先、请注意、用于编译模型的 edgeai-tidl-tools 版本应与目标 Linux SDK 相匹配。 建议使用我们较新的 SDK 10.1、而不是较旧的9.2 SDK。  

    要编译 onnx 模型、请参阅此处提供的示例: https://github.com/TexasInstruments/edgeai-tidl-tools/blob/master/examples/osrt_python/ort/onnxrt_ep.py。您可以编辑该文件来编译模型。 您还需要在以下文件中输入模型配置: https://github.com/TexasInstruments/edgeai-tidl-tools/blob/master/examples/osrt_python/model_configs.py。 

     有关如何使用此示例的说明、请访问: https://github.com/TexasInstruments/edgeai-tidl-tools/tree/master/examples/osrt_python。

    此致、

    Qutaiba

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我已经查看了 edgeai-tidl-tools 的 GitHub
    在 rel_10_01分支中有一个 update_target.sh 文件
    我能否使用此选项切换到 SDK 9.2并编译可由 am62a7使用的模块.bin 文件?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我刚刚使用了 onnxrt_ep.py 和 model_configs.py
    添加 model.onnx 存档
    此程序仅输出 output_binaries 和 output_images 中的分析结果

    我需要将.onnx 文件编译为可以供 am62a7使用的模型文件

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Martin:

    n rel_10_01分支有一个 update_target.sh 文件
    我能否使用此选项切换到 SDK 9.2并编译一个可供 am62a7使用的模块.bin 文件?[/QUOT]

    如果您希望仍在 AM62A 上使用 Linux SDK 9.2、可将 edgeai-tidl-tools 切换到旧版本: https://github.com/TexasInstruments/edgeai-tidl-tools/tree/rel_09_02。 此版本生成的模型工件将在 SDK 9.2上运行。 也就是说、我建议使用与旧版本相比性能有所改进的 SDK 10.1。  

    [报价 userid="407563" url="~/support/processors-group/processors/f/processors-forum/1491920/am62a7-how-to-use-edgeai-tidl-tools-for-the-onnx-file-i-trained-export-the-am62a7-usable-model-bin-file/5733496 #5733496"]

    我刚刚使用了 onnxrt_ep.py 和 model_configs.py
    添加 model.onnx 存档
    此程序仅输出 output_binaries 和 output_images 中的分析结果

    我需要将.onnx 文件编译为可以供 am62a7使用的模型文件

    [报价]

    您是否使用-c 选项运行 onnxrt_ep.py? 此选项意味着编译模型并生成工件。 如果运行此 Python 脚本而不使用-c、则只会运行推理。 本文档中提供了更多详细信息: https://github.com/TexasInstruments/edgeai-tidl-tools/tree/master/examples/osrt_python#model-compilation

    此致、

    Qutaiba

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我使用此命令
    python3 onnxrt_ep.py -c --model OD-yolox_nano_lite
    输出文件是否符合预期?

    user001@user001-CoffeeLake:~/edgeai-tidl-tools_101/model-artifacts/OD-yolox_nano_lite$树
    .
    ├──伪影
    │  ├──allowedNode.txt
    │  ├──onnxrtMetaData.txt
    │  └──tempDir
    │  ├──graphvizInfo.txt
    │  ├──runtimes_visualization.svg
    │  ├──subgraph_0_calib_raw_data.bin
    │  ├──subgraph_0_tidl_io_1.bin
    │  ├──subgraph_0_tidl_net.bin
    │  ├──subgraph_0_tidl_net.bin.layer_info.txt
    │  ├──subgraph_0_tidl_net.bin_netLog.txt
    │  ├──subgraph_0_tidl_net.bin.svg
    │  ├──subgraph_1_calib_raw_data.bin
    │  ├──subgraph_1_tidl_io_1.bin
    │  ├──subgraph_1_tidl_net.bin
    │  ├──subgraph_1_tidl_net.bin.layer_info.txt
    │  ├──subgraph_1_tidl_net.bin_netLog.txt
    │  ├──subgraph_1_tidl_net.bin.svg
    │  ├──subgraph_2_calib_raw_data.bin
    │  ├──subgraph_2_tidl_io_1.bin
    │  ├──subgraph_2_tidl_net.bin
    │  ├──subgraph_2_tidl_net.bin.layer_info.txt
    │  ├──subgraph_2_tidl_net.bin_netLog.txt
    │  ├──subgraph_2_tidl_net.bin.svg
    │  ├──subgraph_3_calib_raw_data.bin
    │  ├──subgraph_3_tidl_io_1.bin
    │  ├──subgraph_3_tidl_net.bin
    │  ├──subgraph_3_tidl_net.bin.layer_info.txt
    │  ├──subgraph_3_tidl_net.bin_netLog.txt
    │  ├──subgraph_3_tidl_net.bin.svg
    │  ├──subgraph_4_calib_raw_data.bin
    │  ├──subgraph_4_tidl_io_1.bin
    │  ├──subgraph_4_tidl_net.bin
    │  ├──subgraph_4_tidl_net.bin.layer_info.txt
    │  ├──subgraph_4_tidl_net.bin_netLog.txt
    │  ├──subgraph_4_tidl_net.bin.svg
    │  ├──subgraph_5_calib_raw_data.bin
    │  ├──subgraph_5_tidl_io_1.bin
    │  ├──subgraph_5_tidl_net.bin
    │  ├──subgraph_5_tidl_net.bin.layer_info.txt
    │  ├──subgraph_5_tidl_net.bin_netLog.txt
    │  ├──subgraph_5_tidl_net.bin.svg
    │  ├──subgraph_6_calib_raw_data.bin
    │  ├──subgraph_6_tidl_io_1.bin
    │  ├──subgraph_6_tidl_net.bin
    │  ├──subgraph_6_tidl_net.bin.layer_info.txt
    │  ├──subgraph_6_tidl_net.bin_netLog.txt
    │  └──subgraph_6_tidl_net.bin.svg
    ├──dataset.yaml
    μ├──模型
    │  ├──model.onnx
    │  └──model.prototxt
    └──param.yaml

    3个目录、50个文件

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    这是我的 model_config.py 配置

    "OD-yolox_nano_lite":{
    "task_type":"检测"、
    "会话":{
    "model_path":"/home/user001/yolox_nano_lite/model/model.onnx、
    "meta_layers_names_list":"/home/user001/yolox_nano_lite/model/model.prototxt、
    "Session_name":"onnxrt"、
    "input_optimization":true、
    }、
    "源":dict()、
    "model_type":"OD"、
    "预处理":{
    "resize"(调整大小):512、
    "裁剪":512、
    "DATA_LOADY":"NCHW"、
    "resize_with_pad":false、
    "REVERSE_CHANNELS":错误、
    }、
    "后处理":{
    "label_offset_pred":0
    }、
    "input_names":["input"]、
    "output_names":["output"]、
    #"input_pulations":[[1、3,640,640]]、
    "extra_info":{
    "NUM_IMAGEs":1、
    "OD_TYPE":"yolox"、
    "框架":"MMDetection"、
    "label_offset_type":"80to90"、
    "label_offset":1、
    "NUM_CLASSES_":80
    }

    }、

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Martin:

     对于 yolox-nano-lite 模型、输出文件看起来不正确。 除非对原始模型进行了更改、否则 yolox-nano-lite 模式应被编译为单个图形。 我运行了 onnxrt_ep.py 对于您可以使用该命令的模型。  

    <>/edgeai-tidl-tools/examples/osrt_python/ort$ python3 onnxrt_ep.py -c --model od-8200_onnxrt_coco_edgeai-mmdet_yolox_nano_lite_416x416_20220214_model_onnx

    可从以下网址获取该模型的配置: github.com/.../model_configs.py

    此致、

    Qutaiba

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你(们)好

    我想编译我自己的模型并在 am62a7 soc 中使用它
    而不是使用/examples 中的模型
    附件是我要编译的.onnx 文件

    TIDL 使用 rel_10_01
    Linux SDK 还使用版本10.01来验证 am62a Model .bin 文件


    我将模型配置添加到 model_configs.py
    "OD-yolox_nano_lite":{
    "task_type":"检测"、
    "会话":{
    "model_path":"/home/user001/yolox_nano_lite/model/model.onnx、
    "meta_layers_names_list":"/home/user001/yolox_nano_lite/model/model.prototxt、
    "Session_name":"onnxrt"、
    "input_optimization":true、
    }、
    "源":dict()、
    "model_type":"OD"、
    "预处理":{
    "resize"(调整大小):416、
    "CROP":416,
    "DATA_LOADY":"NCHW"、
    "resize_with_pad":false、
    "REVERSE_CHANNELS":错误、
    }、
    "后处理":{
    "label_offset_pred":0
    }、
    "input_names":["input"]、
    "output_names":["dts"、"labels"]、
    "input_pulations":[[1、3,416,416]]、
    "extra_info":{
    "NUM_IMAGEs":1、
    "OD_TYPE":"yolox"、
    "框架":"MMDetection"、
    "label_offset_type":"80to90"、
    "label_offset":1、
    "num_classes":3.
    }
    }、
    设置是否正确?

    e2e.ti.com/.../5047.model.zip

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Martin:

    感谢您提供您的模型。 我将在下周查看并提供更详细的答案。

    此致、

    Qutaiba

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Martin:

    我看到您共享的模型与我们 modelzoo 中的默认 yolox-nano-lite 模型相同。 在这种情况下、只需对 yolox-nano-lite 模型使用 configs 即可、但 需要进行一些更改:github.com/.../model_configs.py  
    您可以更改路径和类数以适合您的模型。 但它应该适合您。 我只是尝试了一下、然后编译了模型。  

    除此之外、我还建议添加更多适合您的训练数据集的校准图像: https://github.com/TexasInstruments/edgeai-tidl-tools/blob/10_01_04_00/examples/osrt_python/ort/onnxrt_ep.py#L74。

    此致、

    Qutaiba

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你(们)好
    我只需要修改此程序即可更改模型文件的路径吗?

    "OD-8200_onnxrt_coco_edgeai-mmdet_yolox_nano_lite_416x416_20220214_model_onnx":create_model_config (
    task_type="检测"、
    source=dict()
    model_url="">software-dl.ti.com/.../yolox_nano_lite_416x416_20220214_model.onnx"、
    meta_arch_url="">software-dl.ti.com/.../yolox_nano_lite_416x416_20220214_model.prototxt"、
    INFORE_SHAPE=真、
    )、

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Martin:

    是的、您可以修改原始 yolox-nano-lite 的配置。 还有 model_url 和 meta_arch_url。 更重要的是更改   model_path 和   meta_layers_names_list、它们是会话词典的一部分、网址为: https://github.com/TexasInstruments/edgeai-tidl-tools/blob/10_01_04_00/examples/osrt_python/model_configs.py#L769-L773

    此致、

    Qutaiba