open-mmlab / mmpose

OpenMMLab Pose Estimation Toolbox and Benchmark.
https://mmpose.readthedocs.io/en/latest/
Apache License 2.0
5.92k stars 1.26k forks source link

[bug] 无法转换rtmw-x的模型 #2785

Closed shekmun closed 1 year ago

shekmun commented 1 year ago

Prerequisite

Environment

pytorch:1.8.1+cu111 openmim:0.3.9 mmengine:0.9.0 mmcv:2.1.0 mmdeploy:1.3.0 mmpose:1.2.0 onnxruntime:1.8.1

Reproduces the problem - code sample

python tools/deploy.py configs/mmpose/pose-detection_simcc_onnxruntime_dynamic.py ../mmpose/projects/rtmpose/rtmpose/wholebody_2d_keypoint/rtmw-x_8xb320-270e_cocktail13-384x288.py rtmw-x_simcc-cocktail13_pt-ucoco_270e-384x288-0949e3a9_20230925.pth demo/resources/human-pose.jpg --work-dir model/rtmw-x --device cuda:0 --show --dump-info

Reproduces the problem - command or script

python tools/deploy.py configs/mmpose/pose-detection_simcc_onnxruntime_dynamic.py ../mmpose/projects/rtmpose/rtmpose/wholebody_2d_keypoint/rtmw-x_8xb320-270e_cocktail13-384x288.py rtmw-x_simcc-cocktail13_pt-ucoco_270e-384x288-0949e3a9_20230925.pth demo/resources/human-pose.jpg --work-dir model/rtmw-x --device cuda:0 --show --dump-info

Reproduces the problem - error message

错误1、 Traceback (most recent call last): File "tools/deploy.py", line 338, in main() File "tools/deploy.py", line 123, in main deploy_cfg, model_cfg = load_config(deploy_cfg_path, model_cfg_path) File "/opt/pyenv/versions/pytorch-1.8.1/lib/python3.8/site-packages/mmdeploy/utils/config_utils.py", line 29, in load_config configs = [_load_config(cfg) for cfg in args] File "/opt/pyenv/versions/pytorch-1.8.1/lib/python3.8/site-packages/mmdeploy/utils/config_utils.py", line 29, in configs = [_load_config(cfg) for cfg in args] File "/opt/pyenv/versions/pytorch-1.8.1/lib/python3.8/site-packages/mmdeploy/utils/config_utils.py", line 22, in _load_config cfg = mmengine.Config.fromfile(cfg) File "/opt/pyenv/versions/pytorch-1.8.1/lib/python3.8/site-packages/mmengine/config/config.py", line 490, in fromfile raise e File "/opt/pyenv/versions/pytorch-1.8.1/lib/python3.8/site-packages/mmengine/config/config.py", line 488, in fromfile cfg_dict, imported_names = Config._parse_lazy_import(filename) File "/opt/pyenv/versions/pytorch-1.8.1/lib/python3.8/site-packages/mmengine/config/config.py", line 1068, in _parse_lazy_import raise ConfigParsingError( mmengine.config.utils.ConfigParsingError: /opt/pyenv/versions/3.8.2/envs/pytorch-1.8.1/lib/python3.8/site-packages/mmpose/configs/base/default_runtime.py not found! It means that incorrect module is defined in with read_base(): = from mmpose.configs._base_.default_runtime import ..., please make sure the base config module is valid and is consistent with the prior import logic

错误2、 Traceback (most recent call last): File "tools/deploy.py", line 338, in main() File "tools/deploy.py", line 129, in main export2SDK( File "/opt/pyenv/versions/pytorch-1.8.1/lib/python3.8/site-packages/mmdeploy/backend/sdk/export_info.py", line 352, in export2SDK deploy_info = get_deploy(deploy_cfg, model_cfg, work_dir, device) File "/opt/pyenv/versions/pytorch-1.8.1/lib/python3.8/site-packages/mmdeploy/backend/sdk/export_info.py", line 267, in getdeploy , customs = get_model_name_customs( File "/opt/pyenv/versions/pytorch-1.8.1/lib/python3.8/site-packages/mmdeploy/backend/sdk/export_info.py", line 61, in get_model_name_customs task_processor = build_task_processor( File "/opt/pyenv/versions/pytorch-1.8.1/lib/python3.8/site-packages/mmdeploy/apis/utils/utils.py", line 44, in build_task_processor codebase_type = get_codebase(deploy_cfg, model_cfg=model_cfg) File "/opt/pyenv/versions/pytorch-1.8.1/lib/python3.8/site-packages/mmdeploy/utils/config_utils.py", line 100, in get_codebase or model_cfg['type'].startswith('mmrazor.'): AttributeError: type object 'TopdownPoseEstimator' has no attribute 'startswith'

Additional information

1、通过mim(mim install mmpose)或者源码安装(python -m pip install .)的mmpose的目录(python3.8/site-packages/mmpose*)下面都没有configs这个文件夹,但是运行python tools/deploy.py会提示没有python3.8/site-packages/mmpose/configs/base/default_runtime.py这个文件,所以只能从源码中手动拷贝一个configs目录到python的安装目录 2、然后错误就变成另外一个错误AttributeError: type object 'TopdownPoseEstimator' has no attribute 'startswith' 3、已经尝试了通过mim安装mmengine、mmdeploy、mmpose或线上最新的代码安装,都会出现这个问题,而且只有转换rtmw-x这个模型的时候报错,其他的hrnet、faster_rcnn、rtmpose-m、rtmpose-x都可以正常运行

Ben-Louis commented 1 year ago

您好,这个问题是由 rtmw 之前采用的新版 config 与 mmdeploy 之间的不兼容引起的。我们目前在 dev-1.x 分支中修复了这个问题。您可以先使用 dev-1.x 分支中的 rtmw config

shekmun commented 1 year ago

可以了,感谢