Install detectron2 under windows10 (the latest version of maskRCNN)

It’s been almost two years since I first played maskrcnn. I haven’t tried detectron2 after it went online. I decided to try it on Windows. Address

https://github.com/facebookresearch/detectron2

The official clearly stated that there is no special consideration to support windows, but I read the comments in the issues, basically the installation is still not a big problem. I only encountered two problems, which are listed here for your reference.

(1) clone to local

git clone https://github.com/facebookresearch/detectron2.git

cd detectron2

(2) Modify line 483 of cocoeval.cpp

This is mainly because there is no localtime_r function on windows, this function is threadsafe, and the corresponding function on windows is localtime_s. If you don’t modify it, the error is like this,

D:\detectron2\detectron2\layers\csrc\cocoeval\cocoeval.cpp(483): \ C3861: "localtime_r": Identifier not found

How to modify?

In D:\devPytorch\detectron2\detectron2\layers\csrc\cocoeval/cocoval.cpp, add (it should be possible without adding it, but I added)
#include <time.h>
This must be changed to
localtime_s(&local_time,&rawtime ); // changed bymc, originally it is localtime_r(&rawtime, &local_time)

(3) Modify setup.py, install pycocotools

Because pip install pycocotools will not succeed and will report an error, similar to cl: command line error D8021: invalid numerical parameter "/Wno-cpp", so we have to install pycocotools manually.

Comment out the following line,
#"pycocotools>=2.0.1"

Then install pycocotools manually

Solution one (the one I use)
Use pip to install in CMD terminal:
pip install git+https://github.com/philferriere/cocoapi.git#subdirectory=PythonAPI
solution two
https://github.com/philferriere/cocoapi download Source code and unzip it. Open the CMD terminal as an administrator and switch to the cocoapi\PythonAPI directory. Run the following command:
# install pycocotools locally
python setup.py build_ext --inplace
# install pycocotools to the Python site-packages
python setup.py build_ext install

(4) python setup.py install develop

In the main directory of detectron2, enter
python setup.py install develop

A lot of packages will be installed (Facebook can really toss you).

Finally, the installation is successful.

(5) Test

Tested it with the Demo that comes with detectron2.

Randomly ran a few pictures of instance segmentation, it took about 4s on average in CPU mode,
~/msCoco2017/test2017\000000000001.jpg: detected 4 instances in 3.84s
~/msCoco2017/test2017\000000000016.jpg: detected 4 instances in 4.36s
~/msCoco2017/test2017\000000000019.jpg: detected 3 instances in 4.45s
~/msCoco2017/test2017\000000000057.jpg: detected 3 instances in 4.31s
~/msCoco2017/test2017\000000000063.jpg: detected 4 instances in 3.93s
~/msCoco2017/test2017\000000000069.jpg: detected 17 instances in 4.46s

用Cuda1080跑的,
~/msCoco2017/test2017\000000000001.jpg: detected 4 instances in 1.55s
~/msCoco2017/test2017\000000000016.jpg: detected 4 instances in 0.21s
~/msCoco2017/test2017\000000000019.jpg: detected 3 instances in 0.21s
~/msCoco2017/test2017\000000000057.jpg: detected 3 instances in 0.19s
~/msCoco2017/test2017\000000000063.jpg: detected 4 instances in 0.18s
~/msCoco2017/test2017\000000000069.jpg: detected 17 instances in 0.23s
~/msCoco2017/test2017\000000000080.jpg: detected 4 instances in 0.18s

The speed increase is still considerable, and the GPU is close to real-time detection.

Previous reference

https://blog.csdn.net/tanmx219/article/details/100829920  (This problem existed before, but now it is gone)

Guess you like

Origin blog.csdn.net/tanmx219/article/details/107437267