What do you do when you are new in Italy and unable to determine what kind of pasta is being served to you?
Solutions is simple – Put on your nerd cap and let the machine distinguish it for you!
So what data do we have ? We have data of 4 different kinds of pastas, for each type of pasta we have around 1000 images
Our task is to load the images, convert it into a matrix of numbers (possibly change the shape of the matrix by using some engineering tools) and classify the pastas.
First of all you can download the data from here
The complete code is here
So what do we need to
- First we need to read all the images in python, and to this we need to iterate over the food file
- Once the images are loaded we convert them into numerical matrices (After all they are numeric pixel values that represent a particular color)
- We also shape the data by removing some unnecessary pixel values
- Great so now we have our data – time to split it in train and testing
- Finally we run different kinds of svm models however we cannot exceed 48% accuracy 😦
- But no reason to be upset Artificial neural networks to the rescue
- What are ANN – Artificial neural networks are one of the main tools used in machine learning. As the “neural” part of their name suggests, they are brain-inspired systems which are intended to replicate the way that we humans learn. Neural networks consist of input and output layers, as well as (in most cases) a hidden layer consisting of units that transform the input into something that the output layer can use. They are excellent tools for finding patterns which are far too complex or numerous for a human programmer to extract and teach the machine to recognize.
ANN’s were able to give us 60% accuracy , which is a significant increase from SVM’s.
However in order to boost our accuracy, now we try to convert our images from color to gray scale and try to highlight any particular unique shape or feature of the image. This process is known as Histogram of Gradient.
However this didn’t help us get better results.
One shortcut solution we could have used is to use a pre trained neural network, train it on our data and get better results, like vgg16
So what are you waiting for – Buon Appetito!!!!