Detectron2 is a powerful open-source object detection and segmentation framework built by Facebook AI Research. It's widely used for research and development in computer vision applications. However, installing Detectron2 on Windows 11 can be a bit tricky due to various dependencies. In this guide, I will take you through the step-by-step process to set up Detectron2 on your Windows 11 system.
Step 1: Set up a Conda Environment
First, let's create a new conda environment to isolate the installation:
conda create --name detectron2_env python=3.11.7
conda activate detectron2_env
Step 2: Install CUDA
If you have an NVIDIA GPU, you'll need to install the CUDA toolkit. Ensure you have the correct version compatible with your GPU:
conda install cuda=12.1 -c nvidia
Step 3: Install PyTorch
Install PyTorch with the required CUDA version:
conda install pytorch==1.9.1 torchvision==0.10.1 torchaudio==0.9.1 cudatoolkit=12.1 -c pytorch -c nvidia
For other versions of CUDA, and the required PyTorch version, you can refer to https://pytorch.org/get-started/locally/.
In case you are on CPU, use
conda install pytorch torchvision torchaudio cpuonly -c pytorch
Step 4: Update Visual C++ Redistributable
Ensure your system has the latest Visual C++ Redistributable installed. You can download and install it from the official Microsoft website.
Step 5: Install Cython and COCO Tools
Cython is a prerequisite for building Detectron2, while COCO tools required for evaluation:
pip install cython
conda install conda-forge::pycocotools
Step 6: Clone Detectron2 Repository
Clone the Detectron2 repository from GitHub:
git clone https://github.com/facebookresearch/detectron2.git
Step 7: Install Detectron2
python -m pip install -e detectron2
That's it! You've successfully installed Detectron2 on your Windows 11 system. You can now start using it for various computer vision tasks like object detection, instance segmentation, and more.
Remember to activate your conda environment whenever you want to work with Detectron2.
Happy coding!🤗🤗
Top comments (3)
Thank you! Just what I was looking for!
Do I need to clone and install detectron2? Why is this necessary?
Installation will set up your system, while cloning will help you utilize all the models present in the detectron2 model zoo. I hope this helps!