
windows系统下的环境配置(GPU版)
这里提供以下windows下CPU版本环境配置的教程:CPU-mmdetection 注:Ubuntu系统下的环境配置大同小异,甚至会简单点
pytorch(python3.8)
pytorch命令指南 
pip3 install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio===0.9.1 -f https://download.pytorch.org/whl/torch_stable.html
可能会出现pip失败的情况,大概率是网络不稳定造成的,
pytorch下载 如果上面因为网络原因pip失败,可以去上面链接下载对应的库包,本文的库链接如下:
下载下来执行: package_location:下载包的绝对地址
pip3 install {package_location}
CUDA11.1+CUDNN8.0.5
- CUDA Toolkit 11.1.1 (Oct 2020)
- cuDNN v8.0.5 (November 9th, 2020), for CUDA 11.1
上述CUDA TOOlkit默认安装完毕之后,将cuDNN解压出来文件夹里的许多文件复制到如下目录即可:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1
mmdetection(GPU)
open-mmlab-mmdetection开源库  将上述库clone下来
MMDetection中文安装指南
 上述mmcv-full的安装可以直接复制下面
pip install mmcv-full=={1.3.9} -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9.1/index.html
 第三步骤的安装是补充的,有需要可以安装 
验证安装结果
 下载上述代码指定的权重: faster-rcnn权重下载链接
from mmdet.apis import init_detector, inference_detector
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
device = 'cuda:0'
model = init_detector(config_file, checkpoint_file, device=device)
inference_detector(model, 'demo/demo.jpg')
复制上述代码到工程根目录运行,如果程序exit code为0,则环境配置完成
或者运行如下代码:
from mmdet.apis import init_detector, inference_detector
import mmcv
config_file = './configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
checkpoint_file = './checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'
model = init_detector(config_file, checkpoint_file, device='cuda:0')
img = './demo/demo.jpg'
result = inference_detector(model, img)
model.show_result(img, result)
model.show_result(img, result, out_file='result.jpg')
如果exit code为0,根目录会出现result.jpg 
|