Win10、Cuda10、VS2017自行百度安装,本文就不加详述了
一、Anaconda虚拟环境
1、python环境
conda create -n CenterNet python=3.6
conda activate CenterNet
2、Pytorch1.2.0
(1)下载如下两个文件,网址:https://download.pytorch.org/whl/cu100/torch_stable.html
torch-1.2.0-cp36-cp36m-win_amd64.whl
torchvision-0.4.0-cp36-cp36m-win_amd64.whl
(2)pip安装下载的两个文件,用绝对路径
pip install path/torch-1.2.0-cp36-cp36m-win_amd64.whl
pip install path/torchvision-0.4.0-cp36-cp36m-win_amd64.whl
3、其他Python库
git clone https://github.com/xingyizhou/CenterNet.git
cd CenterNet
pip install -r requirements.txt
二、编译DCNv2
(1)git clone https://github.com/CharlesShang/DCNv2
(2)DCNv2文件夹替换CenterNet\src\lib\models\networks\DCNv2文件夹
(3)修改 DCN文件2\src\cuda\dcn_v2_cuda.cu
//extern THCState *state; // 注释该行
THCState *state = at::globalContext().lazyInitCUDA(); // 添加该行
(4)编译
cd CenterNet\src\lib\models\networks\DCNv2
make.sh
三、编译NMS
(1)cd CenterNet\src\lib\external
注释setup.py文件中该行代码
#extra_compile_args=["-Wno-cpp", "-Wno-unused-function"]
(2)编译
python setup.py build_ext --inplace
四、测试
python demo.py ctdet --demo ../images/ --load_model ../models/ctdet_coco_dla_2x.pth