安装Detectron2及相关依赖并进行测试

1.首先安装anaconda,这个比较简单,网上很多教程

2.新建detectron环境

conda create --name detectron2 python=3.8

注意,这里的环境要求是根据detectron2的官方要求安装的,具体可以看detectron2/INSTALL.md at main · facebookresearch/detectron2 · GitHub

查看detectron环境

conda env list

3.安装Pytorch,这个参考官方网站Start Locally | PyTorch,选择conda版本,我这是linux、python3.8、cuda11.4、RTX3060显卡版本,会得到相应命令,装11.3就行(没有11.4版本)


conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

查看Pytorch和TorchVision版本

python
import torch
torch.__version__
import torchvision
torch.vision.__version__

4.安装opencv

注意:opencv3已经不支持python3.8

python3.8版本直接通过conda安装就行

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python

5.安装cython和cocotools

pip install cython
pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'

6.检查

看一下上面安装的东西对不对

conda env list

7.安装配置detectron2

首先将源码克隆到本地

git clone https://github.com/facebookresearch/detectron2.git

也可以使用代理:https://ghproxy.com/

git clone https://ghproxy.com/https://github.com/facebookresearch/detectron2.git

8.安装detectron2

在detectron2上层目录执行

python -m pip install -e detectron2

9.数据集下载

官网地址:COCO - Common Objects in Context

 

百度网盘:链接: https://pan.baidu.com/s/1wad_82nFn8Pc_cQHnW3w_Q?pwd=nx76 提取码: nx76

10.解压数据集,并放入到/detectron2/datasets/

11.执行测试指令

注意:000000078548.jpg是你选择的图片,需要放在/detectron2/demo/文件夹下

python demo.py --config-file ../configs/COCO-Detection/retinanet_R_50_FPN_1x.yaml --input 000000078548.jpg [--other-options] --opts MODEL.WEIGHTS detectron2://COCO-Detection/retinanet_R_50_FPN_1x/190397773/model_final_bfca0b.pkl

12.执行训练指令

 python ./tools/train_net.py --config-file ./configs/COCO-Detection/retinanet_R_50_FPN_1x.yaml --eval-only MODEL.WEIGHTS detectron2://COCO-Detection/retinanet_R_50_FPN_1x/190397773/model_final_bfca0b.pkl

13.其它问题

如果遇到了:执行detectron2编译报错No such file or directory: ‘/usr/local/cuda/bin/bin/nvcc‘

参考我这个博客:执行detectron2编译报错No such file or directory: ‘/usr/local/cuda/bin/bin/nvcc‘_C++有手就行的博客-CSDN博客

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值