Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] 按照yolox_pose文档中的环境变量设置方式后进行模型转换存在错误 #2720

Closed
vicnoah opened this issue Sep 25, 2023 · 19 comments

Comments

@vicnoah
Copy link

vicnoah commented Sep 25, 2023

📚 The doc issue

执行命令

!export PYTHONPATH=/content/mmpose/projects/yolox_pose:$PYTHONPATH && echo $PYTHONPATH && cd /content/mmpose/projects/yolox_pose && python ../../../mmdeploy/tools/deploy.py \
../../../mmdeploy/configs/mmpose/pose-detection_yolox-pose_onnxruntime_dynamic.py \
configs/yolox-pose_m_4xb64-300e_coco.py \
../../../drive/MyDrive/yolox/yolox-pose_publish-cee405cd_20230925.pth ../../demo.jpg \
--work-dir ../../../drive/MyDrive/yolox/onnx --device cpu --dump-info

会出现错误提示

/content/mmpose/projects/yolox_pose:/env/python
Traceback (most recent call last):
  File "/content/mmpose/projects/yolox_pose/../../../mmdeploy/tools/deploy.py", line 335, in <module>
    main()
  File "/content/mmpose/projects/yolox_pose/../../../mmdeploy/tools/deploy.py", line 123, in main
    deploy_cfg, model_cfg = load_config(deploy_cfg_path, model_cfg_path)
  File "/usr/local/lib/python3.10/dist-packages/mmdeploy/utils/config_utils.py", line 29, in load_config
    configs = [_load_config(cfg) for cfg in args]
  File "/usr/local/lib/python3.10/dist-packages/mmdeploy/utils/config_utils.py", line 29, in <listcomp>
    configs = [_load_config(cfg) for cfg in args]
  File "/usr/local/lib/python3.10/dist-packages/mmdeploy/utils/config_utils.py", line 22, in _load_config
    cfg = mmengine.Config.fromfile(cfg)
  File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 461, in fromfile
    import_modules_from_strings(**cfg_dict['custom_imports'])
  File "/usr/local/lib/python3.10/dist-packages/mmengine/utils/misc.py", line 77, in import_modules_from_strings
    imported_tmp = import_module(imp)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/content/mmpose/projects/yolox_pose/models/__init__.py", line 5, in <module>
    from .yolox_pose_head import *  # noqa
  File "/content/mmpose/projects/yolox_pose/models/yolox_pose_head.py", line 13, in <module>
    from mmyolo.models.dense_heads import YOLOXHead, YOLOXHeadModule
  File "/usr/local/lib/python3.10/dist-packages/mmyolo/models/__init__.py", line 4, in <module>
    from .dense_heads import *  # noqa: F401,F403
  File "/usr/local/lib/python3.10/dist-packages/mmyolo/models/dense_heads/__init__.py", line 10, in <module>
    from .yolov7_head import YOLOv7Head, YOLOv7HeadModule, YOLOv7p6HeadModule
  File "/usr/local/lib/python3.10/dist-packages/mmyolo/models/dense_heads/yolov7_head.py", line 16, in <module>
    from ..task_modules.assigners.batch_yolov7_assigner import BatchYOLOv7Assigner
  File "/usr/local/lib/python3.10/dist-packages/mmyolo/models/task_modules/__init__.py", line 2, in <module>
    from .assigners import BatchATSSAssigner, BatchTaskAlignedAssigner
  File "/usr/local/lib/python3.10/dist-packages/mmyolo/models/task_modules/assigners/__init__.py", line 4, in <module>
    from .batch_task_aligned_assigner import BatchTaskAlignedAssigner
  File "/usr/local/lib/python3.10/dist-packages/mmyolo/models/task_modules/assigners/batch_task_aligned_assigner.py", line 9, in <module>
    from mmyolo.models.losses import bbox_overlaps
  File "/usr/local/lib/python3.10/dist-packages/mmyolo/models/losses/__init__.py", line 3, in <module>
    from .oks_loss import OksLoss
  File "/usr/local/lib/python3.10/dist-packages/mmyolo/models/losses/oks_loss.py", line 17, in <module>
    class OksLoss(nn.Module):
  File "/usr/local/lib/python3.10/dist-packages/mmengine/registry/registry.py", line 666, in _register
    self._register_module(module=module, module_name=name, force=force)
  File "/usr/local/lib/python3.10/dist-packages/mmengine/registry/registry.py", line 611, in _register_module
    raise KeyError(f'{name} is already registered in {self.name} '
KeyError: 'OksLoss is already registered in model at models.oks_loss'

Suggest a potential alternative/fix

No response

@Ben-Louis
Copy link
Collaborator

Projects 中的 YOLOX-Pose 目前只与 mmyolo 0.5.0 兼容 (https://github.com/open-mmlab/mmpose/tree/dev-1.x/projects/yolox_pose#prerequisites). 请先安装 mmyolo 0.5.0 来使用该项目

@vicnoah
Copy link
Author

vicnoah commented Sep 26, 2023

Projects 中的 YOLOX-Pose 目前只与 mmyolo 0.5.0 兼容 (https://github.com/open-mmlab/mmpose/tree/dev-1.x/projects/yolox_pose#prerequisites). 请先安装 mmyolo 0.5.0 来使用该项目

好的,我试试

@vicnoah
Copy link
Author

vicnoah commented Sep 26, 2023

Projects 中的 YOLOX-Pose 目前只与 mmyolo 0.5.0 兼容 (https://github.com/open-mmlab/mmpose/tree/dev-1.x/projects/yolox_pose#prerequisites). 请先安装 mmyolo 0.5.0 来使用该项目

使用0.5.0又存在其它的报错了。

/content/mmpose/projects/yolox-pose:/env/python
09/26 05:02:02 - mmengine - WARNING - Failed to search registry with scope "mmpose" in the "Codebases" registry tree. As a workaround, the current "Codebases" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmpose" is a correct scope, or whether the registry is initialized.
09/26 05:02:02 - mmengine - WARNING - Failed to search registry with scope "mmpose" in the "mmpose_tasks" registry tree. As a workaround, the current "mmpose_tasks" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmpose" is a correct scope, or whether the registry is initialized.
09/26 05:02:02 - mmengine - WARNING - Failed to search registry with scope "mmyolo" in the "Codebases" registry tree. As a workaround, the current "Codebases" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmyolo" is a correct scope, or whether the registry is initialized.
/usr/local/lib/python3.10/dist-packages/mmpose/utils/setup_env.py:79: UserWarning: The current default scope "mmyolo" is not "mmpose", `register_all_modules` will force the currentdefault scope to be "mmpose". If this is not expected, please set `init_default_scope=False`.
  warnings.warn('The current default scope '
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 106, in __getattr__
    value = super().__getattr__(name)
  File "/usr/local/lib/python3.10/dist-packages/addict/addict.py", line 67, in __getattr__
    return self.__getitem__(item)
  File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 135, in __getitem__
    return self.build_lazy(super().__getitem__(key))
  File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 102, in __missing__
    raise KeyError(name)
KeyError: 'codec'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/content/mmpose/projects/yolox-pose/../../../mmdeploy/tools/deploy.py", line 335, in <module>
    main()
  File "/content/mmpose/projects/yolox-pose/../../../mmdeploy/tools/deploy.py", line 129, in main
    export2SDK(
  File "/usr/local/lib/python3.10/dist-packages/mmdeploy/backend/sdk/export_info.py", line 353, in export2SDK
    pipeline_info = get_pipeline(deploy_cfg, model_cfg, work_dir, device)
  File "/usr/local/lib/python3.10/dist-packages/mmdeploy/backend/sdk/export_info.py", line 286, in get_pipeline
    preprocess = get_preprocess(deploy_cfg, model_cfg, device=device)
  File "/usr/local/lib/python3.10/dist-packages/mmdeploy/backend/sdk/export_info.py", line 197, in get_preprocess
    transforms = task_processor.get_preprocess()
  File "/usr/local/lib/python3.10/dist-packages/mmdeploy/codebase/mmpose/deploy/pose_detection.py", line 342, in get_preprocess
    model_cfg = process_model_config(self.model_cfg, [''], input_shape)
  File "/usr/local/lib/python3.10/dist-packages/mmdeploy/codebase/mmpose/deploy/pose_detection.py", line 39, in process_model_config
    codec = cfg.codec
  File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 1489, in __getattr__
    return getattr(self._cfg_dict, name)
  File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 110, in __getattr__
    raise AttributeError(f"'{self.__class__.__name__}' object has no "
AttributeError: 'ConfigDict' object has no attribute 'codec'

@Ben-Louis
Copy link
Collaborator

这个报错和 mmyolo 版本无关,应该是 mmdeploy 里面的实现有点问题。我们这两天看一下这个问题

@Ben-Louis
Copy link
Collaborator

请参考 这个 PR 修改 mmdeploy 的代码。这个 PR 中的代码兼容 MMPose dev-1.x 分支中的 YOLOX-Pose

@vicnoah
Copy link
Author

vicnoah commented Sep 27, 2023

请参考 这个 PR 修改 mmdeploy 的代码。这个 PR 中的代码兼容 MMPose dev-1.x 分支中的 YOLOX-Pose

好的,我试试

@vicnoah
Copy link
Author

vicnoah commented Sep 28, 2023

MPose dev-1.x 分支中的 YOLOX-Pose

我用dev-1.x分支的代码后还是存在此错误。

安装mmpose的方式:

git clone -b dev-1.x https://github.com/open-mmlab/mmpose.git
cd mmpose && pip install -r requirements.txt && pip install -v -e .

安装mmdeploy的方式:
1.安装mmdeploy

pip install mmdeploy==1.3.0
pip install mmdeploy-runtime==1.3.0
pip install onnxruntime==1.12.0
git clone -b v1.3.0 --recursive https://github.com/open-mmlab/mmdeploy.git

2.替换相关代码文件

mmdeploy/mmdeploy/codebase/mmpose/deploy/pose_detection.py
mmdeploy/mmdeploy/codebase/mmpose/deploy/pose_detection_model.py
mmdeploy/mmdeploy/codebase/mmpose/models/heads/yolox_pose_head.py

环境信息:

09/28 02:25:36 - mmengine - INFO - 

09/28 02:25:36 - mmengine - INFO - **********Environmental information**********
09/28 02:25:37 - mmengine - INFO - sys.platform: linux
09/28 02:25:37 - mmengine - INFO - Python: 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
09/28 02:25:37 - mmengine - INFO - CUDA available: False
09/28 02:25:37 - mmengine - INFO - numpy_random_seed: 2147483648
09/28 02:25:37 - mmengine - INFO - GCC: x86_64-linux-gnu-gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
09/28 02:25:37 - mmengine - INFO - PyTorch: 2.0.1+cu118
09/28 02:25:37 - mmengine - INFO - PyTorch compiling details: PyTorch built with:
  - GCC 9.3
  - C++ Version: 201703
  - Intel(R) oneAPI Math Kernel Library Version 2022.2-Product Build 20220804 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.7.3 (Git Hash 6dbeffbae1f23cbbeae17adb7b5b13f1f37c080e)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.8, CUDNN_VERSION=8.7.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -D_GLIBCXX_USE_CXX11_ABI=0 -fabi-version=11 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wunused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_DISABLE_GPU_ASSERTS=ON, TORCH_VERSION=2.0.1, USE_CUDA=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=1, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, 

09/28 02:25:37 - mmengine - INFO - TorchVision: 0.15.2+cu118
09/28 02:25:37 - mmengine - INFO - OpenCV: 4.8.0
09/28 02:25:37 - mmengine - INFO - MMEngine: 0.8.3
09/28 02:25:37 - mmengine - INFO - MMCV: 2.0.1
09/28 02:25:37 - mmengine - INFO - MMCV Compiler: GCC 9.3
09/28 02:25:37 - mmengine - INFO - MMCV CUDA Compiler: 11.8
09/28 02:25:37 - mmengine - INFO - MMDeploy: 1.3.0+1132e82
09/28 02:25:37 - mmengine - INFO - 

09/28 02:25:37 - mmengine - INFO - **********Backend information**********
09/28 02:25:37 - mmengine - INFO - tensorrt:	None
09/28 02:25:37 - mmengine - INFO - ONNXRuntime:	1.12.0
09/28 02:25:37 - mmengine - INFO - ONNXRuntime-gpu:	None
09/28 02:25:37 - mmengine - INFO - ONNXRuntime custom ops:	Available
09/28 02:25:37 - mmengine - INFO - pplnn:	None
09/28 02:25:37 - mmengine - INFO - ncnn:	None
09/28 02:25:37 - mmengine - INFO - snpe:	None
09/28 02:25:37 - mmengine - INFO - openvino:	None
09/28 02:25:37 - mmengine - INFO - torchscript:	2.0.1+cu118
09/28 02:25:37 - mmengine - INFO - torchscript custom ops:	NotAvailable
09/28 02:25:37 - mmengine - INFO - rknn-toolkit:	None
09/28 02:25:37 - mmengine - INFO - rknn-toolkit2:	None
09/28 02:25:37 - mmengine - INFO - ascend:	None
09/28 02:25:37 - mmengine - INFO - coreml:	None
09/28 02:25:37 - mmengine - INFO - tvm:	None
09/28 02:25:37 - mmengine - INFO - vacc:	None
09/28 02:25:37 - mmengine - INFO - 

09/28 02:25:37 - mmengine - INFO - **********Codebase information**********
09/28 02:25:37 - mmengine - INFO - mmdet:	3.0.0rc6
09/28 02:25:37 - mmengine - INFO - mmseg:	None
09/28 02:25:37 - mmengine - INFO - mmpretrain:	None
09/28 02:25:37 - mmengine - INFO - mmocr:	None
09/28 02:25:37 - mmengine - INFO - mmagic:	None
09/28 02:25:37 - mmengine - INFO - mmdet3d:	None
09/28 02:25:37 - mmengine - INFO - mmpose:	1.1.0
09/28 02:25:37 - mmengine - INFO - mmrotate:	None
09/28 02:25:37 - mmengine - INFO - mmaction:	None
09/28 02:25:37 - mmengine - INFO - mmrazor:	None
09/28 02:25:37 - mmengine - INFO - mmyolo:	0.5.0

@Ben-Louis
Copy link
Collaborator

Ben-Louis commented Sep 28, 2023

请问您部署 YOLOX-Pose 的时候使用的命令是哪条呢?我这边尝试

python tools/deploy.py configs/mmpose/pose-detection_yolox-pose_onnxruntime_dynamic.py ../mmpose/configs/body_2d_keypoint/yoloxpose/coco/yoloxpose_s_8xb32-300e_coco-640.py ../mmpose/ckpts/yoloxpose_s_8xb32-300e_coco-640-56c79c1f_20230829.pth ../mmpose/tests/data/coco/000000197388.jpg --work-dir logs/yoloxpose/s/onnx --test-img ../mmpose/tests/data/coco/000000197388.jpg --device cuda:0 --show --dump-info

是可以跑通部署的

@vicnoah
Copy link
Author

vicnoah commented Sep 28, 2023

请问您部署 YOLOX-Pose 的时候使用的命令是哪条呢?我这边尝试

python tools/deploy.py configs/mmpose/pose-detection_yolox-pose_onnxruntime_dynamic.py ../mmpose/configs/body_2d_keypoint/yoloxpose/coco/yoloxpose_s_8xb32-300e_coco-640.py ../mmpose/ckpts/yoloxpose_s_8xb32-300e_coco-640-56c79c1f_20230829.pth ../mmpose/tests/data/coco/000000197388.jpg --work-dir logs/yoloxpose/s/onnx --test-img ../mmpose/tests/data/coco/000000197388.jpg --device cuda:0 --show --dump-info

是可以跑通部署的

我是在谷歌colab环境下跑的,这是代码。

!export PYTHONPATH=/content/mmpose/projects/yolox_pose:$PYTHONPATH && echo $PYTHONPATH && cd /content/mmpose/projects/yolox_pose && python ../../../mmdeploy/tools/deploy.py \
../../../mmdeploy/configs/mmpose/pose-detection_yolox-pose_onnxruntime_dynamic.py \
configs/yolox-pose_m_4xb64-300e_coco.py \
../../../drive/MyDrive/yolox/yolox-pose_publish-cee405cd_20230925.pth ../../demo.jpg \
--work-dir ../../../drive/MyDrive/yolox/onnx --device cpu --dump-info

@Ben-Louis
Copy link
Collaborator

projects 里面的 YOLOX-Pose (mmpose/projects/yolox_pose) 后面应该不会继续维护了。建议使用 主库中的 YOLOX-Pose,兼容性和性能都会更好一点。前面提到的 mmdeploy 的 PR 也是适配主库中的 YOLOX-Pose

@vicnoah
Copy link
Author

vicnoah commented Sep 28, 2023

projects 里面的 YOLOX-Pose (mmpose/projects/yolox_pose) 后面应该不会继续维护了。建议使用 主库中的 YOLOX-Pose,兼容性和性能都会更好一点。前面提到的 mmdeploy 的 PR 也是适配主库中的 YOLOX-Pose

那不再需要设置PYTHONPATH了吗?我这个命令是正确的吗?新的代码弄进去还是在报错。

命令

!cd mmpose && python ../mmdeploy/tools/deploy.py \
../mmdeploy/configs/mmpose/pose-detection_yolox-pose_onnxruntime_dynamic.py \
configs/body_2d_keypoint/yoloxpose/coco/yoloxpose_tiny_4xb64-300e_coco-416.py \
../drive/MyDrive/yolox/yolox-pose_publish-cee405cd_20230925.pth demo.jpg \
--work-dir ../drive/MyDrive/yolox/onnx --device cpu --dump-info
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 107, in __getattr__
    value = super().__getattr__(name)
  File "/usr/local/lib/python3.10/dist-packages/addict/addict.py", line 67, in __getattr__
    return self.__getitem__(item)
  File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 136, in __getitem__
    return self.build_lazy(super().__getitem__(key))
  File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 103, in __missing__
    raise KeyError(name)
KeyError: 'bgr_to_rgb'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/content/mmpose/../mmdeploy/tools/deploy.py", line 335, in <module>
    main()
  File "/content/mmpose/../mmdeploy/tools/deploy.py", line 129, in main
    export2SDK(
  File "/usr/local/lib/python3.10/dist-packages/mmdeploy/backend/sdk/export_info.py", line 353, in export2SDK
    pipeline_info = get_pipeline(deploy_cfg, model_cfg, work_dir, device)
  File "/usr/local/lib/python3.10/dist-packages/mmdeploy/backend/sdk/export_info.py", line 286, in get_pipeline
    preprocess = get_preprocess(deploy_cfg, model_cfg, device=device)
  File "/usr/local/lib/python3.10/dist-packages/mmdeploy/backend/sdk/export_info.py", line 197, in get_preprocess
    transforms = task_processor.get_preprocess()
  File "/usr/local/lib/python3.10/dist-packages/mmdeploy/codebase/mmpose/deploy/pose_detection.py", line 342, in get_preprocess
    model_cfg = process_model_config(self.model_cfg, [''], input_shape)
  File "/usr/local/lib/python3.10/dist-packages/mmdeploy/codebase/mmpose/deploy/pose_detection.py", line 62, in process_model_config
    to_rgb=data_preprocessor.bgr_to_rgb))
  File "/usr/local/lib/python3.10/dist-packages/mmengine/config/config.py", line 111, in __getattr__
    raise AttributeError(f"'{self.__class__.__name__}' object has no "
AttributeError: 'ConfigDict' object has no attribute 'bgr_to_rgb'

@Ben-Louis
Copy link
Collaborator

Ben-Louis commented Sep 28, 2023

根据报错信息

File "/usr/local/lib/python3.10/dist-packages/mmdeploy/codebase/mmpose/deploy/pose_detection.py", line 62, in process_model_config
to_rgb=data_preprocessor.bgr_to_rgb))

您现在使用的 mmdeploy 是用 pip 安装的预编译包,所以您修改的 mmdeploy 代码不会产生效果。您在改完 mmdeploy 的代码后需要执行一下 pip install -e /content/mmdeploy

@vicnoah
Copy link
Author

vicnoah commented Sep 28, 2023

根据报错信息

File "/usr/local/lib/python3.10/dist-packages/mmdeploy/codebase/mmpose/deploy/pose_detection.py", line 62, in process_model_config
to_rgb=data_preprocessor.bgr_to_rgb))

您现在使用的 mmdeploy 是用 pip 安装的预编译包,所以您修改的 mmdeploy 代码不会产生效果。您在改完 mmdeploy 的代码后需要执行一下 pip install -e /content/mmdeploy

非常感谢,问题已经解决了。

@vicnoah vicnoah closed this as completed Sep 28, 2023
@wenkaiH
Copy link

wenkaiH commented Oct 16, 2023

mmdeploy/mmdeploy/codebase/mmpose/deploy/pose_detection.py
mmdeploy/mmdeploy/codebase/mmpose/deploy/pose_detection_model.py
mmdeploy/mmdeploy/codebase/mmpose/models/heads/yolox_pose_head.py

根据报错信息

File "/usr/local/lib/python3.10/dist-packages/mmdeploy/codebase/mmpose/deploy/pose_detection.py", line 62, in process_model_config
to_rgb=data_preprocessor.bgr_to_rgb))

您现在使用的 mmdeploy 是用 pip 安装的预编译包,所以您修改的 mmdeploy 代码不会产生效果。您在改完 mmdeploy 的代码后需要执行一下 pip install -e /content/mmdeploy

同样的问题,按上述办法更改mmdeploy的三个文件,重新pip install -e ,但执行命令后出现如下问题:

python tools/deploy.py configs/mmpose/pose-detection_yolox-pose_onnxruntime_dynamic.py ../mmpose/configs/body_2d_keypoint/yoloxpose/coco/yoloxpose_m_8xb32-300e_coco-640.py https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/yolox_pose/yoloxpose_m_8xb32-300e_coco-640-84e9a538_20230829.pth demo/resources/human-pose.jpg --work-dir mmdeploy-model/yoloxpose-ort --device cpu --show --dump-info

10/16 16:49:28 - mmengine - WARNING - Failed to search registry with scope "mmpose" in the "Codebases" registry tree. As a workaround, the current "Codebases" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmpose" is a correct scope, or whether the registry is initialized.
10/16 16:49:28 - mmengine - WARNING - Failed to search registry with scope "mmpose" in the "mmpose_tasks" registry tree. As a workaround, the current "mmpose_tasks" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmpose" is a correct scope, or whether the registry is initialized.
10/16 16:49:30 - mmengine - INFO - Start pipeline mmdeploy.apis.pytorch2onnx.torch2onnx in subprocess
10/16 16:49:31 - mmengine - WARNING - Failed to search registry with scope "mmpose" in the "Codebases" registry tree. As a workaround, the current "Codebases" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmpose" is a correct scope, or whether the registry is initialized.
10/16 16:49:31 - mmengine - WARNING - Failed to search registry with scope "mmpose" in the "mmpose_tasks" registry tree. As a workaround, the current "mmpose_tasks" registry in "mmdeploy" is used to build instance. This may cause unexpected failure when running the built modules. Please check whether "mmpose" is a correct scope, or whether the registry is initialized.
Process Process-2:
Traceback (most recent call last):
File "/home/ccnu-train/anaconda3/envs/mmdeploy/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/home/ccnu-train/anaconda3/envs/mmdeploy/lib/python3.8/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/home/ccnu-train/hwk/mmdeploy/mmdeploy/apis/core/pipeline_manager.py", line 107, in call
ret = func(*args, **kwargs)
File "/home/ccnu-train/hwk/mmdeploy/mmdeploy/apis/pytorch2onnx.py", line 63, in torch2onnx
torch_model = task_processor.build_pytorch_model(model_checkpoint)
File "/home/ccnu-train/hwk/mmdeploy/mmdeploy/codebase/base/task.py", line 120, in build_pytorch_model
model = MODELS.build(model)
File "/home/ccnu-train/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmengine/registry/registry.py", line 570, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/home/ccnu-train/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 232, in build_model_from_cfg
return build_from_cfg(cfg, registry, default_args)
File "/home/ccnu-train/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
obj = obj_cls(**args) # type: ignore
File "/home/ccnu-train/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmpose/models/pose_estimators/bottomup.py", line 41, in init
super().init(
File "/home/ccnu-train/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmpose/models/pose_estimators/base.py", line 43, in init
super().init(
File "/home/ccnu-train/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmengine/model/base_model/base_model.py", line 78, in init
self.data_preprocessor = MODELS.build(data_preprocessor)
File "/home/ccnu-train/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmengine/registry/registry.py", line 570, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/home/ccnu-train/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 232, in build_model_from_cfg
return build_from_cfg(cfg, registry, default_args)
File "/home/ccnu-train/anaconda3/envs/mmdeploy/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 121, in build_from_cfg
obj = obj_cls(**args) # type: ignore
TypeError: init() got an unexpected keyword argument 'batch_augments'
10/16 16:49:32 - mmengine - ERROR - /home/ccnu-train/hwk/mmdeploy/mmdeploy/apis/core/pipeline_manager.py - pop_mp_output - 80 - mmdeploy.apis.pytorch2onnx.torch2onnx with Call id: 0 failed. exit.

@Ben-Louis
Copy link
Collaborator

@wenkaiH,您好,请问您安装的 mm 系列库都是什么版本的呢?

@wenkaiH
Copy link

wenkaiH commented Oct 16, 2023

@wenkaiH,您好,请问您安装的 mm 系列库都是什么版本的呢?

mmcv 2.0.1 pypi_0 pypi
mmdeploy 1.3.0 dev_0
mmdeploy-runtime-gpu 1.3.0 pypi_0 pypi
mmdet 3.0.0 pypi_0 pypi
mmengine 0.8.4 pypi_0 pypi
mmpose 1.1.0 pypi_0 pypi
mmyolo 0.5.0 pypi_0 pypi

@Ben-Louis
Copy link
Collaborator

您安装的 mmpose 1.1.0 正式版里面还没有这个 YOLOX-Pose。可以试下在您的 mmpose 文件夹里执行一下 pip install -e . 或者将 mmpose 升级到 1.2.0

@wenkaiH
Copy link

wenkaiH commented Oct 16, 2023

您安装的 mmpose 1.1.0 正式版里面还没有这个 YOLOX-Pose。可以试下在您的 mmpose 文件夹里执行一下 pip install -e . 或者将 mmpose 升级到 1.2.0

尝试了pip install -e . 成功解决啦!非常感谢!!!

@wenkaiH
Copy link

wenkaiH commented Oct 16, 2023

您安装的 mmpose 1.1.0 正式版里面还没有这个 YOLOX-Pose。可以试下在您的 mmpose 文件夹里执行一下 pip install -e . 或者将 mmpose 升级到 1.2.0

接一个问题哈,部署成功后 API推理是没问题的,但 SDK推理会在加载pipeline报一些参数错:

loading libmmdeploy_trt_net.so ... failed to load library libmmdeploy_trt_net.so loading libmmdeploy_ort_net.so ... [2023-10-16 19:07:59.107] [mmdeploy] [info] [model.cpp:35] [DirectoryModel] Load model: "mmdeploy-model/yoloxpose-ort/" [2023-10-16 19:07:59.393] [mmdeploy] [error] [compose.cpp:37] Unable to find Transform creator: BottomupResize. Available transforms: [("CenterCrop", 0), ("Collect", 0), ("Compose", 0), ("DefaultFormatBundle", 0), ("FormatShape", 0), ("ImageToTensor", 0), ("LetterResize", 0), ("Lift", 0), ("LoadImageFromFile", 0), ("Normalize", 0), ("Pad", 0), ("RescaleToHeight", 0), ("Resize", 0), ("ResizeOCR", 0), ("ShortScaleAspectJitter", 0), ("TenCrop", 0), ("ThreeCrop", 0), ("TopDownAffine", 0), ("TopDownGetBboxCenterScale", 0)] [2023-10-16 19:07:59.393] [mmdeploy] [error] [task.cpp:99] error parsing config: { "context": { "device": "", "model": "", "stream": "" }, "input": [ "img" ], "module": "Transform", "name": "Preprocess", "output": [ "prep_output" ], "transforms": [ { "type": "LoadImageFromFile" }, { "input_size": [ 640, 640 ], "pad_val": [ 114, 114, 114 ], "type": "BottomupResize" }, { "mean": [ 0, 0, 0 ], "std": [ 1, 1, 1 ], "to_rgb": false, "type": "Normalize" }, { "keys": [ "img" ], "type": "ImageToTensor" }, { "keys": [ "img" ], "meta_keys": [ "img_shape", "pad_shape", "ori_shape", "img_norm_cfg", "scale_factor", "bbox_score", "center", "scale" ], "type": "Collect" } ], "type": "Task" } [2023-10-16 19:07:59.977] [mmdeploy] [error] [common.h:50] Could not found entry 'UNKNOWN' in mmpose. Available components: [("DeepposeRegressionHeadDecode", 0), ("SimCCLabelDecode", 0), ("TopdownHeatmapBaseHeadDecode", 0), ("TopdownHeatmapMSMUHeadDecode", 0), ("TopdownHeatmapMultiStageHeadDecode", 0), ("TopdownHeatmapSimpleHeadDecode", 0), ("ViPNASHeatmapSimpleHeadDecode", 0)] [2023-10-16 19:07:59.977] [mmdeploy] [error] [task.cpp:99] error parsing config: { "component": "UNKNOWN", "context": { "device": "", "model": "", "stream": "" }, "input": [ "prep_output", "infer_output" ], "module": "mmpose", "name": "postprocess", "output": [ "post_output" ], "params": { "flip_test": false, "input_size": [ 640, 640 ], "nms_thr": 0.65, "score_thr": 0.5, "type": "YOLOXPoseAnnotationProcessor" }, "type": "Task" } 段错误 (核心已转储)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants