yolox model conversion problem

I was trying to convert this yolox model in kneron toolchain and encountered this error:

Using TensorFlow backend.

Traceback (most recent call last):

 File "convert_yolox.py", line 12, in <module>

  result_m = ktc.onnx_optimizer.torch_exported_onnx_flow(exported_m)

 File "/workspace/libs/ONNX_Convertor/optimizer_scripts/pytorch_exported_onnx_preprocess.py", line 30, in torch_exported_onnx_flow

  m = combo.common_optimization(m)

 File "/workspace/libs/ONNX_Convertor/optimizer_scripts/tools/combo.py", line 135, in common_optimization

  fusing.fuse_slice_nodes_into_conv(g)

 File "/workspace/libs/ONNX_Convertor/optimizer_scripts/tools/fusing.py", line 1084, in fuse_slice_nodes_into_conv

  remove_nodes(input_value.name)

 File "/workspace/libs/ONNX_Convertor/optimizer_scripts/tools/fusing.py", line 1007, in remove_nodes

  g.node.remove(input_weight)

ValueError: Item to delete not in list



the code to convert is:

import ktc
import onnx
import torch
import torch.onnx


import numpy as np, os, sys, re, json


# Load model
exported_m = onnx.load('yolox_s.onnx')


# Optimize the exported onnx object
result_m = ktc.onnx_optimizer.torch_exported_onnx_flow(exported_m)

# onnx2onnx
optimized_m = ktc.onnx_optimizer.onnx2onnx_flow(result_m, eliminate_tail=True)

# save converted
onnx.save(optimized_m, 'yolox_cvt.onnx')

# eval result
km = ktc.ModelConfig(51200, "0001", "730", onnx_model=optimized_m)
eval_result = km.evaluate()
print("\nNpu performance evaluation result:\n" + str(eval_result))
Tagged:

Comments

  • edited November 2022

    @Werner

    Hi Werner,

    Sorry for the late reply; I have confirmed the problem for you here.

    These two APIs will have errors in the latest version (kneron/toolchain:v0.19.0) of the Kneron Toolchain for the model you are using.

    # Optimize the exported onnx object

    result_m = ktc.onnx_optimizer.torch_exported_onnx_flow(exported_m)

    # onnx2onnx

    optimized_m = ktc.onnx_optimizer.onnx2onnx_flow(result_m, eliminate_tail=True)


    You can try using Kneron Toolchain v0.17.2 when using these two APIs

    docker run --rm -it -v /mnt/docker:/docker_mount kneron/toolchain:v0.17.2


    Other actions (e.g., eval result) are used in the latest version of the Kneron Toolchain (kneron/toolchain:latest).

    docker run --rm -it -v /mnt/docker:/docker_mount kneron/toolchain:latest

    # eval result

    km = ktc.ModelConfig(51200, "0001", "730", onnx_model=optimized_m)

    eval_result = km.evaluate()

    print("\nNpu performance evaluation result:\n" + str(eval_result))

The discussion has been closed due to inactivity. To continue with the topic, please feel free to post a new discussion.