Set up python, tensorflow for image classification

2–3 minutes

read

I started with image classifiation using tensorflow and had no clue about how to start, since no resources are available straight forward, so I am writing this blog.

PC Hardware Setup

First of all to perform machine learning and deep learning on any dataset, the software/program requires a computer system powerful enough to handle the computing power necessary. So the following is required:

  1. Central Processing Unit (CPU) — Intel Core i5 6th Generation processor or higher. An AMD equivalent processor will also be optimal.
  2. RAM — 8 GB minimum, 16 GB or higher is recommended.
  3. Graphics Processing Unit (GPU) — NVIDIA GeForce GTX 960 or higher. AMD GPUs are not able to perform deep learning regardless.
  4. Operating System — Ubuntu or Microsoft Windows 10. I recommend updating Windows 10 to the latest version before proceeding forward.

Step 1: Download Anaconda

In this step, we will download the Anaconda Python package for your platform.

Anaconda is a free and easy-to-use environment for scientific Python.

1.Install Anaconda (Python 3.6 version) Download

Step 2: Install Anaconda

In this step, we will install the Anaconda Python software on our system.

Installation is very easy and quick once you download the setup. Open the setup and follow the wizard instructions.

Step 3: Update Anaconda

Open Anaconda Prompt to type the following command(s). Don’t worry Anaconda Prompt is just works same as cmd.

conda update conda
conda update --all

Step 4: Create an Anaconda Environment

Here we will create a new anaconda environment for our specific usage so that it will not affect the root of Anaconda.
Open Anaconda Prompt to type the following commands.
1. Create a conda environment named “tensorflow” (you can change the name) by invoking the following command:

conda create -n tensorflow pip python=3.6

here tensorflow is the name of the environment.

2. Activate the conda environment by issuing the following command:

conda activate tensorflow

now in terminal before the bash (tensorflow) will be written.

Step 5: Install TensorFlow (including Keras)

Next we will install TenslowFlow in the virtual environment you created with conda. Note: we will be using pip install instead of conda install per the TensorFlow official installation documentation.

#install pip in the virtual environment 
$ conda install pip

# install Tensorflow
$ pip install --upgrade tensorflow

# install Keras (Note: please install TensorFlow first)
$ pip install Keras
After installing TensorFlow you can verify its installation with python in command line:
Invoke python from your shell as follows:

#invoke python from your shell
$ python

# create a simple TensorFlow program inside the python interactive shell

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))

# Exit the python shell Ctrl+D

As all the steps are done, but still u may face a problem which is - 

2017-11-02 01:56:21.698935: C:\//tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2

Now this will be a warning which is given when we are using python 3.9 as there is no binary available for this version so we should make 3.7 or 3.8 python as default-

Current version-

$python

$python3

after checking just do-

alias python='python3'

So now python and python3 will have same version, so make python3 to a low version.

IMPORTANT LINKS – 

https://keras.io/#keras-the-python-deep-learning-library

v imp – https://towardsdatascience.com/setup-an-environment-for-machine-learning-and-deep-learning-with-anaconda-in-windows-5d7134a3db10

https://conda.io/docs/user-guide/getting-started.html

Click to access conda-cheatsheet.pdf

Leave a comment