全新的detectron2:
- 基于pytorch重写
- 加入了新的功能如:panoptic segmentation, densepose, Cascade R-CNN, rotated bounding boxes
- 为轮子而生、为开源而生
- 训练更快
作为一只新入门的菜鸟一直奉行:复现,复现,复现,自我发挥=自找麻烦
- 开始
- 安装VS2019(可以不卸载VS2017\VS2015)
- 安装CUDA10.1及与之配套的cudnn(可以不卸载CUDA10.0),安装完成后可以使用一下命令检验:
nvidia-smi
- 安装Anaconda
- 创建一个虚拟环境
conda create -n detectron2py36 python=3.6.5
- 进入虚拟环境
activate detectron2py36
- 安装pytorch,可前往pytorch官网,或者直接使用以下命令,建议使用国内镜像
pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
并作如下修改:
file1:
{your evn path}\Lib\site-packages\torch\include\torch\csrc\jit\argument_spec.h
example:
{C:\Miniconda3\envs\py36}\Lib\site-packages\torch\include\torch\csrc\jit\argument_spec.h(190)
static constexpr size_t DEPTH_LIMIT = 128;
change to -->
static const size_t DEPTH_LIMIT = 128;
file2:
{your evn path}\Lib\site-packages\torch\include\pybind11\cast.h
example:
{C:\Miniconda3\envs\py36}\Lib\site-packages\torch\include\pybind11\cast.h(1449)
explicit operator type&() { return *(this->value); }
change to -->
explicit operator type&() { return *((type*)this->value); }
- 安装fvcore:
pip install 'git+https://github.com/facebookresearch/fvcore'
- 安装cython
pip install cython
- 参考https://github.com/philferriere/cocoapi安装pycocotools
- 编译detectron2可参考官网:https://github.com/facebookresearch/detectron2
git clone git@github.com:facebookresearch/detectron2.git
做如下修改:
for the "detectron2/layers/csrc/ROIAlign/ROIAlign_cuda.cu" and "detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cuda.cu",
change from each
dim3 grid(std::min(at::cuda::ATenCeilDiv(output_size, 512L), 4096L));
~
~
dim3 grid(std::min(at::cuda::ATenCeilDiv(grad.numel(), 512L), 4096L));
to
dim3 grid(std::min(at::cuda::ATenCeilDiv(static_cast<int64_t>(output_size), static_cast<int64_t>(512)), static_cast<int64_t>(4096)));
~
~
dim3 grid(std::min(at::cuda::ATenCeilDiv(static_cast<int64_t>(grad.numel()), static_cast<int64_t>(512)), static_cast<int64_t>(4096)));
编译:
cd detectron2
python setup.py build develop
- 完成,侵删。
Inference :
https://github.com/facebookresearch/detectron2
https://github.com/facebookresearch/detectron2/issues/9
https://github.com/philferriere/cocoapi
https://github.com/facebookresearch/detectron2/issues/9#issuecomment-546226799