1. detectron2
FAIR’s open source object detection framework, Detectron2, is based on Pytorch. It trains faster, features more fully, and supports more diverse models than ever before. For example, in addition to primitive models like Faster R-CNN, Mask R-CNN, RetinaNet, DensePose, etc., new models like Cascade R-NN, Panoptic FPN, TensorMask, etc., are supported. It also addresses the previous problem of Pytorch production being difficult to deploy. So I can’t wait to try it out and document the Detectron2 environment setup.
2. Pytorch environment
First, we need to set up a Pytorch environment, as described in the previous article installing Pytorch with Conda.
3. opencv3
Opencv3 is a well-known computer vision processing library. In Python 3.6, use the following command and do the job:
conda install -c menpo opencv3
Copy the code
However, the above command is invalid in Python 3.7. Pypi can be used for installation:
pip install opencv-python
Copy the code
If your network is not good and easy to fail, we can temporarily use PYPI image of Tsinghua to install:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python
Copy the code
4. fvcore
Fvcore is a lightweight core library from FAIR open source that provides the most common and basic features shared in various computer vision frameworks such as Detectron2. The library requires a Python environment of >=Python 3.6.
The Conda installation command is:
conda install -c fvcore fvcore
Copy the code
The pypI installation command is as follows:
pip install fvcore
Copy the code
See Section 3 for a faster way to use pYPI mirroring.
5. pycocotools
The COCO database released by Microsoft is a large image data set designed for object detection, segmentation, human key point detection, semantic segmentation and subtitle generation. The COCO API provides API interfaces for Matlab, Python and Lua. The API provides complete image tag data loading, parsing, and visualization. The PyCocoTools library provides access to a number of features provided by COCO. Installation methods vary in different environments. The Linux environment is used as an example:
pip3 install -U Cython
pip3 install -U pycocotools
Copy the code
6. Other package dependencies
Install according to the requirements provided by the project.
GCC compiler version >= 4.9
7. Install detectron2
Here we go. The next big thing is to install the Detectron 2.
7.1 Direct Installation
You can install it directly by executing the following command:
pip install 'git+https://github.com/facebookresearch/detectron2.git'
Copy the code
Add the –user parameter to the above command line if no permission is displayed.
7.2 Local Installation
You can also Git a local installation:
git clone https://github.com/facebookresearch/detectron2.git
cd detectron2 && pip install -e .
Copy the code
7.3 tip
For MacOS users, the following installation commands should be executed on top of either 7.1 or 7.2:
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ pip install -e .
Copy the code
Also, if you install multiple CUDA versions on your machine, it may cause inconsistency between NVCC and CUDA versions. There is a workaround online that I haven’t come across, so I’m just warning you.
8. To summarize
Generally there are not too many problems with the installation as I have done above. If you have good suggestions, you can give feedback via the wechat official account: Felordcn. In the next article, we will discuss some problems in the process of practical use.
Follow our public id: Felordcn for more information
Personal blog: https://felord.cn