[Docs] Describe how model_config and deploy_config is used for generating TensorRT engine and TensorRT Inference
📚 The doc issue
I am using mmdeploy to convert mmdet models to TensorRT using python3 tools/deploy.py. My understanding is that, we can set the post-processing in codebase_config:
codebase_config = dict(
type='mmdet',
task='ObjectDetection',
model_type='end2end',
post_processing=dict(
score_threshold=0.9,
confidence_threshold=0.9, # for YOLOv3
iou_threshold=0.5,
max_output_boxes_per_class=200,
pre_top_k=5000,
keep_top_k=100,
background_label_id=-1,
))
In the generated details.json, this configuration is successfully reflected. However, when using the TensorRT model to perform inference, it is not the case -- as you can see, I set a very high score threshold to filter out the predictions, but it isn't filtered out. Also, updating the test_cfg in model_config during inference time on the fly works with the pytorch model, but not the generated TensorRT model, is this expected?
Looking at the pipeline.json, it seems like the TensorRT model is generated with the test_cfg in the model configuration, not the deploy configuration.
Can you confirm the understanding is correct? Can we provide some documentation around:
- If changing post-processing threshold is required, where we should change them?
- How are these configurations being used in the conversion process? Is
codebase_configoverwriting model_config file?
mmdeploy environment: openmmlab/mmdeploy:ubuntu20.04-cuda11.3-mmdeploy0.14.0 mmdet version: mmdet==2.28.2
Thanks!
Suggest a potential alternative/fix
No response
@xiaolul hi, the params for nms are first abtained from model config as you can see. This is intended to align pytorch model and backend model with same config. https://github.com/open-mmlab/mmdeploy/blob/0a8cbe2286dcb226f3140d0bae8700cdfaf37a47/mmdeploy/codebase/mmdet/models/dense_heads/yolo_head.py#L133-L140
Thus
- If the parameter exists in model config, change it in model config.
- If the parameter not exists in model config but exists in deploy config, then change it in deploy config.
Thank you. So if model_config already configured something, then in the TensorRT conversion step, it is already built-in and we cannot change it in inference. Is it a correct understanding?
Thank you. So if model_config already configured something, then in the TensorRT conversion step, it is already built-in and we cannot change it in inference. Is it a correct understanding?
Yes, nms parameters are exported into onnx model. If you want to change them, you need to change in the model config and rerun tools/deploy.py.
Thanks for the clarification!