在集成 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
此時表示已經完成安裝和環境准備工作。可以調取模型和接下來的訓練,推理,驗證的過程了。