Setup Detectron2 on Cloud Linux
After setting up CUDA on Machines, we will install detectron 2 now.
- Setup the environment
I would recommend using conda to manage environments
If you don’t have Anaconda/Miniconda instaled on your system, Install it using the following steps:-
a) Download Miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
b) Change permission and make the file executable
chmod 777 Miniconda3-latest-Linux-x86_64.sh
c) Run the Installer and follow instructions
./Miniconda3-latest-Linux-x86_64.sh
d) Reload ~/.bashrc
source .bashrc
Now that we have conda installed, we can create virtual environments.
Create a virtual environment
conda create -n detectron2_env
Activate the Virtual Environment.
conda activate detectron2_env
Step 2: Install Requirements
Install pip if not installed
conda install pip
Make a requirement.txt
file containing requirements for detectron2, and copy the following content in requirement.txt
opencv-python
torch
torchvision
git+https://github.com/facebookresearch/fvcore
then install the requirements by:
pip install -r detectron_requirement.txt
Step 3: Install detectron2
Install detectron2 by running these commands
git clone https://github.com/facebookresearch/detectron2 detectron2_repopip install --user -e detectron2_repo
Step 4: Check the installation
To check if detectron2 is successfully installed run these commands
cd detectron2_repowget http://images.cocodataset.org/val2017/000000439715.jpg -O input.jpgpython3 demo/demo.py --config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input input.jpg --output outputs --opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl
If all commands runs without errors, Hooray, Detectron2 is setup on your system, you can now use it to train the model and make inferences.