YOLOX-ONNXRuntime in Python

This doc introduces how to convert your pytorch model into onnx, and how to run an onnxruntime demo to verify your convertion.

Download ONNX models.

ModelParametersGFLOPsTest SizemAPWeights
YOLOX-Nano0.91M1.08416x41625.8github
YOLOX-Tiny5.06M6.45416x41632.8github
YOLOX-S9.0M26.8640x64040.5github
YOLOX-M25.3M73.8640x64047.2github
YOLOX-L54.2M155.6640x64050.1github
YOLOX-Darknet5363.72M185.3640x64048.0github
YOLOX-X99.1M281.9640x64051.5github

Convert Your Model to ONNX

First, you should move to <YOLOX_HOME> by:

cd <YOLOX_HOME>

Then, you can:

  1. Convert a standard YOLOX model by -n:
python3 tools/export_onnx.py --output-name yolox_s.onnx -n yolox-s -c yolox_s.pth

Notes:

  • -n: specify a model name. The model name must be one of the [yolox-s,m,l,x and yolox-nane, yolox-tiny, yolov3]

  • -c: the model you have trained

  • -o: opset version, default 11. However, if you will further convert your onnx model to OpenVINO, please specify the opset version to 10.

  • --no-onnxsim: disable onnxsim

  • To customize an input shape for onnx model, modify the following code in tools/export.py:

    dummy_input = torch.randn(1, 3, exp.test_size[0], exp.test_size[1])
  1. Convert a standard YOLOX model by -f. When using -f, the above command is equivalent to:
python3 tools/export_onnx.py --output-name yolox_s.onnx -f exps/default/yolox_s.py -c yolox_s.pth
  1. To convert your customized model, please use -f:
python3 tools/export_onnx.py --output-name your_yolox.onnx -f exps/your_dir/your_yolox.py -c your_yolox.pth

ONNXRuntime Demo

Step1.

cd <YOLOX_HOME>/demo/ONNXRuntime

Step2.

python3 onnx_inference.py -m <ONNX_MODEL_PATH> -i <IMAGE_PATH> -o <OUTPUT_DIR> -s 0.3 --input_shape 640,640

Notes:

  • -m: your converted onnx model
  • -i: input_image
  • -s: score threshold for visualization.
  • --input_shape: should be consistent with the shape you used for onnx convertion.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值