Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

How To Build a Digit Classifier In Tensorflow

how to build a digit classifier

MNIST – Modified National Institute of Standards and Technology is the crucible of a comprehensive computer vision database. Since its release in 1999, MNIST’s classic dataset of handwritten pictures has been accepted as the foundation for benchmarking classification algorithms.

Image source <a href=httpswwwresearchgatenetfigureImages generated by different GAN architectures trained on MNIST 1 and MNIST 2 The fig1 331152942>researchgatenet<a>

Most of the time, learners start by classifying digits given by MNIST. So, today we will also start by classifying the digits using IDE Software with TensorFlow.

What you can learn from this tutorial?

What is MNIST?

It is a dataset of 60,000 small square 28×28 pixel grayscale images of handwritten single digits within 0 and 9. Since it has been around for more than two decades, various top-performing models are deep learning convolutional neural networks that achieve a classification accuracy of above 99 percent. 

How to recognize the hand-drawn numbers in an image?

TensorFlow is an open-source library developed by the Google Brain labs for deep learning research. Since there are already trained models for detecting objects, patterns, and more. It is easy to load the model and give inputs to it to get high results. Because you might need some time to train a new model for your project.

What is the TensorFlow Lite Model?

TensorFlow Lite model has given in a peculiar efficient portable format known as “FlatBuffers”. This TensorFlow Lite model is a collection of tools that enables on-device machine learning by assisting developers to run their models.

You can learn about TensorFlow Lite Model here.

For more posts on this blog about machine learning and TensorFlow click the following dynamic search link: https://blogs.embarcadero.com/?s=tensorflow

How to use TensorFlow with Delphi?

Well, we thanks to our wonderful community of Delphi and C++ developers TensorFlow Lite is available for Delphi right now. Go to the following link to the TensorFlow Lite Model for Delphi repository.

The TFLITE dynamic link library helps you to utilize TensorFlow Lite model functions. It contains common enums, types, and methods used throughout TensorFlow Lite. This includes everything from error codes, to the kernel and delegate APIs.

You can head over and download the entire project to test it. As you can see, you can draw a number and, the TensorFlow gets the data as a 28×28 pixel image which it translates and returns as a number from 0 to 9.

To reproduce the actual images, the input which is 28×28 pixels is flattened into a 1D vector 784 pixels in size. So, each of the 784 pixels delivering up the image is stored as a value within 0 and 255.. This can help to determine the grayscale of the pixel because our images are presented in black and white. A black pixel in the input image is expressed by 255, and a white pixel in the image is described by 0.

[crayon-6767c6def3bc9176052524/]

Head on over to the following link to download the example code and try it for yourself: https://github.com/qq33095304/TensorFlow-Lite-Delphi


RAD Studio Delphi is a fast and efficient environment for creating robust applications which work natively on all platforms including Windows, macOS, Linux, iOS and Android. Why not download a free trial today and meet your customer’s needs no matter what device they choose to use?

Exit mobile version