This doc introduces how to convert your pytorch model into onnx, and how to run an onnxruntime demo to verify your convertion.
Model | Parameters | GFLOPs | Test Size | mAP | Weights |
---|---|---|---|---|---|
YOLOX-Nano | 0.91M | 1.08 | 416x416 | 25.3 | onedrive/github |
YOLOX-Tiny | 5.06M | 6.45 | 416x416 | 31.7 | onedrive/github |
YOLOX-S | 9.0M | 26.8 | 640x640 | 39.6 | onedrive/github |
YOLOX-M | 25.3M | 73.8 | 640x640 | 46.4 | onedrive/github |
YOLOX-L | 54.2M | 155.6 | 640x640 | 50.0 | onedrive/github |
YOLOX-Darknet53 | 63.72M | 185.3 | 640x640 | 47.3 | onedrive/github |
YOLOX-X | 99.1M | 281.9 | 640x640 | 51.2 | onedrive/github |
First, you should move to <YOLOX_HOME> by:
cd <YOLOX_HOME>
Then, you can:
- Convert a standard YOLOX model by -n:
python3 tools/export_onnx.py --output-name yolox_s.onnx -n yolox-s -c yolox_s.pth.tar
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])
- 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.tar
- 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.tar
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.