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.

[参考译文] EDGE-AI-STUDIO:使用 edgeai-tidl-tools 进行模型编译

Guru**** 2483885 points
Other Parts Discussed in Thread: EDGE-AI-STUDIO

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

https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1547627/edge-ai-studio-model-compiling-using-edgeai-tidl-tools

部件号:EDGE-AI-STUDIO


工具/软件:

工程师、您好:

在训练生成 6.1MB 二进制.onnx 文件后、我尝试使用 Pytorch 编译经过训练的模型。 我获得了用于编译模型的资源。 但没有得到澄清。  
我所做的步骤:
1.将数据集拆分为 TRAIN 和 VAL.
2.编写了一个训练代码,数据集将被输入其中。
3.包含将.pth 导出到.onnx 的代码  
4.克隆 edgeai-tidl-tools
5.检查分支 10_01_04_00(使用 SDK 10.01)
6、导出 SOC=am62a
7.  source ./setup.sh
8.打开一个新的终端选项卡$ source ./ setup_env.sh $am62a.
9、创建了一个名为 model 的目录,在其中添加了.onnx 文件
10、在中创建了一个词典  examples/osrt_python/model_configs.py  
    

    "cl-ort-my_model": create_model_config(
        task_type="classification",
        source=dict(
            model_path="../../models/my_model.onnx",
        ),
        preprocess=dict(
            resize=256,
            crop=224,
            data_layout="NCHW",
            resize_with_pad=False,
            reverse_channels=False,
        ),
        session=dict(
            session_name="onnxrt",
            model_path=os.path.join(models_base_path, "my_model.onnx"),
            input_mean=[0.0, 0.0, 0.0],
            input_scale=[1.0, 1.0, 1.0],
            input_optimization=True,
            input_details={"input": [1, 3, 224, 224]},
            output_details={"output": [1, 6]},
        ),
        extra_info=dict(
            num_images=numImages,
            num_classes=6,
        )
    ),


   and models_base_path =“../../../models /“
11.python3 onnxrt_ep.py -c -m cl-ort-dsm_model
   错误如下:
    
Available execution providers :  ['AzureExecutionProvider', 'CPUExecutionProvider']

Running 1 Models - ['cl-ort-my_model']


Running_Model :  cl-ort-my_model  


Running shape inference on model ../../../models/my_model.onnx 

/home/user/.local/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py:121: UserWarning: Specified provider 'TIDLCompilationProvider' is not in available provider names.Available providers: 'AzureExecutionProvider, CPUExecutionProvider'
  warnings.warn(
*************** EP Error ***************
EP Error Unknown Provider Type: TIDLCompilationProvider when using ['TIDLCompilationProvider', 'CPUExecutionProvider']
Falling back to ['CPUExecutionProvider'] and retrying.
****************************************
Process Process-1:
Traceback (most recent call last):
  File "/usr/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/lib/python3.10/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/user/edgeai-tidl-tools/examples/osrt_python/ort/onnxrt_ep.py", line 388, in run_model
    for j in range(batch):
TypeError: 'str' object cannot be interpreted as an integer


请检查并验证我所执行的步骤。 帮助我修复错误。 我需要修改任何其他内容来编译模型

此致、
Sajan

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

    还有一个问题是我应该在 onnxrt_ep.py 中更改代码了
    效果

    calib_images = [
        "../../../test_data/airshow.jpg",
        "../../../test_data/ADE_val_00001801.jpg",
    ]
    class_test_images = ["../../../test_data/airshow.jpg"]
    od_test_images = ["../../../test_data/ADE_val_00001801.jpg"]
    seg_test_images = ["../../../test_data/ADE_val_00001801.jpg"]
    

    如果是、我是否应该将数据集中的一些随机图像添加到该路径中。 此 python 代码中有任何要更改的内容

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

    您好、Sajan、

    从错误日志中、看起来您的模型没有以静态尺寸导出、例如、对于批次、 通道、高度和宽度尺寸。 从 Pytorch 到 ONNX 的模型导出应提供静态设置尺寸[0]。

    这就是为什么您看到批维被解释为一个字符串,以及为什么您 在模型解析日志中看到许多“未知输入维,不受 TIDL 支持“的实例。

     [0] https://docs.pytorch.org/tutorials/beginner/onnx/export_simple_model_to_onnx_tutorial.html  

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

    您好、Sajan、

    错误表明存在未设置的预期“params['postprocess ']“。 这应该位于模型工件的 param.yaml 文件中、完成模型编译后将创建 edgeai-tidl-tools。 此文件对模型文件本身中原本不包含的各种设置(通常用于预处理和后处理)进行编码。  

    我在我们的 model_zoo 模型(如/opt/model_zoo/ONR-CL-6360-regNetx-200mf)中看到 有一个 param.yaml、字段为“postprocess:{}“(空)  

    看起来 10.1 中有一个错误、如果您没有设置后处理、则 param.yaml 中不会出现此字段。  

    您可以执行以下操作之一:

    • 编辑您的 param.yaml、为“postprocess:{}“添加一行
    • 为您的模型编辑您的 model_configs.py ,使其包含“'postprocess ': dict ()“

    BR、
    Reese

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

    您好 Reese、

    为您的模型编辑您的 model_configs.py、使其包含“'postprocess':dict ()“

    您能帮助我补充一下这个词句吗?
    现有配置为:

            "cl-ort-my_model": create_model_config(
            task_type="classification",
            source=dict(
                model_path=os.path.join(models_base_path, "my_model.onnx"),
            ),
            preprocess=dict(
                resize=256,
                crop=224,
                data_layout="NCHW",
                resize_with_pad=False,
                reverse_channels=False,
            ),
            session=dict(
                session_name="onnxrt",
                model_path=os.path.join(models_base_path, "my_model.onnx"),
                input_mean=[0.485, 0.456, 0.406],
                input_scale=[1 / 0.229, 1 / 0.224, 1 / 0.225],
                input_optimization=True,
                input_details={
                    "name": "input",
                    "shape": [1, 3, 224, 224]
                },
                output_details={
                    "name": "output",
                    "shape": [1, 6]
                },
            ),
            extra_info=dict(
                num_images=numImages,
                num_classes=6,
            )
        ),




    注意:我尝试简单地将 postprocess:{}添加到 param.yaml。 它有效、但仅 在 post_process 中打印其他部分。 如果不像我那样、请纠正我。

    上面提到的其他部分,它没有进入 IF 部件
            for idx in topN_classes:                                       
                idx += self.model.label_offset                         
                class_name = self.model.dataset_info.get(idx, None)           
                if class_name:                                     
                    name = class_name.name                
                    if class_name.supercategory:                   
                        name = f"{class_name.supercategory}/{name}"    
                else:                                              
                    name = "Normal"                      
                class_list.append(name)      


    此致、
    Sajan

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

    您的 model-config 将包括(在末尾):

            ),
            extra_info=dict(
                num_images=numImages,
                num_classes=6,
            ),
            postprocess=dict(),
        ),

    上面提到的其他部分、它没有进入 IF 器件[/报价]

    好的、如果我正确地解释(模糊的)注释、这是不同的部分。 这是关于查找模型的类的名称。  

    self.model.dataset_info.get(idx, None) 

    • 该行可能找不到数据集信息、数据集信息将位于 model-artifacts/dataset.yaml 中。 此文件是否存在?
      • 使用 edgeai-tidl-tools 进行编译时、dataset.yaml 的默认内容可能没有信息。 这是因为它不知道您的数据集包括哪些内容。 edgeai-modelmaker 和模型编写器为您的数据集提供此版本的文件。 对于 edgeai-tidl-tools、您可能需要自己编写该 dataset.yaml 文件、或从 modelmaker/Composer 的相应输出进行复制。  
    • 我建议打印上面复制的行的输出、并使用该输出来诊断为什么找不到您的类名。  
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Reese、

    在 model_config.py 中添加了后处理 Dict 并重新编译。 没有变化。

    打印我上面复制的行的输出并使用它来诊断为什么找不到您的类名。  [/报价]

    尝试打印 class_name 时为 None。


    此文件是否存在

    info:
      description: classification dataset
    categories:
    - id: 1
      supercategory: classification
      name: category_1
    - id: 2
      supercategory: classification
      name: category_2
    - id: 3
      supercategory: classification
      name: category_3
    - id: 4
      supercategory: classification
      name: category_4
    - id: 5
      supercategory: classification
      name: category_5
    - id: 6
      supercategory: classification
      name: category_6
    color_map:
    - - 0
      - 0
      - 0
    - - 0
      - 0
      - 255
    - - 0
      - 255
      - 0
    - - 0
      - 255
      - 255
    - - 255
      - 0
      - 0
    - - 255
      - 0
      - 255
    - - 255
      - 255
      - 0
    - - 255
      - 255
      - 255
      
      
      =============================================================================================
      
      I tried changing this with respective class names
      
    info: {}
    categories:
    - id: 1
      name: Class1
    - id: 2
      name: Class2
    - id: 3
      name: Class3
    - id: 4
      name: Class4
    - id: 5
      name: Class5
    - id: 6
      name: Class7
    color_map:
    - - 0
      - 0
      - 0
    - - 0
      - 0
      - 255
    - - 0
      - 255
      - 0
    - - 0
      - 255
      - 255
    - - 255
      - 0
      - 0
    - - 255
      - 0
      - 255
    - - 255
      - 255
      - 0
    - - 255
      - 255
      - 255
      




    [报价 userid=“360457" url="“ url="~“~/support/processors-group/processors/f/processors-forum/1547627/edge-ai-studio-model-compiling-using-edgeai-tidl-tools/5964799
      • 使用 edgeai-tidl-tools 进行编译时、dataset.yaml 的默认内容可能没有信息。 这是因为它不知道您的数据集包括哪些内容。 edgeai-modelmaker 和模型编写器为您的数据集提供此版本的文件。 对于 edgeai-tidl-tools、您可能需要自己编写该 dataset.yaml 文件、或从 modelmaker/Composer 的相应输出进行复制。  
    [/报价]

    我没有明白。

    帮助我解决问题。

    此致、
    Sajan

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

    您好、Sajan、

    对我来说看起来像一个有效的 dataset.yaml。

    [引述 userid=“634264" url="“ url="~“~/support/processors-group/processors/f/processors-forum/1547627/edge-ai-studio-model-compiling-using-edgeai-tidl-tools/5966333

    在 model_config.py 中添加了后处理 Dict 并重新编译。 没有变化。

    [/报价]

    这是否意味着您最新编译的模型在 param.yaml 中仍然没有“postprocess:{}“?

    我建议打印“idx",“,"classname"、"classname"和“和"elf.model.label_offset"“"elf.model.label_offset"以“以 跟踪“跟踪此处发生的情况。 如果 label_offset 是某个非数字值(如无)、则会导致 idx 也为无

    可能发生的情况是 param.yaml 中缺少设置、如下所示:  

    metric:
      label_offset_pred: -1

    如果缺少、请创建并分配给“0"。“。 否则请提供您的整个 param.yaml 以便我可以分析。

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

    您好 Reese、

    这是否意味着您最新编译的模型在 param.yaml 中仍然没有'postprocess:{}'?

    否、最新编译的模型具有 param.yaml 中的后处理:{}

    我建议打印“idx",“,"classname"、"classname"和“和"elf.model.label_offset"“"elf.model.label_offset"以“以 跟踪“跟踪此处发生的情况。

    idx : 0
    self.model.label_offset: 0
    class_name : None
    idx : 0
    self.model.label_offset: 0
    class_name : None
    idx : 0
    self.model.label_offset: 0
    class_name : None
    idx : 0
    self.model.label_offset: 0
    class_name : None
    idx : 0
    self.model.label_offset: 0
    class_name : None
    idx : 0
    self.model.label_offset: 0
    class_name : None
    idx : 0
    self.model.label_offset: 0
    class_name : None
    idx : 0
    self.model.label_offset: 0
    class_name : None

    param.yaml 中缺少设置、如下所示:

    task_type: classification
    preprocess:
      resize:
      - 256
      - 256
      crop:
      - 224
      - 224
      data_layout: NCHW
      resize_with_pad: false
      reverse_channels: false
      add_flip_image: false
    session:
      session_name: onnxrt
      model_path: model/my_model.onnx
      input_mean:                     
      - 0.485                         
      - 0.456    
      - 0.406
      input_scale:
      - 4.366812  
      - 4.464286  
      - 4.444444
      input_optimization: true
      input_details:          
      - name: input           
        shape:      
        - 1        
        - 3   
        - 224
        - 224
        type: tensor(float)
      output_details:      
      - name: input        
        shape:       
        - 1        
        - 6   
        type: tensor(float)
      artifacts_folder: artifacts
      input_data_layout: NCHW    
      target_device: AM62A       
    postprocess: {}    

    已尝试 在 param.yaml 中添加度量:。 打印是  

    idx : -1
    self.model.label_offset: -1
    class_name : None
    idx : -1
    self.model.label_offset: -1
    class_name : None
    idx : -1
    self.model.label_offset: -1
    class_name : None
    idx : -1
    self.model.label_offset: -1
    class_name : None
    idx : -1
    self.model.label_offset: -1
    class_name : None


    当值为–1 或 0 时、它会进入 暴露 后处理分类的一部分。

    此致、
    Sajan

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

    我需要看到完整的 param.yaml。 问题可能与后处理无关、而是输入的预处理方式与培训期间的处理方式不同。 您在哪里训练模型?

      input_mean:                     
      - 0.485                         
      - 0.456    
      - 0.406
      input_scale:
      - 4.366812  
      - 4.464286  
      - 4.444444

    这些值看起来像 imagenet 数据集的 Mean 和 1/STDev。 这通常用作许多模型的预处理参数、因为 imagenet 通常用于训练主干/特征提取器。  

    但是、这些假设您的数据是在时间间隔[0、1]上加载的--在我们的工具中、情况并非如此。 它以 uint8 的形式加载(因此间隔[0255])。

    尝试将平均值乘以 255、并将 INPUT_SCALE 除以 255。 它们可能与我们的 model_zoo[0]中其他分类模型的值相同。 如果您在 Edge Studio 中使用 edgeai-modelmaker 或模型编写器进行了训练、则这些工件中包含的 param.yaml 可能使用了这些相同的值。  

    当您使用 edgeai-tidl-tools 进行编译时、一个很好的步骤是将网络作为数据集映像的分类运行、并检查输出是否合理。 您可以这样做、它可以与 ONNX 模型版本(在 CPU 上运行)一起运行。 如果 CPU 版本的输出不好、通常是预处理参数不正确的结果。

    BR、
    Reese

     [0] https://github.com/TexasInstruments/edgeai-tidl-tools/blob/19ac4e61b40890537ab67fb3036780f41a7ade3a/examples/osrt_python/model_configs.py#L60 

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

    使用 Pytorch 进行训练。

    我不熟悉使用 Pytorch 进行模型训练。 和加载器部分中的说明。 即输入均值 transform.normalize。

    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])


    您能验证我编写的配置代码吗?
            "cl-ort-my_model": create_model_config(
            task_type="classification",
            source=dict(
                model_path=os.path.join(models_base_path, "my_model.onnx"),
            ),
            preprocess=dict(
                resize=256,
                crop=224,
                data_layout="NCHW",
                resize_with_pad=False,
                reverse_channels=False,
            ),
            session=dict(
                session_name="onnxrt",
                model_path=os.path.join(models_base_path, "my_model.onnx"),
                input_mean=[0.485, 0.456, 0.406],
                input_scale=[1 / 0.229, 1 / 0.224, 1 / 0.225],
                input_optimization=True,
                input_details={
                    "name": "input",
                    "shape": [1, 3, 224, 224]
                },
                output_details={
                    "name": "output",
                    "shape": [1, 6]
                },
            ),
            extra_info=dict(
                num_images=numImages,
                num_classes=6,
            ),
            postprocess=dict(),
        ),
    



    注意:我尝试删除分数 (input_cale=[0.229、0.224、0.225]) 并重新编译。 运行模型时出现与 tidl 相关的错误
    Warning : Couldn't find corresponding ioBuf tensor for onnx tensor with matching name 
    Invoke  : ERROR: Unable to allocate memory for TIDL RT in[] out [] tensor struct
    2025-08-11 09:06:39.843151013 [E:onnxruntime:, sequential_executor.cc:514 ExecuteKernel] Non-zero status code returned while running TIDL_1 node. Name:'TIDLExecutionProvider_TIDL_1_1' Status Message: TIDL Compute Invoke Failed.
    Exception in thread Thread-1 (pipeline):
    Traceback (most recent call last):
      File "/usr/lib/python3.12/threading.py", line 1075, in _bootstrap_inner
        self.run()
      File "/usr/lib/python3.12/threading.py", line 1012, in run
        self._target(*self._args, **self._kwargs)
      File "/opt/edgeai-gst-apps/apps_python/infer_pipe.py", line 137, in pipeline
        result = self.run_time(input_img)
                 ^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.12/site-packages/edgeai_dl_inferer.py", line 198, in __call__
        return self.interpreter.run(None, {self.input_name: input_img})
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.12/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py", line 217, in run
        return self._sess.run(output_names, input_feed, run_options)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    onnxruntime.capi.onnxruntime_pybind11_state.Fail: [ONNXRuntimeError] : 1 : FAIL : Non-zero status code returned while running TIDL_1 node. Name:'TIDLExecutionProvider_TIDL_1_1' Status Message: TIDL Compute Invoke Failed.


    此致、
    Sajan

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

    您好、Sajan、  

    好的、这是我怀疑的。 您不会首先了解预处理的这些详细信息

     

    替换 input_mean 和 input_SCALE 以使用与此链接中的值类似的值。  

    BR、
    Reese

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

    尊敬的 Reese:

    替换 input_mean 和 input_SCALE、以使用此链接中的值。  [/报价]

    我在替换 input_mean 和 input_SCALE 后尝试了模型编译。 没有变化。 代码通过 post_proced.py 中的 else 部分。

    我应该需要训练模型吗 (transformers.ormalize) 使用上述存储库中的值。

    此致、
    Sajan

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

    您好、Sajan、

    我们现在将在 edgeai-tidl-tools 中进行测试、然后回到模型开发流程的更基本部分。 我们将使用 edgeai-tidl-tools/examples/osrt_python/ort/onnxrt_ep.py

    如果您使用-d 标签与 onnxrt_ep.py 一起运行模型来禁用 TIDL、而改用 CPUExecutionProvider、结果是什么? 您应使用数据集中的图像。

    那么最高置信指数是否对应于预期的类别? 如果不是、则问题可能仍是预处理。 如果结果良好、则在没有-d 的情况下再次运行、以便将 TIDLExecutionProvider 用于您的模型工件

    • 并不是使用-d 标签可能会删除现有的模型工件、并且需要您重新运行编译 (-c)
    [引述 userid=“634264" url="“ url="~“~/support/processors-group/processors/f/processors-forum/1547627/edge-ai-studio-model-compiling-using-edgeai-tidl-tools/5972776

    我应该需要训练模型吗 (transformers.ormalize) 使用上述存储库中的值。

    [/报价]

    否、无需使用不同的预处理参数进行重新训练。  

    请再次复制 model_config 条目和 param.yaml

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

    您好、Sajan、

    我们现在将在 edgeai-tidl-tools 中进行测试、然后回到模型开发流程的更基本部分。 我们将使用 edgeai-tidl-tools/examples/osrt_python/ort/onnxrt_ep.py

    如果您使用-d 标签与 onnxrt_ep.py 一起运行模型来禁用 TIDL、而改用 CPUExecutionProvider、结果是什么? 您应使用数据集中的图像。

    那么最高置信指数是否对应于预期的类别? 如果不是、则问题可能仍是预处理。 如果结果良好、则在没有-d 的情况下再次运行、以便将 TIDLExecutionProvider 用于您的模型工件

    • 并不是使用-d 标签可能会删除现有的模型工件、并且需要您重新运行编译 (-c)
    [引述 userid=“634264" url="“ url="~“~/support/processors-group/processors/f/processors-forum/1547627/edge-ai-studio-model-compiling-using-edgeai-tidl-tools/5972776

    我应该需要训练模型吗 (transformers.ormalize) 使用上述存储库中的值。

    [/报价]

    否、无需使用不同的预处理参数进行重新训练。  

    请再次复制 model_config 条目和 param.yaml

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

    尊敬的 Reese:

    如果您使用-d 标签与 onnxrt_ep.py 一起运行模型以禁用 TIDL、而使用 CPUExecutionProvider、结果是什么? [/报价]

    已尝试  python3 onnxrt_ep.py -d -m cl-ort-my_model 。 已生成模型、但工件文件夹不包含任何内容。
    我检查了是否在 apps_python 中运行该模型。 它将打开、帧速率约为 8fps。 配置 I 中指定为 24 帧。

    启动应用程序时的警告为:

    ******** WARNING ******* : Could not open /opt/model_zoo/cl-ort-my_model/artifacts/allowedNode.txt for reading... Entire model will run on ARM without any delegation to TIDL !


    dataset.yaml 包含类 AS  
      supercategory: classification
      name: category_1
     

    它将输出为 CATEGORY_1 或其他内容。 它也不准确。 我根据假设找到 category_4 各自的名称。


    此致、
    Sajan

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

    在此阶段、请保持在 edgeai-tidl-tools 内。 我们正在尝试了解输入预处理是否是导致输出不准确的根本原因。 如果预处理错误、您的输出将是错误的。

    使用-d 将删除您的工件 yes、但也会在 CPUExecutionProvider 上运行基准.onnx。 无需 TIDL 工件即可运行该过程。 这用于检查.ONNX 模型本身的行为是否正确。 -d 表示“disable_offload"。“。 这将运行缓慢,但也将运行在模型的原生数据类型与 ONNX 的实现。  

    当模型使用 edgeai-tidl-tools python 脚本运行时、它会将输出文件写入 edgeai-tidl-tools/output_images、其中显示了模型的后处理输出。 我们希望确保这对于您的模型而言是准确的。  同样、如果使用-d 标签运行、它将在 CPU 上运行。 如果省略此标签、它将尝试使用 TIDL 进行加速(在 x86 上进行仿真,或在目标处理器上通过硬件进行加速)

    如果要查看模型的实际输出、common_utils.py 包括分类任务的后处理代码--您可以在打印这些结果时添加一些额外的代码。

    请再次复制 model_config 条目和 param.yaml

    我的意思是、请附上这个主题。  

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

    您好 Reese、

    请附加到此主题。  [/报价]

    # model_config
    
            "cl-ort-my_model": create_model_config(
            task_type="classification",
            source=dict(
                model_path=os.path.join(models_base_path, "my_model.onnx"),
            ),
            preprocess=dict(
                resize=256,
                crop=224,
                data_layout="NCHW",
                resize_with_pad=False,
                reverse_channels=False,
            ),
            session=dict(
                session_name="onnxrt",
                model_path=os.path.join(models_base_path, "my_model.onnx"),
                input_mean=[123.675, 116.28, 103.53],
                input_scale=[0.017125, 0.017507, 0.017429],
                input_optimization=True,
                input_details={
                    "name": "input",
                    "shape": [1, 3, 224, 224]
                },
                output_details={
                    "name": "output",
                    "shape": [1, 6]
                },
            ),
            extra_info=dict(
                num_images=numImages,
                num_classes=6,
            ),
            postprocess=dict(),
        ),
    


    # param.yaml
    
    task_type: classification
    preprocess:
      resize:
      - 256
      - 256
      crop:
      - 224
      - 224
      data_layout: NCHW
      resize_with_pad: false
      reverse_channels: false
      add_flip_image: false
    session:
      session_name: onnxrt
      model_path: model/my_model.onnx
      input_mean:
      - 123.675
      - 116.28
      - 103.53
      input_scale:
      - 0.017125
      - 0.017507
      - 0.017429
      input_optimization: true
      input_details:
      - name: input
        shape:
        - 1
        - 3
        - 224
        - 224
        type: tensor(float)
      output_details:
      - name: input
        shape:
        - 1
        - 6
        type: tensor(float)
      artifacts_folder: artifacts
      input_data_layout: NCHW
      target_device: AM62A
    postprocess: {}



    模型的实际输出、common_utils.py 包括分类任务的后处理代码--您可以在打印这些结果时添加一些附加代码。

    您能帮忙吗? 我也检查了代码。 找不到与输出名称相关的任何内容。  
    如何传递映像以验证并获取 edgeai-tidl-tools/output_images 的输出文件?

    此致、
    Sajan

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

    param.yaml 和 model_config 看起来正确。  

    在 onnxrt_ep.py 中、您可以更改 class_test_images 以指向您自己的映像。 get_class_labels [1]  用于在 common_utils.py 中查找后处理。 它也引用自 onnxrt_ep.py。 它将假定 python 中有一些'classs'变量。  

    在 edgeai-tidl-tools/output_images 中生成的映像中、使用 onnxrt_ep.py 中的-d 标签运行模型的结果是什么? 这看起来是否合理? 我建议使用数据集中的图像。 您还可以查看推理的输出、并查看哪个索引的值最高--这将是您认可的类。  

    您能帮您解决这个问题吗?

    我要求您添加打印对帐单。 我不能在每个调试步骤的细节上提供给您。 如果您无法添加几行代码来调试此组件、我不知道如何构建实际的应用程序。 您正在突破我们的免费支持的界限。 我希望您自己调试其中的一些内容、并指导如何进行调试。  

    输出名称、标签、类实际上都是相同的想法。 它是与您的分类相对应的文本名称或整数索引。  

    如果你通过我的模型和测试图像,我可能可以自己验证,但预计它需要几天.

    [1] https://github.com/TexasInstruments/edgeai-tidl-tools/blob/95ba2c7ec62bbedeb637d7a5c0273fcede21cac9/examples/osrt_python/common_utils.py#L332 

    BR、
    Reese