TensorFlow Diaries- Intro and Setup

Why a blog that focuses on Computer Vision suddenly shifted to Machine Learning? This might be ringing in the heads of many active readers of my blog. So let me start my blog by answering the above question 😉

It is quite funny to note that Computer Vision was actually started as a summer project in MIT (1966) by Prof. Marvin Minsky. He laid out some tasks to are to be completed as a part of the summer project and it has been what the field is working on for the past 40-50 years. In Computer Vision, we are trying to teach computers how to see and perceive the environment like a human does. This includes recognising objects, understanding complex scenes, locomotion in an environment avoiding obstacles, 3D reconstruction etc., and a lot of these require Machine Learning algorithms along with 3D Geometry and applied mathematics. So, Computer Vision actually requires knowledge of Machine Learning! Even if you observe the top conference publications in Computer Vision such as CVPR and ICCV, you can see a lot of papers using Machine Learning and Deep Learning tasks to produce some state of the results. Rest is History! Assuming you all know what Deep Learning is, let us dive into the Intro to TensorFlow and how to setup your machine.

Why TensorFlow?

You might be wondering why I chose this specific library over other existing libraries such as Keras, Theano, Torch etc. Though TensorFlow is launched as an open-source software recently into the market, it has been accepted by the community in huge numbers. Many people are using it in their development environments/pipeline to design and train custom networks for solving complex real-world problems, researchers have also started using it because of its flexibility to design and test new types of networks, some universities have already included TensorFlow in their Machine Learning course curriculum and so on. The reason why I chose TensorFlow is the following: Once I design the network in Python+TensorFlow, I can easily export it to any platform or production level software (in my case, Android and iOS apps) and test them in real time.

But for doing any of those fancy tasks, the first thing to begin with is setting up your development environment for TensorFlow. I have carefully tested every possible scenario and documenting the best and easiest way to setup environment by keeping in view that you will be playing with the state-of-the-art networks.

In order to proceed further, you should be having a Linux based system with Ubuntu 16.04 OS on it. Sorry Windows and Mac users, you can also follow the steps given below but I can’t guarantee any solutions to any problems that might rise during installation. 🙂

  • Install Anaconda: Download Anaconda for Python 3.6 version (64 Bit installer) from this link and follow the instructions on their webpage to install it on your OS. After the whole process is completed you might have to restart your system to check that installation has been successfully completed. Open Terminal and type ‘python’ and check the output:
$ python
Python 3.5.2 |Anaconda 4.2.0 (x86_64)| (default, Jul  2 2016, 17:52:12)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>>
  • The main advantage of Anaconda is that it comes with a list of packages during the time of installation. And we can also create separate working environment for every project that we work so that we can overcome the package version conflict. So let us start creating the environment for our Deep Learning projects. Open terminal and create an environment named ‘dl’ (or you can use any name of your choice). Note: To use TensorFlow you need to use Python 3.5. The speciality of Anaconda is that you can specify your python version for the environment while creating it (even if your anaconda version is Python 3.6)
$ conda create -n dl python=3.5
  • Enter environment and download the necessary packages:
$ source activate dl
(dl)$ conda install pandas matplotlib jupyter notebook scipy scikit-learn
  • If you observe, I didn’t include ‘numpy’ in the list of packages that I installed in the environment. This is because TensorFlow installs the Numpy along with its installation. Now installing TensorFlow is two types. You can either install TensorFlow with CPU support or GPU support. Enter the below command in the terminal to install TensorFlow CPU version:
(dl)$ pip install --upgrade \
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.1.0-cp35-cp35m-linux_x86_64.whl
  • If you want to install TensorFlow GPU version, please make sure that you have the CUDA 8.0 and CuDNN 5.1 setup in your machine along with their environment variables. Then write the following command instead of the above command:
(dl)$ pip install --upgrade \
https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-linux_x86_64.whl
  • With this you will have the system ready for your Machine Learning/Deep Learning development. For Computer Vision + Machine Learning, you might need to install OpenCV package in python. Follow these instructions in case you want to develop computer vision applications using OpenCV and Python.
(dl)$ conda install -c https://conda.binstar.org/menpo opencv3
  • For people who love playing with depth sensors and want to do real-time deep learning, stay tuned to my next blog post on librealsense and Intel Realsense cameras. For starters, if you have already installed librealsense from source, you can integrate inside python using the pyrealsense package. You can easily integrate it in your anaconda environment using the following command.
(dl)$ pip install pyrealsense
  • Finally you can exit from your environment using ‘source deactivate’ and enter it using ‘source activate ‘ commands.

In this blog, you have created your work environment for working on Machine Learning using TensorFlow. In my next series of blogs, I will give you introduction to some basic networks in Computer Vision so that you can learn how to code networks in TensorFlow along with implementing Deep Learning to Computer Vision.

One thought on “TensorFlow Diaries- Intro and Setup

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s