This post’s about how to install TensorFlow, numpy, OpenCV and Jupyter to be prepared to run Deep Learning models in a local environment using either python 2.7 or python 3.6.

Miniconda

Miniconda is a package manager that allows creating virtual environments; this enables different python versions and libraries isolated from others. The next link points to the miniconda version for different O.S platforms https://conda.io/miniconda.html. The Mac OS X version it is used in this tutorial. It can be either downloaded by clicking the link on that page or using curl command from Terminal Console in your the system using the URL shown below.

$ curl -O https://repo.continuum.io/miniconda/Miniconda2-latest-MacOSX-x86_64.sh

To start the installation, execute the command below, and follow the instruction you will be asked to read, type either yes or no and press enter.

$ sh Miniconda2-latest-MacOSX-x86_64.sh

The next step is to create a conda virtual environment that will encapsulate the execution of the code, then it only will contain the python version and libraries required to run deep learning models with tensorflow. Your environment will have a name after the -n parameter and the python version also will be defined. Remember to use source activate and source deactivate to enter or quit your virtual environment.

$ conda create -n ml-lab python=3.6
$ source activate ml-lab
(ml-lab) $

The next step is to install libraries that will be used like numpy to matrix operations, OpenCV to load images and return it in numpy equivalent, Jupyter notebook to write and test code, and TensorFlow on version 1.6.

(ml-lab) $ pip install numpy
(ml-lab) $ pip install opencv-python
(ml-lab) $ pip install jupyter
(ml-lab) $ pip install --upgrade \
    https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.6.0-py3-none-any.whl

Validate tools you just installed

Let’s validate if a least Tensorflow will work with the next commands

$ source activate ml-lab
(ml-lab) $ python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> test = tf.Session().run(tf.add(5, 7))
2018-03-09 20:31:58.043920: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
>>> print("This should be 12 ==", test)
This should be 12 == 12
exit()
(ml-lab) $

At this point, you have been installed tested TensorFlow. That’s will you need to start working with Deep Learning models. A post about how to run a plants classifier can be found here https://medium.com/@moisesvargas/deep-learning-inception-in-few-steps-e5340021990c