Closed Haroldhy closed 1 year ago
detection_tensorrt_static-320x320.py 这个文件是你从 mmdeploy/configs 文件夹拷贝到的吧。不建议你拷贝,因为他依赖一些其他的 config,没拷贝全的话会破坏目录结构
https://mmdetection.readthedocs.io/zh_CN/latest/user_guides/config.html#id9
感谢回复!但我遇到了一个新的报错。 我把convert_rtmdet.py放到了mmdeploy文件夹目录下,并且运行python .\convert_rtmdet.py --config .\configs\mmdet\detection\detection_onnxruntime_dynamic.py --checkpoint .\weights\rtmdet_nano_8xb32-100e_coco-obj365-person-05d8511e.pth --output ..\mmpose\projects\rtmpose\examples\RTMPose-Deploy\Windows\TensorRT\python\rtmdet\,得到报错: Traceback (most recent call last): File "E:\anaconda3\envs\mmpose\lib\site-packages\mmengine\config\config.py", line 106, in getattr value = super().getattr(name) File "E:\anaconda3\envs\mmpose\lib\site-packages\addict\addict.py", line 67, in getattr return self.getitem(item) File "E:\anaconda3\envs\mmpose\lib\site-packages\mmengine\config\config.py", line 135, in getitem return self.build_lazy(super().getitem(key)) File "E:\anaconda3\envs\mmpose\lib\site-packages\mmengine\config\config.py", line 102, in missing raise KeyError(name) KeyError: 'model'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".\convert_rtmdet.py", line 104, in
我看了一下,这个项目是脱离mmdeploy使用的。
https://github.com/Dominic23331/rtmpose_tensorrt
model cfg 指的应该是 pytorch 那边的 config
不好意思,我不大能理解“pytorch 那边的 config”是什么意思?能不能帮我举个例子呀?谢谢!
不好意思,我不大能理解“pytorch 那边的 config”是什么意思?能不能帮我举个例子呀?谢谢!
就是说这个模型(ckpt)是用哪个config训练出来的。
比如这里 https://github.com/open-mmlab/mmpose/blob/main/configs/body_2d_keypoint/rtmpose/coco/rtmpose_coco.md
你说的没错!十分感谢!我已经将cfg修改为了mmpose\projects\rtmpose\rtmdet\person/rtmdet_nano_320-8xb32_coco-person.py。但是我运行的时候还是出现了新的bug,想再请教下一下!报错信息如下所示:
(mmpose) PS E:\hy\algorithm\workspace\mmdeploy> python .\convert_rtmdet.py --config ..\mmpose\projects\rtmpose\rtmdet\person\rtmdet_nano_320-8xb32_coco-person.py --checkpoint .\weights\rtmdet_nano_8xb32-100e_coco-obj365-person-05d8511e.pth --output ..\mmpose\projects\rtmpose\examples\RTMPose-Deploy\Windows\TensorRT\python\rtmdet\
Loads checkpoint by local backend from path: .\weights\rtmdet_nano_8xb32-100e_coco-obj365-person-05d8511e.pth
E:\anaconda3\envs\mmpose\lib\site-packages\torch\nn\functional.py:1709: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.
warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")
Traceback (most recent call last):
File ".\convert_rtmdet.py", line 109, in
但是我并没有在config文件中看到hardsigmoid是在哪里定义的,想请教一下我在哪里找到定义这层的定义呢?或者说您有什么解决方法的建议吗?
可能是pytorch或者mmdet版本跟他们用的不一样,建议去 https://github.com/open-mmlab/mmpose/issues 提个issue问下吧
也可以尝试按照这个修改一下: https://github.com/pytorch/vision/issues/3463 https://blog.csdn.net/jacke121/article/details/125358683
我觉得应该就是你列出来的两个文章里的问题,但是我没有找到这个hardsigmoid层是在哪里定义的。无论如何非常感谢!
你如果熟悉mm系列的话,应该知道模型是根据config来创建的,那么你看config中各个模型是不是用到了这个函数。
简单搜了一下mmdet是有两处,channel_attention应该是一处,另一处你可以看看用没用到。
谢谢,我通过直接修改torch的nn.Hardsigmoid()解决了!然后我又遇到了和之前很类似的错误,具体信息如下:
(mmpose) PS E:\hy\algorithm\workspace\mmdeploy> python .\convert_rtmdet.py --config ..\mmpose\projects\rtmpose\rtmdet\person\rtmdet_nano_320-8xb32_coco-person.py --checkpoint .\weights\rtmdet_nano_8xb32-100e_coco-obj365-person-05d8511e.pth --output ..\mmpose\projects\rtmpose\examples\RTMPose-Deploy\Windows\TensorRT\python\rtmdet\
Loads checkpoint by local backend from path: .\weights\rtmdet_nano_8xb32-100e_coco-obj365-person-05d8511e.pth
E:\anaconda3\envs\mmpose\lib\site-packages\torch\nn\functional.py:1709: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.
warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.")
Traceback (most recent call last):
File ".\convert_rtmdet.py", line 108, in
output 应该是个文件路径吧,你给的文件夹的。
我觉得这个你完全可以自己debug解决的。报错很明显了。
File ".\convert_rtmdet.py", line 108, in
torch.onnx.export(
不好意思,我刚刚自己检查也发现了。已经解决好啦
Checklist
Describe the bug
error:Traceback (most recent call last): File ".\convert_rtmdet.py", line 104, in
model = build_model_from_cfg(args.config, args.checkpoint, args.device)
File ".\convert_rtmdet.py", line 10, in build_model_from_cfg
model = init_detector(config_path, checkpoint_path, device=device)
File "E:\anaconda3\envs\mmpose\lib\site-packages\mmdet\apis\inference.py", line 53, in init_detector
config = Config.fromfile(config)
File "E:\anaconda3\envs\mmpose\lib\site-packages\mmengine\config\config.py", line 456, in fromfile
cfg_dict, cfg_text, env_variables = Config._file2dict(
File "E:\anaconda3\envs\mmpose\lib\site-packages\mmengine\config\config.py", line 940, in _file2dict
raise e
File "E:\anaconda3\envs\mmpose\lib\site-packages\mmengine\config\config.py", line 882, in _file2dict
_cfg_dict, _cfg_text, _env_variables = Config._file2dict(
File "E:\anaconda3\envs\mmpose\lib\site-packages\mmengine\config\config.py", line 838, in _file2dict
if lazy_import is None and Config._is_lazy_import(filename):
File "E:\anaconda3\envs\mmpose\lib\site-packages\mmengine\config\config.py", line 1651, in _is_lazy_import
with open(filename, encoding='utf-8') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'E:\hy\algorithm\workspace\mmpose\projects\rtmpose\examples\RTMPose-Deploy\Windows\TensorRT\python\config\../base/base_static.py'
Reproduction
My Code :E:\hy\algorithm\workspace\mmpose\projects\rtmpose\examples\RTMPose-Deploy\Windows\TensorRT\python> python .\convert_rtmdet.py --config .\config\detection_tensorrt_static-320x320.py --checkpoint .\checkpoint\rtmdet_nano_8xb32-100e_coco-obj365-person-05d8511e.pth --output .\rtmdet\
Environment
Error traceback
No response