Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
DelphiRAD Studio

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.

How To Build a Digit Classifier In Tensorflow - digits
Image source: researchgate.net

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

What you can learn from this tutorial?

  • Computer vision fundamentals including simple neural networks
  • Classification methods

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?

How To Build a Digit Classifier In Tensorflow - tflite.dll image

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.

How To Build a Digit Classifier In Tensorflow - array of inputs

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.

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?


What's New for RAD Studio 11

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

Software Developer | B.Tech-CSE at AUT | Delphi/C++ Builder Enthusiast | Microsoft Learn Student Ambassador | Microsoft Azure Certified | Udacity Alumni
Related posts
NewsWhitepaper

The Pros And Cons Of Artificial Intelligence

C++DelphiNewsRAD StudioWhitepaper

A Beginner’s Guide to Artificial Intelligence

C++Code

What You Need For C++ Artificial Intelligence Step By Step

C++Delphi

Artificial Intelligence: Expectations vs. Reality

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES