In the very popular show Silicon Valley, one of my favorite characters Jian Yang creates a Deep learning application which accurately predicts if a food item is a hot dog or not, pretty funny stuff, So I thought of using google’s open source TensorFlow library to create my very own Hot dog classification program.

So without further chit chat let’s start classifying some hotdogs.

For this project I’ve used :

Tensorflow(DUH),

Docker,

Google Images,

Fatkun Image downloader extension for chrome.

First we have to set up docker, since I’m using debian it was pretty straight forward.

You can find plenty of info on how to set up docker over here, https://www.docker.com/community-edition

Downloading the TensorFlow Image for docker :

docker run -it tensorflow/tensorflow:1.1.0 bash

We create a directory for all the source code and image datasets :

mkdir tf_files

Let’s launch that docker instance shall we :

docker run -it \

--publish 6006:6006 \

--volume ${HOME}/tf_files:/tf_files \

--workdir /tf_files \

tensorflow/tensorflow:1.1.0 bash

Since we’re classifying if an article is a hotdog or not, we’re going to need 1 folder and 2 subfolders, the main folder is going to be called images and within that folder we will create 2 subfolders named hotdogs and random.

mkdir images

cd images

mkdir hotdogs

mkdir random

cd ../

Now we need around 100 images of hotdogs in the hotdogs folder and 100 random images of things that aren’t hotdogs, I used Fatkun image downloader from chrome extension store for this purpose, but a point to be noted is that TensorFlow only handles JPEG images and using PNG’s can run you into a lot of trouble, after you’re done populating the directories with images of hotdogs and random things in their respective folders we have to download and retrain the Inception V3 net by google, since we don’t have the required time nor resources to train our own CNN.

curl -O https://raw.githubusercontent.com/tensorflow/tensorflow/r1.1/tensorflow/examples/image_retraining/retrain.py

After download the retrain.py file we go on forward to start training on our own models :

python retrain.py \

--bottleneck_dir=bottlenecks \

--model_dir=inception \

--summaries_dir=training_summaries/long \

--output_graph=retrained_graph.pb \

--output_labels=retrained_labels.txt \

--image_dir=images

That is gonna take a while depending on your machine, so let it run. After it is done we can use a simple python script to actually predict if a supplied image is a hotdog or not, download this script using this command :

We’ve made our very own image classifier in less than 10 minutes, let’s check it out shall we!

So we run the script on a sample hotdog image :

It is pretty clear that the supplied image was a hotdog!

Now let’s input something which isn’t a hotdog :

From that it’s pretty clear that it isn’t a hotdog!

There you have it folks your very own hot dog classifier in less than 10 minutes, for the complete source here’s the link : https://github.com/Fazelesswhite/Hotdog-Classification