文章目录
一. Anaconda 安装
安装教程:Anaconda介绍、安装及使用教程
清华开源镜像网:清华开源镜像网
一些指令:
- 查看所有环境
conda env list
- 复制某个环境,复制 test 这个环境
conda create --name copy --clone test
- 删除某个环境
conda remove --name test --all
二. Detectron2 环境配置
链接:detectron2
1. requirements
- 新建环境
conda create --name detectron2 python=3.6
- 激活环境
conda activate detectron2
- 安装Pytorch,自己在这里找 Pytorch官网
conda install pytorch torchvision cudatoolkit=9.2 -c pytorch
- 安装 opencv 包
conda install --channel https://conda.anaconda.org/menpo opencv3
- 安装 pycocotools 包
pip install cython; pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
2. 物体检测平台
3. 安装
python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
三. 物体检测平台 Detectron2 使用
1. 数据集下载
链接:COCO
2. 测试
- 找一张 coco 验证集的图像放到,
./detectron2/demo
文件夹中 - 运行指令
- 激活环境
conda activate detectron2
- 进入路径下
cd ./detectron2/demo
- 运行指令
python demo.py --configfile ../configs/COCODetection/retinanet_R_50_FPN_1x.yaml --input 000000000785.jpg [--otheroptions]--opts MODEL.WEIGHTS detectron2://COCODetection/retinanet_R_50_FPN_1x/190397773/model_final_bfca0b.pkl
3. 在 coco 验证集上测试训练好的模型精度
conda activate detectron2
cd ./detectron2
python ./tools/train_net.py --config-file ./configs/COCODetection/retinanet_R_50_FPN_1x.yaml --eval-only MODEL.WEIGHTS detectron2://COCODetection/retinanet_R_50_FPN_1x/190397773/model_final
_bfca0b.pkl
4. 常见问题解决方法
-
pycharm 加载慢
点击文件夹 → Mark Directory as → excluded