创建新环境
1.在终端输入conda create -n detec python=3.6
在磁盘空间足够时,新建环境好管理
激活环境及配置
2.激活环境source activate detec
3. 安装pytorch conda install pytorch=1.4 torchvision cudatoolkit=10.0
这一步需要挂梯子操作(经常网络不佳),但是有的时候国内源更快
装依赖项
在每个项目的网络的安全说明里去找,一般会写出要哪些配置。有的也需要百度去查某个依赖项怎么装
4. pip install opencv-python
5. pip install 'git+https://github.com/facebookresearch/fvcore'
6. pip install cython; pip install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
进入下载好的github代码 文件夹
7.进入项目文件夹cd /home/koihoo/下载/github/detectron2
8.配置依赖项 python setup.py build develop
demo运行
Detectron2入门
预训练模型推理演示
一、从模型中选择一个模型及其配置文件,例如mask_rcnn_R_50_FPN_1x.yaml
二、提供demo.py
运行内置标准模型的工具。使用以下命令运行:
cd demo / python demo.py --config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \ --input input1.jpg input2.jpg \ [--other-options] --opts MODEL.WEIGHTS detectron2: //COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl