Build Silicon Valley’s Hotdog Detector With C# And CNTK
In the TV show Silicon Valley there’s a famous scene where Jian-Yang demonstrates the SeeFood app that can identify any kind of food in an image.
Of course, this being Silicon Valley, there’s a catch: the app can only identify hotdogs and classifies everything else as ‘not hotdog’.
Watch the full clip below:
In this article I am going to build this same app which must be able to identify hotdogs in any image.
The easiest way to do this is to build a convolutional neural network and train it on a dataset of hotdog and not-hotdog images. The Kaggle Hotdog dataset has exactly what I need.
I’ll download the archive and create hotdog and nothotdog folders in the project folder that I’m going to create below.
Here’s what the hotdog set looks like:
These are 499 pictures of hotdogs. I also have a second set with 499 images of food that isn’t a hotdog:
I will need to train a neural network on these image sets and get the hotdog detection accuracy as high as possible.
Let’s get started. I need to build a new application from scratch by opening a terminal and creating a new NET Core console project:
$ dotnet new console -o HotdogNotHotdog
$ cd HotdogNotHotdog
I will copy the two dataset folders hotdog and nothotdog into this folder because the code I’m about to type next will expect it here.
Now I will install the following packages:
$ dotnet add package CNTK.GPU
$ dotnet add package XPlot.Plotly
$ dotnet add package Fsharp.Core