【AI-人工智能-mmdetection】ModuleNotFoundError: No module named 'mmdet.version'

在集成 mmdetection 框架时遇到这样的问题。

ModuleNotFoundError: No module named 'mmdet.version'

mmdetection 框架搭建过程很容易忽略 编译过程

root@48ea75026556:/mmdetection# python sg-pcr-client/pcr_agant_new.py 
Traceback (most recent call last):
  File "sg-pcr-client/pcr_agant_new.py", line 9, in <module>
    from pr_handler_new import PicRecHandler
  File "/home/mmxsrt/sg-pcr-client/pr_handler_new.py", line 4, in <module>
    from mmdet.apis import init_detector, inference_detector, show_result
  File "/mmdetection/mmdet/__init__.py", line 1, in <module>
    from .version import __version__, short_version
ModuleNotFoundError: No module named 'mmdet.version'
root@48ea75026556:/mmdetection# 

其实在mmdetection-master中 有个docker目录

里面很清楚的描述了搭建过程。贴上dockerfile代码

 1 ARG PYTORCH="1.1.0"
 2 ARG CUDA="10.0"
 3 ARG CUDNN="7.5"
 4 
 5 FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel
 6 
 7 RUN apt-get update && apt-get install -y libglib2.0-0 libsm6 libxrender-dev libxext6
 8 
 9 # Install mmdetection
10 RUN conda install cython -y
11 RUN git clone https://github.com/open-mmlab/mmdetection.git /mmdetection
12 WORKDIR /mmdetection
13 RUN pip install -e .

最后一步使我们本次解决问题的关键 安装编译

RUN pip install -e .

编译成功后

Installing collected packages: mmdet
  Found existing installation: mmdet 1.0rc0+unknown
    Uninstalling mmdet-1.0rc0+unknown:
      Successfully uninstalled mmdet-1.0rc0+unknown
  Running setup.py develop for mmdet
Successfully installed mmdet

此时表示已经完成安装和环境准备工作。可以调取模型和接下来的训练,推理,验证的过程了。

猜你喜欢

转载自www.cnblogs.com/yangww/p/11582897.html