全新的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.3.1 torchvision===0.4.2 -f https://download.pytorch.org/whl/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple
並作如下修改:
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 [email protected]: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