This tutorial briefly introduces how to export an OpenMMlab model to a specific backend using MMDeploy tools. Notes:
- Supported backends are ONNXRuntime, TensorRT, ncnn, PPLNN, OpenVINO.
- Supported codebases are MMClassification, MMDetection, MMSegmentation, MMOCR, MMEditing.
- Install and build your target backend. You could refer to ONNXRuntime-install, TensorRT-install, ncnn-install, PPLNN-install, OpenVINO-install for more information.
- Install and build your target codebase. You could refer to MMClassification-install, MMDetection-install, MMSegmentation-install, MMOCR-install, MMEditing-install.
python ./tools/deploy.py \
${DEPLOY_CFG_PATH} \
${MODEL_CFG_PATH} \
${MODEL_CHECKPOINT_PATH} \
${INPUT_IMG} \
--test-img ${TEST_IMG} \
--work-dir ${WORK_DIR} \
--calib-dataset-cfg ${CALIB_DATA_CFG} \
--device ${DEVICE} \
--log-level INFO \
--show \
--dump-info
deploy_cfg
: The path of deploy config file in MMDeploy codebase.model_cfg
: The path of model config file in OpenMMLab codebase.checkpoint
: The path of model checkpoint file.img
: The path of image file that used to convert model.--test-img
: The path of image file that used to test model. If not specified, it will be set toNone
.--work-dir
: The path of work directory that used to save logs and models.--calib-dataset-cfg
: Only valid in int8 mode. Config used for calibration. If not specified, it will be set toNone
and use "val" dataset in model config for calibration.--device
: The device used for conversion. If not specified, it will be set tocpu
.--log-level
: To set log level which in'CRITICAL', 'FATAL', 'ERROR', 'WARN', 'WARNING', 'INFO', 'DEBUG', 'NOTSET'
. If not specified, it will be set toINFO
.--show
: Whether to show detection outputs.--dump-info
: Whether to output information for SDK.
- Find model's codebase folder in
configs/
. Example, convert a yolov3 model you need to findconfigs/mmdet
folder. - Find model's task folder in
configs/codebase_folder/
. Just like yolov3 model, you need to findconfigs/mmdet/detection
folder. - Find deployment config file in
configs/codebase_folder/task_folder/
. Just like deploy yolov3 model you can useconfigs/mmdet/detection/detection_onnxruntime_dynamic.py
.
python ./tools/deploy.py \
configs/mmdet/detection/detection_tensorrt_dynamic-320x320-1344x1344.py \
$PATH_TO_MMDET/configs/yolo/yolov3_d53_mstrain-608_273e_coco.py \
$PATH_TO_MMDET/checkpoints/yolo/yolov3_d53_mstrain-608_273e_coco.pth \
$PATH_TO_MMDET/demo/demo.jpg \
--work-dir work_dir \
--show \
--device cuda:0
You can try to evaluate model, referring to how_to_evaluate_a_model.
Refer to Support model list