第一步 安装python

cuda 10.2 环境下 
  • conda create -n detectron python=3.7

第二步 安装pycocotools

  • 下载对应的pycocotools-windows · PyPI根据python版本,然后pip安装
  • pip install pycocotools_windows-2.0.0.2-cp37-cp37m-win_amd64.whl

第三步 安装Torch和Torchvision

  • pip install “torch-1.10.1+cu102-cp37-cp37m-win_amd64.whl”
  • pip install “torchvision-0.11.2+cu102-cp37-cp37m-win_amd64.whl”

第四步 安装fvcore

下载链接:https://github.com/facebookresearch/fvcore 点击跳转.
然后cd到setup.py所在目录,用以下指令安装
python setup.py build --force develop
打开cmd输入 import fvcore 没报错即成功

第五步 安装detectron2

在安装detectron2前需要先修改detectron2与pytorch的代码以保证顺利安装。
下载地址:https://github.com/conansherry/detectron2 点击跳转.
1)根据官方文档对pytorch进行如下修改(觉得难找可以下载Everything)

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); }

第一个文件的位置有变动为:{your evn path}\Lib\site-packages\torch\include\torch\csrc\jit\runtime\argumenta_spec.h

<font color='red'>2)</font>将detectron2\detectron2\layers\csrc\deformable 文件夹下三个文件中全部的 AT_CHECK 全部替换为 TORCH_CHECK

第六步 开始安装

  • 进入解压后setup.py的路径
    cd detectron2
  • 安装
    python setup.py build --force develop

在这里插入图片描述

  • 验证
    在这里插入图片描述
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐