安装anaconda
1 创建虚拟环境并激活:
conda create -n mask python=3.6
conda activate mask
2 安装pytorch 和torchvision
目前最新版本即为1.4.0,所以直接安装
pytthon -m pip install torch torchvision
3 安装pycocotools:
pip install cython; pip install -U / 'git+https://gitee.com/cubone/cocoapi.git#subdirectory=PythonAPI'
国内源,下载速度更快
4 升级gcc到5.0以上(如果gcc已经不低于此版本,可以路过)
查看gcc版本:gcc --version
centos升级流程:
https://blog.youkuaiyun.com/yimingfei/article/details/105535894
5 安装detectron2
python -m pip install 'git+https://gitee.com/junfengchen2016/facebookresearch_detectron2.git'
或者
git clone https://gitee.com/junfengchen2016/facebookresearch_detectron2.git
cd detectron2 && python -m pip install -e .
国内源,下载速度快。我选择了第二种
6 安装Pre-Built Detectron2
# for CUDA 10.1:
python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/index.html
我cuda 版本是10.1,直接运行此命令。
查看cuda版本命令:
cat /usr/local/cuda/version.txt
其它版本或cpu,则最后网页更改为:
cuda10.0 https://dl.fbaipublicfiles.com/detectron2/wheels/cu100/index.html
cuda9.2 https://dl.fbaipublicfiles.com/detectron2/wheels/cu92/index.html
cpu https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/index.html
安装完成
测试:
cd demo
cd demo/python demo.py --config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \ --input input1.jpg input2.jpg \ --output output --opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl
其中,测试图片需要自己指定,输出路径要先创建,权重文件如没有会自动下载
本文详细介绍如何使用Anaconda环境安装PyTorch、TorchVision、PyCOCOTools及Detectron2等深度学习框架,包括创建虚拟环境、安装依赖库、升级GCC、安装预构建的Detectron2等步骤。
1万+

被折叠的 条评论
为什么被折叠?



