Skip to content
New issue

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

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

Already on GitHub? # to your account

复现demo出现ModuleNotFoundError: No module named 'mmcv._ext' #56

Closed
LUO77123 opened this issue Mar 2, 2022 · 5 comments
Closed

Comments

@LUO77123
Copy link

LUO77123 commented Mar 2, 2022

我的版本
Python 3.9.7
mmcv 1.4.6
mmdet 2.22.0
mmrotate 0.1.0
torch 1.7.1+cu110
torchaudio 0.7.2
torchvision 0.8.2+cu110
nvcc -V显示 Cuda compilation tools, release 11.0, V11.0.194
nvidia-smi 显示 CUDA Version: 11.1

通过 1.pip install openmim 2.mim install mmrotate 命令,顺利安装成功。
创建checkpoint文件夹存放预训练模型,
测试命令 python demo/image_demo.py demo/demo.jpg configs/oriented_rcnn/oriented_rcnn_r50_fpn_1x_dota_le90.py checkpoint/oriented_rcnn_r50_fpn_1x_dota_le90-6d2b2ce0.pth demo/vis.jpg device 6

报错
Traceback (most recent call last):
File "/home/C/LUOLIE/mmrotate-main/demo/image_demo.py", line 14, in
from mmdet.apis import inference_detector, init_detector
File "/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.9/site-packages/mmdet/apis/init.py", line 2, in
from .inference import (async_inference_detector, inference_detector,
File "/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.9/site-packages/mmdet/apis/inference.py", line 7, in
from mmcv.ops import RoIPool
File "/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.9/site-packages/mmcv/ops/init.py", line 2, in
from .active_rotated_filter import active_rotated_filter
File "/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.9/site-packages/mmcv/ops/active_rotated_filter.py", line 8, in
ext_module = ext_loader.load_ext(
File "/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.9/site-packages/mmcv/utils/ext_loader.py", line 13, in load_ext
ext = importlib.import_module('mmcv.' + name)
File "/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'mmcv._ext'

不知道问题出在哪里,请大佬指导一下

@Soul-Code
Copy link

同样的问题

@LUO77123
Copy link
Author

LUO77123 commented Mar 2, 2022 via email

@yangxue0827
Copy link
Collaborator

@LUO77123
Copy link
Author

LUO77123 commented Mar 2, 2022

参考https://github.com/open-mmlab/mmrotate/blob/main/docs/en/faq.md

感谢大佬帮助,解决了mmcv版本匹配问题,demo运行出现新的
我的版本问题
Python 3.8.12
mmcv 1.4.6
mmcv-full 1.4.6
mmdet 2.22.0
mmrotate 0.1.0
torch 1.7.0+cu110
torchaudio 0.7.0
torchvision 0.8。 1+cu110
nvcc -V Cuda显示编译工具,发布11.0,V11.0.194
nvidia -smi CUDA 版本:11.1
问题:
raise ModuleAttributeError("'{}' object has no attribute '{}'".format(
torch.nn. modules.module.ModuleAttributeError:“RoIAlignRotated”对象没有属性“out_size”

是全部内容
/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.8/site-packages/mmdet/models/dense_heads/anchor_head.py:116: UserWarning: DeprecationWarning: num_anchorsis deprecated, 为了一致性或者也num_base_priors使用
warnings.warn('DeprecationWarning: num_anchorsis deprecated, '
load checkpoint from local path: checkpoint/
orient_rcnn_r50_fpn_1x_dota_le90-6d2b2ce0.pth /home/zhuyu/anaconda3/envs/mmmlab/lib/python3.8/site-packages/mmdet/models/dense_heads /anchor_head.py:123: UserWarning: DeprecationWarning: anchor_generator is deprecated, please use " prior_generator
" instead第 42 行,在

main()
文件“demo/image_demo.py”,第 35 行,主要
结果 = inference_detector(model, args.img)
文件“/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.8/site-packages/ mmdet/apis/inference.py”,第 150 行,inference_detector
results = model(return_loss=False, rescale=True, **data)
文件“/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.8/site -packages/torch/nn/modules/module.py”,第 727 行,在 _call_impl
结果 = self.forward(*input, **kwargs)
文件“/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.8 /site-packages/mmcv/runner/fp16_utils.py”,第 109 行,在 new_func
返回 old_func(*args, **kwargs)
文件“/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.8/site-包/mmdet/models/detectors/base.py”,第 174 行,在前进
返回 self.forward_test(img, img_metas, **kwargs)
文件“/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.8/site-packages/mmdet/models/detectors/base.py”,第 147 行,在 forward_test
返回 self.simple_test(imgs[0], img_metas[0], **kwargs)
文件“/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.8/site-packages/mmrotate/models/detectors/ two_stage.py”,第 183 行,在 simple_test
返回 self.roi_head.simple_test(
文件“/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.8/site-packages/mmrotate/models/roi_heads/rotate_standard_roi_head.py” ,第 252 行,在 simple_test
det_bboxes 中,det_labels = self.simple_test_bboxes(
文件“/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.8/site-packages/mmrotate/models/roi_heads/orientation_standard_roi_head.py”,第 134 行,在 simple_test_bboxes
bbox_results = self._bbox_forward(x, rois)
文件中“/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.8/site-packages/mmrotate/models/roi_heads/rotate_standard_roi_head.py”,第169行,在_bbox_forward
bbox_feats = self.bbox_roi_extractor(
文件“/home/zhuyu /anaconda3/envs/mmmlab/lib/python3.8/site-packages/torch/nn/modules/module.py”,第 727 行,在 _call_impl
结果 = self.forward(*input, **kwargs)
文件“/home /zhuyu/anaconda3/envs/mmmlab/lib/python3.8/site-packages/mmcv/runner/fp16_utils.py”,第 197 行,在 new_func
返回 old_func(*args, **kwargs)
文件“/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.8/site-packages/mmrotate/models/roi_heads/roi_extractors/rotate_single_level_roi_extractor.py”,第101行,向前
out_size = self.roi_layers[0]。 out_size
文件“/home/zhuyu/anaconda3/envs/mmmlab/lib/python3.8/site-packages/torch/nn/modules/module.py”,第 778 行,在getattr
raise ModuleAttributeError("'{}' object has没有属性 '{}'".format(
torch.nn.modules.module.ModuleAttributeError: 'RoIAlignRotated' 对象没有属性 'out_size'

@zytx121
Copy link
Collaborator

zytx121 commented Mar 3, 2022

Hi @LUO77123
It is a bug that has been merged to the dev branch but still not merged to main branch #51
You could pull code from the dev branch and try again.

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

No branches or pull requests

4 participants