This Part focuses on setting up our machine to run this model. We will be learning how to use Anaconda’s virtual environments and cloning the repository from GitHub.
Setting up your environment
It is ALWAYS better to use a virtual environment for projects.
That is something I have heard numerous times in the past month since I started my journey in Computer Vision & Machine Learning, and I have to say it is true.
Step 1 — Installing Anaconda on your machine
For those of us who are unaware, Anaconda is a Python (and R) distribution that makes package management and deployment easier.
To install Anaconda for your system, head to this site. Ensure that Anaconda Navigator is installed on your system (this should happen with the Anaconda installation).
Step 2 — Setting up our Virtual Environment
A virtual environment enables us to install different versions of Python, packages, dependencies, etc. without modifying those pre-existing on our system. It also allows us to have different versions of a library (e.g. Python 3.6 vs Python 3.8) running on different projects, based on the requirements.
For this Mask RCNN Model, we will require Python 3.6. Therefore, when creating your virtual environment, ensure to select Python 3.6!
Step 3— Clone GitHub Repository!
You could clone Matterport’s repository into your Anaconda environment from here.
However, I would suggest you clone my repository since I have removed the unnecessary folders for this specific project, making it easier to navigate through the files.
If you have never used Git before, follow these steps.
- Install Git from here.
- Copy this link: https://github.com/aryanvij02/Mask-R-CNN
- Go to your Anaconda Navigator
- Select your environment, click the small play button, and select Open Terminal. (See picture below).
4. In your Terminal/Command Prompt, navigate to the directory into which you wish to clone the Repository.
5. Copy and paste the following command.
git clone https://github.com/aryanvij02/Mask-R-CNN
Step 4— Installing all requirements
To install the following requirements, use ‘conda install’ instead of ‘pip install’. The reason for this is because conda helps us install several essential dependencies that pip may not.
Make sure you are installing these in your virtual environment. In the Anaconda Navigator, open the terminal in your Virtual Environment as such:
- click the small play button, and select Open Terminal. (See picture below).
First let’s install Jupyter Notebook
conda install jupyter notebook
numpy → conda install numpyscipy → conda install scipyPillow → conda install Pillowcython → conda install Cythonmatplotlib → conda install matplotlibscikit-image → conda install scikit-imageTensorflow 1.15 → conda install tensorflow==1.15#if you have a machine with a dedicated GPU (which is highly recommended), install Tensorflow for GPU as well (version 1.15)Tensorflow GPU 1.15 → conda install tensorflow-gpu==1.15Keras → conda install -c conda-forge kerasOpenCV-Python → conda install -c conda-forge opencvh5py 2.10.0 → conda install h5py==2.10.0imgaug → conda install imgaugIPython[all] → conda install IPython[all]
Pro tip! You can make use of the requirements.txt file. Type:
conda install --file requirements.txt
conda install tensorflow-gpu==1.15
conda install -c conda-forge opencv
conda install -c conda-forge keras
If for some reason your installation for OpenCV fails, visit this site.
Step 5 — Adding some important files!
Let’s download the pre-trained dataset and add it to our Mask-RCNN directory.
- Head to this page and download balloon_dataset.zip and mask_rcnn_balloon.h5
- Unzip balloon_dataset.zip and open the unzipped folder.
- Windows Users: Copy the balloon folder into your balloon directory (this would be: C:\‘your-root-directory’\Mask_RCNN\samples\balloon)
- Mac Users: You will have to copy the balloon folder that is nested inside the MacOSX folder into your balloon directory.
- Copy the mask_rcnn_balloon.h5 file into the same balloon directory (C:\‘your-root-directory’\Mask_RCNN\samples\balloon)
There we go! Now we are all set to start using the Mask R-CNN model! Check out Part 3 for the next step😄