ModuleNotFoundError: No module named 'mmcv._ext'
# test.py
from mmdet.apis import init_detector, inference_detector, show_result_pyplot
import mmcv
config_file = '../configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
# download the checkpoint from model zoo and put it in `checkpoints/`
# url: https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
checkpoint_file = '../checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
model = init_detector(config_file, checkpoint_file, device='cuda:0')
# test a single image
img = 'demo.jpg'
result = inference_detector(model, img)
Hello, I attempted to run your model using the code from the demo/inference_demo.ipynb file (test.py above). However, upon execution, I encountered the following issue:
Traceback (most recent call last):
File "test.py", line 1, in <module>
from mmdet.apis import init_detector, inference_detector, show_result_pyplot
File "/Users/thaophan/Work/RnD/Co-DETR/mmdet/apis/__init__.py", line 2, in <module>
from .inference import (async_inference_detector, inference_detector,
File "/Users/thaophan/Work/RnD/Co-DETR/mmdet/apis/inference.py", line 8, in <module>
from mmcv.ops import RoIPool
File "/Users/thaophan/Work/RnD/Co-DETR/myenv/lib/python3.7/site-packages/mmcv/ops/__init__.py", line 2, in <module>
from .active_rotated_filter import active_rotated_filter
File "/Users/thaophan/Work/RnD/Co-DETR/myenv/lib/python3.7/site-packages/mmcv/ops/active_rotated_filter.py", line 10, in <module>
['active_rotated_filter_forward', 'active_rotated_filter_backward'])
File "/Users/thaophan/Work/RnD/Co-DETR/myenv/lib/python3.7/site-packages/mmcv/utils/ext_loader.py", line 13, in load_ext
ext = importlib.import_module('mmcv.' + name)
File "/Users/thaophan/.pyenv/versions/3.7.11/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'mmcv._ext'
python3 -c "import torch; print(torch.__version__)"
1.11.0
================================
pip install mmcv-full==1.5.0 -f https://download.openmmlab.com/mmcv/dist/cpu/torch1.11.0/index.html
pip show mmcv-full
Name: mmcv-full
Version: 1.5.0
Summary: OpenMMLab Computer Vision Foundation
Home-page: https://github.com/open-mmlab/mmcv
Author: MMCV Contributors
Author-email: [email protected]
License:
Location: /Users/thaophan/Work/RnD/Co-DETR/myenv/lib/python3.7/site-packages
Requires: addict, numpy, opencv-python, packaging, Pillow, pyyaml, yapf
Required-by:
================================
macOS Monterey
Version 12.3.1
MacBook Pro (13-inch, 2019, Two Thunderbolt 3 ports)
Processor 1,4 GHz Quad-Core Intel Core i5
Memory 16 GB 2133 MHz LPDDR3
Graphics Intel Iris Plus Graphics 645 1536 MB
Can you help me to fix it ? Thanks
It seems you install the CPU version of mmcv-full. But the code model = init_detector(config_file, checkpoint_file, device='cuda:0') requires GPU for inference.
hello,I've got a problem.
pip install mmcv==1.5.0 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.11/index.html
When I run: sh tools/dist_test.sh projects/configs/co_deformable_detr/co_deformable_detr_r50_1x_coco.py path_to_checkpoint 8 --eval bbox
Traceback (most recent call last):
File "tools/test.py", line 15, in
hello,I've got a problem.
pip install mmcv==1.5.0 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.11/index.html
When I run: sh tools/dist_test.sh projects/configs/co_deformable_detr/co_deformable_detr_r50_1x_coco.py path_to_checkpoint 8 --eval bbox
Traceback (most recent call last): File "tools/test.py", line 15, in from mmdet.apis import multi_gpu_test, single_gpu_test File "/data1/home/jiangying/BigModel/Co-DETR-main/mmdet/apis/init.py", line 2, in from .inference import (async_inference_detector, inference_detector, File "/data1/home/jiangying/BigModel/Co-DETR-main/mmdet/apis/inference.py", line 8, in from mmcv.ops import RoIPool File "/usr/local/lib/python3.8/dist-packages/mmcv/ops/init.py", line 2, in from .active_rotated_filter import active_rotated_filter File "/usr/local/lib/python3.8/dist-packages/mmcv/ops/active_rotated_filter.py", line 8, in ext_module = ext_loader.load_ext( File "/usr/local/lib/python3.8/dist-packages/mmcv/utils/ext_loader.py", line 13, in load_ext ext = importlib.import_module('mmcv.' + name) File "/usr/lib/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) ModuleNotFoundError: No module named 'mmcv._ext'
hey ,bro,I meet the same problem, how do you solove it
This fixed it for me, since it is an old mmcv version the '-full' postfix seems to be required, although for the recent versions this is handled differently
mim uninstall mmcv
mim install mmcv-full==1.5.0