Tuesday, April 18, 2023

Installing TensorFlow on Pop!_OS using Tensorman

Pop!_OS allows easy installation and management of Tensorflow using 'tensorman'.

Installing TensorFlow on Pop!_OS using Tensorman
Installing TensorFlow on Pop!_OS using Tensorman

First, make sure you have all the updates installed:

sudo apt update
sudo apt full-upgrade

Then, install the tensorman package:

sudo apt install tensorman

 In order to get Nvidia CUDA support, install the nvidia docker package:

sudo apt install nvidia-docker2

Thursday, October 8, 2020

Accuracy of Deep Learning Models Over the Years

Over the years, there were many achievements in deep learning, many of which were directly related to the ImageNet Large Scale Visual Recognition Challenge (ILSVRC, or ImageNet challenge for short). We talked about some of those milestones in deep learning in the past and how their unique innovations have helped shape the deep learning landscape today.

Today let us look at how the accuracy of these significant models has increased over the years.

Deep Learning Models Over the Years
Deep Learning Models Over the Years


When reporting the accuracy of classification models two accuracy measures are typically used: Top-1 Accuracy, and Top-5 Accuracy.
  • Top-1 Accuracy - Where the highest probability/confidence prediction from the model matches the expected class
  • Top-5 Accuracy - Where the expected class is within the top 5 predictions of the model

Thursday, October 1, 2020

Pre-orders are Now Open for Deep Learning on Windows

Pre-orders for my new book, Deep Learning on Windows, are Now Open at Amazon.com!

Deep Learning on Windows is my latest book, and it is the longest and the most comprehensive book I have written to date. The book is meant for both beginners and intermediates to deep learning. It covers topics from setting up your tools on Windows and getting started, to complex but fun topics in deep learning and computer vision.

The Cover of 'Deep Learning on Windows'
The Cover of 'Deep Learning on Windows'



The Windows OS accounts for over 70% of the desktop PC usage. Windows provides many conveniences, with a wide variety of available productivity tools, causing it to gather a large userbase. This means that there is a large percentage of you - AI enthusiasts and developers - out there that primarily work on the Windows OS, and would prefer to develop deep learning models on Windows itself.

Tuesday, September 22, 2020

Using model.fit() instead of fit_generator() with Data Generators - TF.Keras

If you have been using data generators in Keras, such as ImageDataGenerator for augment and load the input data, then you would be familiar with the using the *_generator() methods (fit_generator(), evaluate_generator(), etc.) to pass the generators when trainning the model. 

But recently, if you have switched to TensorFlow 2.1 or later (and tf.keras), you might have been getting a warning message such as,

Model.fit_generator (from tensorflow.python.keras.engine.training) is deprecated and will be removed in a future version.
Instructions for updating:
Please use Model.fit, which supports generators.

Or,

Model.evaluate_generator (from tensorflow.python.keras.engine.training) is deprecated and will be removed in a future version.
Instructions for updating:
Please use Model.evaluate, which supports generators.


fit_generator() Deprecation Warning
fit_generator() Deprecation Warning

This is because in tf.keras, as well as the latest version of multi-backend Keras, the model.fit() function can take generators as well. 

Wednesday, September 16, 2020

Major Update on My New Book: Deep Learning on Windows

If you recall, I originally intended to incrementally release my new book - Deep Learning on Windows – and have it completed around the June/July timeframe. Well, the month of July came and went, but no book got released. I also was not posting articles in the blog frequently for the past couple of months.

This was due to a major change in the plan for the book.

Deep Learning on Windows was picked up by a publisher!

The book will now be published under Apress, and it became a much larger offering than what I initially envisioned.

The new cover for the book is shown below:

New Cover for Deep Learning on Windows
New Cover for Deep Learning on Windows


On late-May, while I was working on the first drafts of the book on LeanPub, I was contacted by Apress on whether I would be interested in publishing the book under Apress banner. 

Sunday, May 10, 2020

Easy Text-to-Speech in Windows 10 Using PyWin32

Some time back, we've talked about how to build a speech recognition system in Python. Now let's look in to the other end of it: how to make a Python program that talks. More specifically, let's looks at building a text-to-speech system.

There are several libraries out there that would let you build a text-to-speech model: gTTS, tts_watson, Pyttsx, etc. But today, we'll be talking about using PyWin32 on Windows 10.

Windows 10 has a built-in speech engine, and you can access it through the PyWin32 library. As it uses the built-in system, it's quite efficient than other TTS methods on Windows, and does not require any external tools to playback the audio.

The PyWin32 library gets installed automatically if you're using Anaconda Python. If it's not installed, you can install it using either `conda install pywin32` or `pip install pywin32`.

Text-to-speech with PyWin32
Text-to-speech with PyWin32


Tuesday, April 21, 2020

Book Update: First 3 Chapters are Now Released!

I'm excited to let you know that the first 3 Chapters of my new book - Deep Learning on Windows - is now released at LeanPub!

Deep Learning on Windows - Cover
Deep Learning on Windows

This is currently the only book focusing specifically on setting up and developing Deep Learning models on Microsoft Windows. As I mentioned in my earlier post, most of the queries and questions I have received over the past year or so were related to building deep learning models on the Windows OS, and how-to setup and troubleshoot the tools on it. There were very little material out there addressing Windows specifically.

So, this book is my answer to that.

A total of 12 chapters are planned for the book, covering topics from setting up your tools on Windows, building your first models, to some advanced topics like transfer learning, deploying your models, computer vision, generative adversarial networks, and reinforcement learning.

The book will be released in an incremental manner. The first 3 chapters are now released.
Buying the book now guarantees that you will get all the remaining content, and all future updates and revisions for free as they get released.

The price of the book will increase over time as new chapters gets added, so purchasing early gives you the best value.

Tuesday, April 7, 2020

My New Book is in the works: Deep Learning on Windows

Hope you all are staying safe!

With the lockdown and working from home from my job I've had a bit of free time these past few days. I've spent some of that time on going through the comments of the blog, and the questions and queries I have received from you readers through email and social media channels.

What I was trying to do was to identify any major areas you are struggling in, and try to come up with solutions to address those areas.

What I found was that, most of the queries were related to building deep learning models on the Windows OS, and how-to setup and troubleshoot the tools on it.

So, as a means of addressing this area, I've decided to start writing a new book, which will be named "Deep Learning on Windows".

"Working" Cover Page of the New Book
"Working" Cover Page of the New Book (cover would change in the final version)

Materials and support for setting up deep learning frameworks and building models on Windows is a little bit scarce out there. This is mainly because native support for Windows in many of the popular tools were not there until recently.

This is why I decided to write a book specifically on getting deep learning development started on Windows.

Thursday, March 19, 2020

Stay Safe During the COVID-19 Outbreak

Dear Readers of Codes of Interest,

Hope you, your family and loved ones are staying safe in these troubling times.

Being a globally impacting event, the COVID-19 pandemic has caused disruptions in many of our lives. Some more than others.

And, no doubt most of you have been forced to take a break from your daily routines and remain isolated from others.

SARS-CoV-2
SARS-CoV-2

While we all understand the importance of social distancing, the severity of the situation and the isolation is surely causing stress and uneasiness in all of us.

In order to attempt to provide a way to positively distract you from the stress, I have thought of giving away the kindle version of my book for free. Hopefully, this would allow you to have something to read and do while we wait for this pandemic to settle down.

The kindle eBook will be available via Amazon: https://www.amazon.com/dp/B07MY5Y643
It will be free until Monday, March 23, 2020, 11:59 PM PDT.

Stay safe during these troubling times

Wednesday, January 1, 2020

Fixing the KeyError: 'acc' and KeyError: 'val_acc' Errors in Keras 2.3.x

Have you been using the 'History' object returned by the fit() functions of Keras to graph or visualize the training history of your models? And have you been getting a 'KeyError' type error such as the following since recent Keras upgrade and wondering why?


Traceback (most recent call last):
  File "lenet_mnist_keras.py", line 163, in <module>
    graph_training_history(history)
  File "lenet_mnist_keras.py", line 87, in graph_training_history
    plt.plot(history.history['acc'])
KeyError: 'acc'

The KeyError: 'acc' when attempting to read the history object
The KeyError: 'acc' when attempting to read the history object


Traceback (most recent call last):
  File "lenet_mnist_keras.py", line 163, in <module>
    graph_training_history(history)
  File "lenet_mnist_keras.py", line 88, in graph_training_history
    plt.plot(history.history['val_acc'])
KeyError: 'val_acc'

The KeyError: 'val_acc' when attempting to read the history object
The KeyError: 'val_acc' when attempting to read the history object

Well, this is due to a breaking change introduced in Keras release 2.3.0.

Sunday, December 29, 2019

How to Install TensorFlow 2.0 on Anaconda (with CUDA support)

TensorFlow 2.0 has been released for a few months now. This latest version comes with many new features and improvements, such as eager execution, multi-GPU support, tighter Keras integration, and new deployment options such as TensorFlow Serving.

So, it's time we all switched to TensorFlow 2.0.

TensorFlow 2.0


The Anaconda-native TensorFlow 2.0 packages are now available in the main conda repository. So, let's see how we can install TensorFlow 2.0 on Anaconda Python. This method will work on both Windows and Linux. And, if you have a CUDA capable NVIDIA GPU, you can enable GPU support as well.

Step 1.Creating a New Conda Environment


We'll start by creating a new conda environment. (I'll name it 'tensorflow2'. You can choose another name if you like):

conda create --name tensorflow2 python=3.7 anaconda


Create a new conda environment
Create a new conda environment

Monday, December 16, 2019

How to Build and Install the Latest Version of Dlib on Anaconda on Windows

Dlib is a toolkit for C++ and Python containing machine learning algorithms and tools for creating complex software to solve real world problems. Dlib provides algorithms for machine learning/deep learning, multi-class classification and clustering models, support vector machines, regression models, a large set of numerical algorithms for areas such as matrix manipulations and linear algebra, graphical model inference algorithms, and utility algorithms for computer vision and image processing. And due to C++ implementations backing most of these implementations, they’re optimized to the point that can be used in some real-time applications as well.

If you’re interested in facial recognition models or facial emotion processing, then Dlib is a library you should definitely try out.

Dlib v19.19 in action on conda on Windows
Dlib v19.19 in action on conda on Windows

But with all the great features in Dlib, installing it has always been a little bit troublesome because of some specific dependency requirements it needs which had a habit of almost always conflicting with your other libraries. With the latest versions however, installing Dlib has become somewhat simple.

If you’re using Anaconda Python for your python experiments, like me, you’ll find that there is no native Dlib package in the native conda package list. In one of my earlier tutorials I showed how to install the Dlib conda package from the conda-forge channel in to your conda environment. The conda-force package works perfectly fine, and it’s still one of the quickest ways to install Dlib.

But if you really want the latest official package of Dlib installed (v19.19 as the latest at the time of this writing) then using the pip package is the way to go. In order to install the Dlib pip package you’ll first have to setup some dependencies.

Monday, December 9, 2019

Deep Learning, AI/ML, Computer Vision, and Data Science Gift Buying Guide - 2019

It’s the holiday season! This is the season of the year we like to celebrate the most. And it is the part of the year that we'd like to give, and receive, gifts.

While it's easy to pick a gift (relatively speaking) for some people, the interests of some others might make it hard nail down a gift for. (Take an AI, ML, Data Science and programming enthusiast like me for an example)

Now, you might have a family member, colleague, or a friend that is into AI, Deep Learning, and Machine Learning. Or, they might be working on or interested in Data Science or Computer Vision. You might be wondering what sort of gifts to get them.

Or simply as an enthusiast in those areas yourself, you're thinking of buying a gift for yourself this season. (I know that I’m thinking the same)

So, how do you select a gift for someone with interest in such vast and technical fields?

Well today I’m going to give you some gift ideas that just might work.

AI, ML, Deep Learning, Computer Vision, and Data Science Gift Guide 2019


When thinking of gifts relating to the AI/ML, CV, Data Science fields, we can consider three categories of gifts,

  1. Items to Improve their ability to perform tasks in those areas
  2. Give them new tech toys to play around in those areas
  3. Help them improve their knowledge in those areas

Let’s see what items we can select for each of those categories.


Tuesday, October 1, 2019

TensorFlow 2.0 Released!

After months in the Alpha state, Google has now released the final stable version of TensorFlow 2.0.
TensorFlow 2.0 aims at providing a easy to use yet flexible and powerful machine learning platform.

TensorFlow 2.0 Logo

The new version also hopes to simplify deployment of TF models to any platform by standardizing the model formats. You will be able to run TensorFlow models on a variety of runtimes, such as using TensorFlow Serving - a flexible, high-performance serving system for machine learning models, designed for production environments -, on browser or through Node.js using TensorFlow.js, and on mobile through TensorFlow Lite.

Sunday, June 16, 2019

Bird Watch: Our First Public Deep Learning Computer Vision Product

Codes of Interest is proud to present Bird Watch, a Deep Learning Computer Vision tool to identify bird species from images. It was built for wildlife photographers, bird and nature lovers, researchers, and academics alike.

Bird Watch is now in v0.3.0 Beta and is available for anyone to use free of charge at,


Bird Watch in action
Bird Watch in action

The system was built using transfer learning, with the InceptionV3 model. It uses Keras, TensorFlow, and OpenCV for its underlying features. The web frontend is built using Flask.

Monday, May 20, 2019

Installing OpenCV got easier

OpenCV is undoubtedly the unmatched de facto standard library for computer vision. Not only does it provide a near complete set of vision algorithms, the set of primitive graphics functions it provides to manipulate images makes it essential to many of our projects.

OpenCV being used when building a Keras CNN model
OpenCV being used when building a Keras CNN model

Installing the latest version of OpenCV used to be hard. The pre-built binaries available was never up to the tasks we wanted. Compiling from source was an option, but was tedious and time consuming.

Then, we got the anaconda versions of OpenCV from Conda-Forge, which we could simply install using,

conda install -c conda-forge opencv

Now, things are going to be simpler, as Anaconda native OpenCV packages are now available.

Tuesday, January 8, 2019

Build Deeper: What's in the Book

We're just 1 day away from the release of my new book Build Deeper: The Path to Deep Learning. So, let's see what I've covered in the book.

Build Deeper: The Path to Deep Learning
Build Deeper: The Path to Deep Learning


The new book is the successor to my earlier book - Build Deeper: Deep Learning Beginners' Guide - (which is why I called this the 'second edition), to which I've added a lot more topics this time. The new book is more than twice the length of the old book, and covers more breadth and depth in Deep Learning.

Here's what you can expect in the book:

Wednesday, January 2, 2019

Happy New Year, with a New Book

2019 is here! Happy New Year everyone!
May we see more exciting development in AI, Machine Learning, and Deep Learning this year.

With this new year, I'm excited to make a new announcement.
My new book "Build Deeper: The Path to Deep Learning" is now completed, and will be releasing very soon.

Build Deeper: The Path to Deep Learning

It's the successor for my earlier book "Build Deeper: Deep Learning Beginners' Guide", and covers everything from an introduction to deep learning, to building your own image recognition and computer vision models from scratch, and advanced topics such as transfer learning and fine-tuning your models, with sample code and step-by-step instructions for everything.

The book will be released within next 2 weeks. Stay tuned for more details.



Thursday, November 22, 2018

Installing the New Anaconda Native TensorFlow Package

For a while now, the most reliable two ways to get TensorFlow installed is to either use the pip package, or compile from source.
Compiling TensorFlow from source takes hours, and still prone to errors (see "Failed Attempts at Building TensorFlow GPU from Source"). While the pip package is relatively easier, getting the GPU version of TensorFlow installed using pip was a hassle.

But not anymore. Because the conda native TensorFlow packages are here now.

Installing is quite easy.

Note: Don't install the pip and conda versions of TensorFlow on the same conda environment. If you already have the pip version installed uninstall it using,

pip uninstall tensorflow


To install the CPU version of TensorFlow, just run,

conda install tensorflow


To install the GPU version,

conda install tensorflow-gpu


Saturday, September 1, 2018

Using Multiple Cameras with OpenCV

As you know, OpenCV is capable of reading from any connected camera in your system, whether it's a built-in webcam (in a laptop) or a USB connected one.

But what if, you wanted to read from more than one cam at the same time?

Can OpenCV handle it?

OpenCV accessing 2 cameras at once
OpenCV accessing 2 cameras at once


Yes, it can!

It's quite simple. Here's how to do it.