1、在anaconda中创建环境
建议:envs-python3.7 torch1.6 torchvision0.7 cuda10.2
conda create -n open-mmlab python=3.7 -y
conda activate open-mmlab
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple torch===1.6.0 torchvision===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
cmd查CUDA版本:nvcc -V
tips:将已经安装的带有pytorch的环境(本文中名为torch) clone到新建环境(名为open-mmlab),可以节省安装时间!
conda env list
#查看环境列表
conda create -n open-mmlab --clone torch
检查pytorch是否安装成功,CUDA是否可用。
python
import torch
import torchvision
print(torch.cuda.is_available())
print(torch.__version__)
2、Install mmcv-full
利用官方recommend的pre-built方法,可以省去很多配置的麻烦,mmcv1.1.5可以直接安装成功:
pip install mmcv-full==1.1.5+torch1.6.0+cu102 -f https://download.openmmlab.com/mmcv/dist/index.html
注:一定要对应好torch cuda的版本号,并且给mmcv指定版本(在官网查询latest version和命令,本文中是1.1.5)
3、Clone the MMDetection repository.
下载需要的mmdetection包
方法一:mmdetection2.6 clone package: 链接:https://pan.baidu.com/s/1jpzU96wizGf10hUGWww6Bw 提取码:mda8 (网上下载好的)
方法二:
安装gitbash 迅雷下载https://github.com/git-for-windows/git/releases/download/v2.29.2.windows.2/Git-2.29.2.2-64-bit.exe
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection #打开mmdetection文件夹
tips:在conda prompt的环境下打开mmdetection文件(如何cd mmdetection),例如:
我的mmdetection包安装路径: D:\mmdetection2.6
d:
#进入d盘
cd mmdetection2.6
#打开mmdetection文件
如何网速太慢,可以clone到码云,下载速度直接起飞。
4、Install build requirements and then install MMDetection
4.1先配置requirements:
pip install -r requirements/build.txt
#Install build requirements
这条命令只安装了cython
注:如果有warning,耐心等待,最后也是能够安装成功的(网络的问题)
pip install -r requirements.txt
安装完整的requirements(不装应该也没关系,最好搭一下梯子,否则装的时候会一直报read timed out)
4.2 install mmdetection
python setup.py develop
#Finished processing dependencies for mmdet==2.6.0
然后查询一下conda list
,会发现mmcv-full1.1.5以及mmdet2.6.0以及在内了。
5、测试-基于参考中的mmdetection2.6 clone package
方法一:参考官方verification
from mmdet.apis import init_detector, inference_detector
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
device = 'cuda:0'
# init a detector
model = init_detector(config_file, device=device)
# inference the demo imageD:\mmdetection2.6
inference_detector(model, 'demo/demo.jpg')
注: ‘configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py’、 'demo/demo.jpg’文件的路径,都是在你下载的mmdetection2.6文件夹里,新建test project时,把这些文件copy进去就不会报路径错误了。上述代码的根目录是mmdetection2.6。
model.py在configs文件夹里,parameters文件.pth在checkpoints文件夹里。
方法二:运行官方提供的demo
在jupyter notebook中运行D:\mmdetection2.6\demo\inference_demo.ipynb,如果能完成对输入图像的检测,则安装成功。
方法三:基于mmdetection2.6 clone package: 链接:https://pan.baidu.com/s/1jpzU96wizGf10hUGWww6Bw 提取码:mda8 (选择自己克隆mmdetection包的用前两种方法)
python demo/webcam_demo.py configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth
报错的话,pip install opencv-python==4.2.0.34
如果camera能打开,并且能实现实时检测,就说明安装成功了。
参考:
mmdetection2.6_get_started doc
up-小鸡炖技术【扫盲】Win10配置mmdetection 2.6
mmdetection2.6 clone package: 链接:https://pan.baidu.com/s/1jpzU96wizGf10hUGWww6Bw 提取码:mda8
配置mmcv踩坑:
pip install mmcv-full==latest+torch1.6.0+cu102 -f https://download.openmmlab.com/mmcv/dist/index.html
ERROR: No matching distribution found for mmcv-full==latest+torch1.6.0+cu102
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
MMCV_WITH_OPS=1 pip install -e . # package mmcv-full will be installed after this step
最后一步报错,显示没有MMCV_WITH_OPS命令