TensorFlow Flowers

by Gregory Walsh — on  , 

cover-image

Over the majority of my independent study on Machine Learning I have studied TensorFlow Library made by google. While following Josh Gordon’s Machine Learning Recipes series on youtube I discovered TensorFlow for Poets Code Lab which is a neural network designed for image recognition. By following this Google Codelab I was able to successfully create an application that recognizes the difference between daisy, sunflowers, dandelion, roses, tulips using only the trained neural network and a phone camera. I ran into a few hiccups along the way that I will write about below.

I recommend following the guide as it is very well written however it does not go into how to setup your ide and environment for the project. Keep in mind I am using MacOS for my development so if you are running Linux, Windows, or are throwing rocks to make sparks you might need to change accordingly. I used conda (Anacondas Package Manager) to create a python environment for the application.

It is recommended to use either Docker containers or python virtual environments for projects like this. In order to create the python environment for TensorFlow I ran the following command in terminal:

conda create -n tensorflow_env TensorFlow 

This will create a python environment with the base level packages needed including TensorFlow. From there all you have to do is activate the python environment in your terminal session:

conda activate tensorflow_env

Now we are in the activated python environment so any scripts for the TensorFlow guide that need specific imports will be able to run with no problems.

Other than that, I was successfully able to create a neural network to identify the flowers. I will attach a few screenshots below of the application identifying the flowers:

Roses:



Tulips:



Sunflowers:

How does this work you might be asking? Basically, a bunch of images was passed into googles inception engine to looks specifically for flowers. After extensive training and testing the image classifier gets almost perfect results on flowers. The really cool thing with inception is you can use it as a base and train your own image classifier to identify any object as long as you have enough pictures to pass into the training.

On a final and hilarious note. I’ve been going around and seeing what kind of flowers my friends are :)