Integrating YOLO V5 to KL520

Hello,


We tried to train yolov5 using this repository: https://github.com/ultralytics/yolov5

After saving to onnx format in version 11 and downgrading the ir_version to version 4, we are able to convert the PyTorch-exported onnx and optimize it using "pytorch_exported_onnx_preprocess.py" in "optimizer_scripts" folder. The resulting onnx file is attached as "best_v11_ir4.opt_onnx.zip".

Then, to convert the onnx file into NEF format, we tried to do the same steps listed in the yolo v3 example for KL520 integration: http://doc.kneron.com/docs/#toolchain/yolo_example/ , But, we encountered an error when performing the km.evaluate() command as depicted in the screenshot. We found that you successfully converted yolov5 to nef model. Can you please share with us how to convert yolov5 model from onnx to nef?



Comments

  • edited November 2021

    @Praveen

    Hi Praveen,

    Your question has two parts:

    First, the model you are using has unsupported nodes.

    Second, if you want to use your model, you can only use KL720 to make inferences. KL520 currently does not support Sigmoid operator.


    Before you use "pytorch_exported_onnx_preprocess.py" to export onnx, it is recommended that you first try to remove some operators that are not supported by Kneron docker ToolChain from your Model (e.g. Reshape), and then use Kneron Linux Toolchain Manual 3.1.5 ONNX Optimization The API is optimized for .onnx files, such as

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

    Once you have the optimized .onnx, then you can follow the steps in the Kneron Linux Toolchain Manual 3.2 IP Evaluation to convert to .nef.

  • @Andy Hsieh


    Thanks for your response. Do you think yolov5 works with KL720? Can you please check for me whether the following ONNX file which contains sigmoid operator is compatible with KL720. If yes, I would like to use KL720.


    Thank you in advance



  • @Praveen

    Hi Praveen,

    Yes, the model you provided ('yolov5s-noupsample_convert.zip') can be used in KL720.🙂

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