mmpose
mmpose copied to clipboard
onnx model output node shape is incorrect
Thanks for your error report and we appreciate it a lot. If you feel we have helped you, give us a STAR! :satisfied:
Checklist
- I have searched related issues but cannot get the expected help.
- The bug has not been fixed in the latest version.
Describe the bug
onnx model output node shape is incorrect for top-down hand keypoint model.
mmpose: 0.16.0 mmcv: 1.3.9
Reproduction
- What command or script did you run?
A placeholder for the command.
- What config did you run?
A placeholder for the config.
- Did you make any modifications on the code or config? Did you understand what you have modified?
- What dataset did you use?
Environment
- Please run
PYTHONPATH=${PWD}:$PYTHONPATH python mmpose/utils/collect_env.py
to collect necessary environment information and paste it here. - You may add addition that may be helpful for locating the problem, such as
- How you installed PyTorch [e.g., pip, conda, source]
- Other environment variables that may be related (such as
$PATH
,$LD_LIBRARY_PATH
,$PYTHONPATH
, etc.)
Error traceback
If applicable, paste the error traceback here.
A placeholder for traceback.
Bug fix
If you have already identified the reason, you can provide the information here. If you are willing to create a PR to fix it, please also leave a comment here and that would be much appreciated!
Thanks for your report. Could you please provide more information like the command you run the script and the model config you use?
@ly015 I find that if input_transform='resize_concat' in TopdownHeatmapSimpleHead, onnx model output node shape like above.
reproduce steps
- mmpose v0.20.0
python tools/deployment/pytorch2onnx.py \
configs/wholebody/2d_kpt_sview_rgb_img/topdown_heatmap/coco-wholebody/hrnet_w48_coco_wholebody_256x192.py \
hrnet_w48_coco_256x192-b9e0b3ab_20200708.pth \
--output-file ~/hrnet_w48_coco_256x192.onnx \
--verify
- output
load checkpoint from local path: /dataset/wjx/downloads/hrnet_w32_coco_256x192-c78dce93_20200708.pth
The model and loaded state dict do not match exactly
size mismatch for keypoint_head.final_layer.weight: copying a param with shape torch.Size([17, 32, 1, 1]) from checkpoint, the shape in current model is torch.Size([133, 32, 1, 1]).
size mismatch for keypoint_head.final_layer.bias: copying a param with shape torch.Size([17]) from checkpoint, the shape in current model is torch.Size([133]).
Successfully exported ONNX model: /home/trtuser/hrnet_w32_coco_256x192.onnx
It seems caused by the mismatch of the config and the checkpoint. Specifically, the config file is for coco-wholebody
data which contains 133 keypoints, while the checkpoint seems trained using coco data which contains 17 keypoints.