DelphiLearn PythonPythonPython GUIRAD StudioWindows

This Is How To Make A Deep Learning Computer Vision App

blogbanner gluoncv

Are you looking for the easiest way to implement Deep Learning for Computer Vision and build a nice GUI for them, and all of them are free? You can deliver end-to-end Deep Learning for Computer Vision solutions easily by combining GluonCV and Python4Delphi library, inside your Delphi or C++Builder IDE software.

This post will guide you on how to run the GluonCV library and use Python for Delphi to display it in the Delphi Windows GUI app.

What is the GluonCV library?

This Is How To Make A Deep Learning Computer Vision App The Gluon Logo

GluonCV provides implementations of state-of-the-art (SOTA) deep learning algorithms in computer vision. It aims to help engineers, researchers, and students quickly prototype products, validate new ideas, and learn computer vision.

It features training scripts that reproduce SOTA results reported in the latest papers, a large set of pre-trained models, carefully designed APIs, and easy-to-understand implementations and community support. 

Why use GluonCV and what makes it so powerful?

GluonCV embraces a flexible development pattern, while it is also super easy to optimize and deploy without retaining a  heavyweight deep learning framework.

Here is a quick overview of why GluonCV can create powerful solutions to your application’s needs:

  1. Supporting powerful applications for: Image classification, object detection, semantic segmentation, instance segmentation, pose estimation, and action recognition.
  2. Massive: More than 170+ high-quality pre-trained models. 
  3. Powerful: CUDNN; DNNL optimized, distributed training with Horovod, DALI data loader.
  4. Lightweight: Compact, modular, minimal dependencies.
  5. Flexible: Develop in Python, customizable, easy to debug.
  6. Deploy Friendly: Export to non-python, static graph, VNNI acceleration, mobile-optimized.

 

How do I enable GluonCV inside Python4Delphi in Windows?

First, open and run our Python GUI using project Demo1 from Python4Delphi with RAD Studio. Then insert the script into the lower Memo, click the Execute button, and get the result in the upper Memo. You can find the Demo1 source on GitHub. The behind the scene details of how Delphi manages to run your Python code in this amazing Python GUI can be found at this link.

This Is How To Make A Deep Learning Computer Vision App Showing GluonCV inside the IDE software
Open Demo01dproj

The next step is installing GluonCV into your system. Here is how you can get GluonCV using pip for stable release:

Note: If you don’t have MXNet installed, please install it first using pip install mxnet or using the pip command as described above.

Or read more about MXNet here:

In this post we will demonstrate how to get started with Image Classification using GluonCV, using a pre-trained model on CIFAR10. We will demonstrate how to load a pre-trained model from gluoncv-model-zoo and classify images from the Internet or your local disk.

This Is How To Make A Deep Learning Computer Vision App The model image dataset displayed
CIFAR10 Sample Images

CIFAR10 is a dataset of tiny (32×32) images with labels, collected by Alex Krizhevsky, Vinod Nair, and Geoffrey Hinton. CIFAR10 is widely used as a benchmark in computer vision research.

 

How do I download and show the example image inside Python4Delphi in Windows using GluonCV?

By running the following script inside Python4Delphi, you will download and show the example image:

Let’s see the result in our Python GUI:

This Is How To Make A Deep Learning Computer Vision App Is it a bird is it a plane
GluonCV Demo with Python4Delphi in Windows

The output is a poorly-drawn airplane, which we will try to classify using the pre-trained model. 

How do I perform image transformation using GluonCV?

Next, we define transformations for the image that will perform the following things:

  1. Resize and crop the image to 32×32 in size, 
  2. transpose it to num_channels*height*width, and 
  3. normalize with mean and standard deviation calculated across all CIFAR10 images.

How does the transformed image look like in the Python GUI?

This Is How To Make A Deep Learning Computer Vision AppAn array of pixels
GluonCV Demo with Python4Delphi in Windows

The image transformation makes the image more “model-friendly”, instead of “human-friendly”. 

How do I load a pre-trained model, prepare the image, and feed it to the model using GluonCV?

Next, we load a pre-trained model, prepare the image, and finally feed it to the model:

What does the output look like in the Python GUI?

This Is How To Make A Deep Learning Computer Vision App Results in the terminal output
GluonCV Image Classification Result inside Python4Delphi on Windows

It shows the classification result correctly! The input picture is classified as an airplane, with a probability of 0.393.

Check out the full source code here!

Congratulations, now you have learned how to run the GluonCV library using Python for Delphi to display it in the Delphi Windows GUI app! Now you can solve various real-world problems using the ultra-scalable deep learning framework created by the GluonCV framework and Python4Delphi.

 

Where can I find more examples of building GUI for Artificial Intelligence, Deep Learning, or Computer Vision libraries?

Check out the GluonCV deep learning framework for Python and use it in your projects: 

https://cv.gluon.ai/install.html or https://pypi.org/project/gluoncv/, and

Check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi: https://github.com/pyscripter/python4delphi

Or read our collections of AI/DL/CV-related articles:

MXNet:

OpenCV:

Keras: 

TensorFlow: 

PyTorch: 

Face Recognition:

Theano: 

10 Ultimate Python AI Libraries:

Related posts
CodeIDELearn PythonPythonPython GUITkinter

How To Make More Than 20 ChatGPT Prompts Work With Python GUI Builders And OpenCV Library?

CodeIDEProjectsPythonWindows

Unlock the Power of Python for Deep Learning with Radial Basis Function Networks (RBFNs)

CodeIDELearn PythonPythonPython GUITkinter

How To Make More Than 20 ChatGPT Prompts Work With Python GUI Builders And NumPy Library?

CodeIDEProjectsPythonWindows

Unlock the Power of Python for Deep Learning with Generative Adversarial Networks (GANs) - The Engine behind DALL-E

Leave a Reply

Your email address will not be published. Required fields are marked *