GitHub原链接:https://github.com/facebookresearch/detectron2/blob/master/INSTALL.md
安装
Colab Notebook有安装Detectron2的说明.
Dockerfile也可以通过简单的操作安装Detectron2.
环境
- Linux或macOS,Python ≥ 3.6
- PyTorch ≥ 1.4
- 与PyTorch版本一致的torchvision。一般在PyTorch安装时就已经安装。
- OpenCV,可选,Demo和Visualization会用到
- pycocotools:
pip install cython; pip install -U 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
Build Detectron2 from Source
需要gcc & g++ ≥ 5。ninja 用来快速安装.
执行:
python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
# (add --user if you don't have permission)
# 或者通过本地clone的工程
git clone https://github.com/facebookresearch/detectron2.git
python -m pip install -e detectron2
# 或者如果是MacOS
# CC=clang CXX=clang++ python -m pip install -e .
在重新编译detectron2时,需要用rm -rf build/ **/*.so
将原来的残留文件删除。在重装PyTorch时,常常需要重装Detectron2。
Install Pre-Built Detectron2 (只有Linux需要)
# for CUDA 10.1:
python -m pip install detectron2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/index.html
可以根据实际需要替换cu101为"cu{100,92}“或者"cpu”。
注意:
- 此安装必须与PyTorch官方发行版一起使用。如releases 需要。它不适用于其他版本的PyTorch或非官方的PyTorch版本。
- 有可能此版本时过时的,与实际使用的版本不匹配,参见 projects or meshrcnn.