No. Image Detection and Segmentation does not require a PhD.
Yes. It truly is amazing that we can access and use numerous libraries for free without understanding the complexities behind them.
This series mainly focuses on getting started with Image Segmentation using Mask Regional Convolutional Neural Network (MRCNN) using Python!
Before anything, I would like to credit Matterport, Inc for making this model so easily accessible. You can check out their repository and tutorial on how to get started with this model.
Although their tutorial is well-detailed, starting off as a complete beginner (like myself) can be extremely challenging. Therefore, in this series I would like to ‘hand-hold’ you through the process of modifying the Python scripts and checking your results, eventually being able to implement them on your own projects!
Part 1 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.
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 — 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).
Requirements List
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 opencv-pythonh5py 2.10.0 → conda install h5py==2.10.0imgaug → conda install imgaugIPython[all] → conda install IPython[all]
Pro tip! You can install all of these in a single line as such
conda install numpy scipy Pillow ... (Replace the ... with the other requirements)
Step 4— Clone GitHub Repository!
Amazing! We are one step closer to getting started!
Now, 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.
- 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 5 — Adding some important files!
The pre-trained COCO file and dataset (consisting of annotated images) are too large for me to include it directly into the GitHub repository.
- 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_RCNNsamplesballoon)
- 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_RCNNsamplesballoon)
There we go! Now we are all set to start using the Mask R-CNN model! Check out Part 2 for the next step😄