A-A+

如何在 Windows 10 上轻松安装 Detectron2

2023年04月29日 23:29 汪洋大海 暂无评论 共1598字 (阅读767 views次)

在 Windows 上安装 Detectron2 并不是一件容易的事,因为正式版的 Detectron2 在这个平台上是官方不支持的,而且 Windows Subsystem for Linux 也无法访问机器的 GPU。按照接下来的步骤,您可以快速安装和使用最新版本的Detectron2,完美运行。

第 1 步:创建 conda 环境

conda create -n myenv python=3.7
conda activate myenv

将 myenv 替换为您的环境名称。

第 2 步:安装 Cuda

然后,像安装任何程序一样安装 Cuda 工具包。

第 3 步:安装手电筒

conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1 -c pytorch

注意:PyTorch 1.6 不支持 cudatoolkit=11。但是如果你已经安装了 CUDA 11.x,cudatoolkit=10.1 仍然可以正常工作。

第 4 步:安装 Cython 和 Pycocotools

pip install cython

然后使用下面的存储库,它可以很好地与 Windows 一起安装 Pycocotools。

pip install "git+https://github.com/philferriere/cocoapi.git#egg=pycocotools&subdirectory=PythonAPI"

第 5 步:安装 Detectron2

git clone https://github.com/DGMaxime/detectron2-windows.git

此存储库已准备好与 Windows 一起使用。一些文件已被修改。您可以在此处找到这些文件:

setup.py
detectron2/engine/ defaults.py
detectron2/layers/csrc/cocoeval/ cocoeval.cpp

克隆完成后,安装它。

cd detectron2-windows
pip install -e .

如果安装成功,您应该会看到消息“Successfully installed detectron2”。

第六步:测试Detectron2的安装

pip 安装 opencv-python 
python 测试/test_windows_install.py

结果:

图片 Flickr:Michael J. Belgie, Sr

希望这个故事对你有帮助!

文章来源:https://dgmaxime.medium.com/how-to-easily-install-detectron2-on-windows-10-39186139101c

布施恩德可便相知重

微信扫一扫打赏

支付宝扫一扫打赏

×

给我留言