DeepSnake环境配置

DeepSnake

文章:https://arxiv.org/abs/2001.01629

代码:GitHub - zju3dv/snake: Code for "Deep Snake for Real-Time Instance Segmentation" CVPR 2020 oral

配置环境

本地环境:Linux(Ubuntu 21.10)+cuda11.3

配置环境:按照官方提供的install.md进行安装

1.安装pytorch

conda create -n snake python=3.7
conda activate snake
conda install pytorch==1.10.2 torchvision==0.11.3 cudatoolkit=11.3 -c pytorch -c conda-forge

2.安装所需包

pip install Cython yacs numpy tqdm opencv-contrib-python==3.4.2.17 opencv-python==3.4.2.17 imgaug pycocotools Pillow tensorboardX termcolor

3.安装apex

git clone https://github.com/NVIDIA/apex.git
cd apex

我在安装apex时,用官方提供的的这个checkout会报错

1 error detected in the compilation of "csrc/multi_tensor_scale_kernel.cu"

我找到一个大神的解决方法:https://github.com/NVIDIA/apex/issues/802,把git checkout换成这个就行了

git checkout f3a960f80244cf9e80558ab30f7f7e8cbf03c0a0
export CUDA_HOME="/usr/local/cuda-11.3"
python setup.py install --cuda_ext --cpp_ext

4.安装cuda扩展(dcn_v2,extreme_utils,roi_align_layer)

源代码里提供的这个dcn版本太老了,和pytorch1.10不匹配,用新版本的dcn(https://github.com/jinfagang/DCNv2_latest)把源代码里lib/csrc/dcn_v2里的文件全部替换掉。

DeepSnake环境配置_第1张图片

替换之后再安装

cd dcn_v2
python setup.py build_ext --inplace
cd ../extreme_utils
python setup.py build_ext --inplace
cd ../roi_align_layer
python setup.py build_ext --inplace

运行demo

python run.py --type demo --cfg_file configs/sbd_snake.yaml demo_path demo_images/2009_000871.jpg ct_score 0.3

结果:

DeepSnake环境配置_第2张图片

你可能感兴趣的:(python,计算机视觉,目标检测,pytorch)