网上有很多,后期有需要再出吧。以前也踩了不少坑!
2、conda环境创建conda环境
conda create -n pytorch python=3.8
移除conda环境
conda remove -n pytorch --all
激活conda环境
conda activate pytorch
(以cuda10.2,pytorch1.9,python3.8为例)
由于官网下载太慢,我直接把包下载下来安装。下载地址如下:https://download.pytorch.org/whl/torch_stable.html
也可以到pytorch官网:https://pytorch.org/命令行安装
pip install torchvision-0.10.0+cu102-cp38-cp38-win_amd64.whl
pip install torchaudio-0.9.0-cp38-cp38-win_amd64.whl
pip install torch-1.9.0+cu102-cp38-cp38-win_amd64.whl
命令行输入:
python
import torch
print(torch.cuda.is_available())
出现true说明安装成功
然后输入exit()退出
一句话安装mmcv: https://github.com/open-mmlab/mmcv#installation
pip install mmcv-full==1.4.0 -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.9.0/index.html
建议安装MMDetection和MIM,它会自动处理OpenMMLab项目的依赖,包括mmcv等python包。
先安装openmim
pip install openmim
然后安装mmdet
mim install mmdet
也可以自己git下来mmdet包,然后编译
git clone https://github.com/open-mmlab/mmdetection.git cd mmdetection pip install -r requirements/build.txt pip install -v -e . # or "python setup.py develop"6、验证
1.在mmdetection文件夹中新建一个checkpoints文件夹
把这个网站下https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth的文件放入其中。
2.把下面这段代码创建一个py文件到mmdetection文件夹中
from mmdet.apis import init_detector, inference_detector 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' device = 'cuda:0' # init a detector model = init_detector(config_file, checkpoint_file, device=device) # inference the demo image inference_detector(model, 'demo/demo.jpg')
3.cd 到mmdetection文件夹,并执行 python test.py
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)