In this tutorial we are going to see how to run the Mask R-CNN algorythm using the GPU on the Ubuntu os system.
OS Linux Ubuntu 18.04 (it might work with earlier versions as well, but I don’t guarantee that)
Nvidia GPU with CUDA support. Click here to see the list with all the GPUs which support cuda.
Mask R-CNN is a Convolutional Neural Network used in Computer vision which is able to perform Object Detection and Istance segmentation.
To describe in simple words how this algorythm works, we can divide it into three stages:
On the 1st stage there is a RPN (Region Proposal Network) which proposes the Regions where objects could be. This method is really useful to discard some areas and so to reduce the computetional requirements later on for the object detection.
On the 2nd stage these regions are passed through a Convolutional Neural Network which detects to what category the object belongs.
On the 3rd stage for each Object detected, is also created a Mask which exactly identifies the location of the object, so that we can have clear boundaries of the objects (not simple boxes).
Let’s now see the instructions about how to run this algorythm on Ubuntu. Let me clarify first that there is not only one way to do that, but there are many ways.
The Mask R-CNN algorythm to run needs a deep learning framework. At the moment the most common deep learning frameworks are: tensorflow, pytorch and keras. For each of them there is an implementation of the algorythm.
I choosed for this article to run it on the Pytorch framework. For a different framework, you need of course a different implementation of the algorythm.
This is the github repository of the code we’re going to use: https://github.com/facebookresearch/maskrcnn-benchmark
Let’s now proceed with the installation.
1 - Get the download link of the lastest version of Anaconda here: https://www.anaconda.com/distribution/ 2 - Then on the terminal type:
(You have to change the link with your link for the lastest version). Then after the download is finish you can proceed with the installation.
sudo bash Anaconda3-2019.10-Linux-x86_64.sh
3 - Press enter until you see the “License agreement”, then you press the spacebar until you see the question: “Do you accept the license terms?”
and press enter.
4 - Press enter again to confirm the default location where you want to install anaconda.
5 - “Do you wish the installer to inizialize Anaconda3 by running conda init?
and press enter.
6 - Give administrator permissions to use Anaconda and create virtual environments:
sudo chown -R $USER anaconda3 sudo chwon -R $USER sudo chown R ~/.conda
Once we have anaconda installed we can install all the libraries necesary to run Mask R-CNN
Create an environment:
conda create --name maskrcnn_benchmark -y conda activate maskrcnn_benchmark
pip install torch==1.3.0 pip install torchvision==0.4.1
conda install cudatoolkit=10.0
cd $INSTALL_DIR git clone https://github.com/NVIDIA/apex.git cd apex
python setup.py install
cd $INSTALL_DIR git clone https://github.com/cocodataset/cocoapi.git cd cocoapi/PythonAPI python setup.py build_ext install
cd $INSTALL_DIR git clone https://github.com/mcordts/cityscapesScripts.git cd cityscapesScripts/ python setup.py build_ext install
cd $INSTALL_DIR git clone https://github.com/facebookresearch/maskrcnn-benchmark.git cd maskrcnn-benchmark python setup.py build develop
Once we are still inside the conda environment and the folder maskrcnn-benchmark we can run the algorythm with simply two lines of code:
cd demo python webcam.py
In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.
Magic Methods are the special methods which gives us the ability to access built in syntactical features such as ‘<’, ‘>’, ‘==’, ‘+’ etc.. You must have worked with such methods without knowing them to be as magic methods. Magic methods can be identified with their names which start with __ and ends with __ like __init__, __call__, __str__ etc. These methods are also called Dunder Methods, because of their name starting and ending with Double Underscore (Dunder).
How to Install Pyenv on Ubuntu 18.04 - What is Pyenv? Pyenv is a fantastic tool for installing and managing multiple Python versions. It enables a developer to quickly gain access to newer
In this tutorial, we will show you how to install Microsoft Teams on Ubuntu 20.04 machine. we can install teams using Debian installer file or by adding microsoft repository.
Python is an interpreted, high-level, powerful general-purpose programming language. You may ask, Python’s a snake right? and Why is this programming language named after it?