After Several days of confusion in installing Detectron2 on windows, I finally installed it. So here I've decided to show you the path that I went through.
pycocotools is a Python API that assists in loading, parsing and visualizing the annotations in COCO.
but berfore installing pycocotools, first you should install
Visual Studio Build Tools 2019 (vs_BuildTools.exe)
Follow the instructions that is presented in image below

To install pycocotools, the recommended command is:
pip install pycocotoolsFirst , the Detectron2 repository must be downloaded from here or simply use:
git clone https://github.com/facebookresearch/detectron2.gitNext, changes must be made in 5 files which their names are in following paths:
local_path/detectron2/utils/collect_env.pylocal_path/detectron2/engine/defaults.pylocal_path/detectron2/evaluation/evaluator.pylocal_path/detectron2/layers/csrc/cocoeval/cocoeval.cpplocal_path/detectron2/layers/csrc/nms_rotated/nms_rotated_cuda.cuPlease replace the modified files in this repo with yours.
Use this command to install Detectron2
cd detectron2
pip install -e .- Check the installation:
python -m detectron2.utils.collect_envThe result should be like this:
There is one more thing to do. we should refine unix paths which are / to windows \, we
- step1 :
download iopath:
git clone https://github.com/facebookresearch/iopath --single-branch --branch v0.1.8- step 2:
open iopath/iopath/common/file_io.py
file, in class HTTPURLHandler and it's _get_local_path method, in line 753 replace:
filename = path.split("/")[-1]
with:
filename = parsed_url.path.split("/")[-1]
- step 3 :
Open a terminal with administrator premission, go to your local iopath repository and run following command:
pip install -e iopathHope you can use these instructions to easily install Detectron2. To get more information, follow the links.