CodeDelphiPythonPython GUIRAD StudioWindows

Learn To Build A GUI For These 10 Ultimate Python AI Libraries

Learn To Build A GUI For These 10 Ultimate Python AI Libraries

Table of Contents

What is Artificial Intelligence?

In this post, you’ll learn more about Artificial Intelligence (AI) which has a wide-ranging branch of computer science concerned with building smart machines capable of performing tasks that typically require human intelligence. Understanding how Artificial Intelligence works will enable you to create GUIs with Python Windows GUI Builder with ease.

Why is Artificial Intelligence important?

AI is important because it can give enterprises insights into their operations that they may not have been aware of previously. And more importantly, in some cases, AI can perform tasks better than humans.

AI tools often complete jobs quickly and with relatively few errors when it comes to repetitive, detail-oriented tasks like analyzing large numbers of documents to gain insights, make decisions, risk management, and complete specific tasks or actions.

Relation between Artificial Intelligence, Machine Learning, Neural Networks, and Deep Learning?

Here is a good analogy created by IBM [1]:

“Perhaps the easiest way to think about Artificial Intelligence, Machine Learning, Neural Networks, and Deep Learning is to think of them like Russian nesting dolls. Each is essentially a component of the prior term.”

Learn To Build A GUI For These 10 Ultimate Python AI Libraries Russian dolls
Image Source Reference 1

Or, in other words: Machine Learning is a subfield of Artificial Intelligence. Deep Learning is a subfield of Machine Learning, and Neural Networks make up the backbone of Deep Learning algorithms. The number of node layers, or depth, of neural networks that distinguishes a single neural network from a deep learning algorithm, which must have more than three.

Why use Python for AI?

AI requires a foundation of specialized hardware and software for writing and training Machine Learning algorithms. No one programming language is synonymous with AI, but a few, including Python, R and Java, are popular.

In this article, we will limit our tutorial only for implementation of Python for AI/ML. The reason why Python implementations are so popular, because of its easy to use, popular, mature, and community supported AI/ML libraries.  

Learn To Build A GUI For These 10 Ultimate Python AI Libraries keyboard
AI for All Image Credit rahulp9800 from Pexels

Delphi adds Powerful GUI features and functionalities to Python

In this tutorial, we’ll build Windows Apps with extensive AI capabilities by integrating Python’s AI libraries with Embarcadero’s Delphi, using Python4Delphi (P4D).

P4D empowers Python users with Delphi’s award-winning VCL functionalities for Windows which enables us to build native Windows apps 5x faster. This integration enables us to create a modern GUI with Windows 10 looks and responsive controls for our Python for AI applications. Python4Delphi also comes with an extensive range of demos, use cases, and tutorials.

We’re going to cover the following…

How to use Keras, TensorFlow, scikit-learn, PyTorch, NLTK, Gensim, OpenCV, EasyOCR, Seaborn, and Bokeh Python libraries for Artificial Intelligence

All of them would be integrated with Python4Delphi to create Windows Apps with AI capabilities.

Prerequisites 

Before we begin to work, download and install the latest Python for your platform. Follow the Python4Delphi installation instructions mentioned here. Alternatively, you can check out the easy instructions found in the Getting Started With Python4Delphi video by Jim McKeeth.

How do I get started building with Python GUI?

First, open and run our Python GUI using project Demo01 from Python4Delphi with RAD Studio. Then insert the script into the lower Memo, click the Execute script button, and get the result in the upper Memo. You can find the Demo01 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.

Learn To Build A GUI For These 10 Ultimate Python AI Libraries
Open Demo01dproj

1. How can I build an AI solution with Keras?

Keras is a high-level neural networks API for Python. Keras acts as an interface for the TensorFlow library. As a central part of the tightly connected TensorFlow 2.0 ecosystem, Keras is covering every step of the Machine Learning workflow, from data management to hyperparameter training to deployment solutions.

Keras is designed for human beings, not machines. Keras follows best practices for reducing cognitive load: It offers consistent and simple APIs, minimizes the number of user actions required for common use cases, and it provides clear and actionable error messages.

Its popularity? You don’t need to worry! Keras has extensive documentation and developer guides and is also the most used deep learning framework among the top-5 winning teams on Kaggle. Keras was also the 10th most cited tool in the KDnuggets 2018 software poll and registered a 22% usage. Keras is used by CERN, NASA, NIH, and many more scientific organizations around the world (and yes, Keras is used at the LHC).

Are you looking for a simple, flexible, and powerful deep learning library, and build a nice GUI for them? You can deliver enterprise-grade AI solutions easily by combining Keras and Python4Delphi library, inside Delphi and C++Builder.

First, here is how you can get keras:

The following is a code example of keras to prepare and visualize the famous Kaggle’s Cats vs Dogs dataset for Deep Learning (run this inside the lower Memo of Python4Delphi Demo01 GUI):

What does the final keras result look like in Python GUI?

Learn To Build A GUI For These 10 Ultimate Python AI Libraries all the dogs
Keras Demo with Python4Delphi in Windows

Read more:

Watch the demo here:

2. How can I build AI platforms with TensorFlow?

TensorFlow is an open-source software library for high-performance numerical computation. Its flexible architecture allows easy deployment of computation across a variety of platforms (CPUs, GPUs, TPUs), and from desktops to clusters of servers to mobile and edge devices.

Originally developed by researchers and engineers from the Google Brain team within Google’s AI organization, it comes with strong support for machine learning and deep learning and the flexible numerical computation core is used across many other scientific domains.

First, here is how you can get tensorflow:

These are the script to train your first neural networks in Python GUI by Python4Delphi:

What does the tensorflow example look like in the Python GUI?

Learn To Build A GUI For These 10 Ultimate Python AI Libraries results
TensorFlow Demo with Python4Delphi in Windows

Read more:

Watch the demo here:

3. How do I build GUI for collections of ML algorithms with scikit-learn?

scikit-learn is an open-source Python library for Machine Learning. Scikit-Learn has simple and efficient tools for predictive data analysis that are built on top of SciPy, NumPy, and Matplotlib.

scikit-Learn features various classification, regression, and clustering algorithms including support vector machines, random forests, gradient boosting, k-means, and DBSCAN.

First, here is how you can get scikit-learn:

The following is a code example of sklearn to  compare several classifiers in scikit-learn on synthetic datasets (run this inside the lower Memo of Python4Delphi Demo01 GUI):

What does the sklearn classifier comparisons result look like?

Learn To Build A GUI For These 10 Ultimate Python AI Libraries Sci Kit comparisons
scikit learn Demo with Python4Delphi in Windows

Read more:

4. How do I perform advanced machine learning (ML) with PyTorch?

PyTorch is an open-source machine learning library based on the Torch library, used for applications such as computer vision and natural language processing, primarily developed by Facebook’s AI Research lab (FAIR). It is free and open-source software released under the Modified BSD license. Although the Python interface is more polished and the primary focus of development, PyTorch also has a C++ interface.

Many pieces of deep learning software are built on top of PyTorch, including Tesla Autopilot, Uber’s Pyro, HuggingFace’s Transformers, PyTorch Lightning, and Catalyst.

PyTorch provides two high-level features:

  • Tensor computing (like NumPy) with strong acceleration via graphics processing units (GPU)
  • Deep neural networks built on a tape-based automatic differentiation system

You can reuse your favorite Python packages such as NumPy, SciPy, and Cython to extend PyTorch when needed.

First, here is how you can get pytorch:

Let’s try to load and visualize the FashionMNIST dataset from torchvision. Fashion-MNIST is a dataset of Zalando’s article images consisting of 60000 training examples and 10000 test examples. Each example comprises a 28×28 grayscale image and an associated label from one of 10 classes (0: "T-Shirt",    1: "Trouser",    2: "Pullover", 3: "Dress", 4: "Coat", 5: "Sandal", 6: "Shirt", 7: "Sneaker", 8: "Bag", 9: "Ankle Boot").

pytorch simple example:

Learn To Build A GUI For These 10 Ultimate Python AI Libraries is it a bag is it a shirt is this dress blue or yellow
PyTorch Demo with Python4Delphi in Windows

Read more:

5. How can we work with natural languages using NLTK?

NLTK is a leading platform for building Python programs to work with human language data. Natural Language Processing or NLP for short — in a wide sense, to cover any kind of computer manipulation of natural language. NLP is a field in Machine Learning with the ability of a computer to understand, analyze, manipulate, and potentially generate human language.

NLTK provides easy-to-use interfaces to over 50 corpora and lexical resources such as WordNet, along with a suite of text processing libraries for classification, tokenization, stemming, tagging, parsing, and semantic reasoning, wrappers for industrial-strength NLP libraries, and an active discussion forum.

First, here is how you can get nltk:

Practical work in Natural Language Processing typically uses large bodies of linguistic data or corpora. You can add the popular NLTK datasets to your system using this command:

The following is a code example of nltk to create a classifier app that could predict gender from the people’s name as input (run this inside the lower Memo of Python4Delphi Demo01 GUI):

Here is the nltk demo result in the Python GUI

Learn To Build A GUI For These 10 Ultimate Python AI Libraries NTLK results
NLTK Demo with Python4Delphi in Windows

Read more:

6. How can I perform advanced natural language processing (NLP) with Gensim?

Gensim is an open-source library for Unsupervised Topic Modeling and Natural Language Processing, using Modern Statistical Machine Learning. Gensim has been used and cited in over 1400 commercial and academic applications as of 2018, in a diverse array of disciplines from medicine to insurance claim analysis to patent search.

Design principles of Gensim:

  • Practicality – As industry experts, they focus on proven, battle-hardened algorithms to solve real industry problems. More focus on engineering, less on academia.
  • Memory independence – There is no need for the whole training corpus to reside fully in RAM at any one time. Can process large, web-scale corpora using data streaming.
  • Performance – Highly optimized implementations of popular vector space algorithms using C, BLAS, and memory mapping.

By now, Gensim is known to be the most robust, efficient, and hassle-free piece of software to realize unsupervised semantic modeling from plain text.

First, here is how you can get gensim:

 The following is a code example of gensim to perform similarity queries (run this inside the lower Memo of Python4Delphi Demo01 GUI):

What does the gensim result look in the Python GUI?

Learn To Build A GUI For These 10 Ultimate Python AI Libraries more results
Gensim Demo with Python4Delphi in Windows

Read more:

7. How to get started easily in computer vision with OpenCV?

OpenCV (Open Source Computer Vision Library) is an open-source Computer Vision and Machine Learning software library. OpenCV was built to provide a common infrastructure for Computer Vision applications and to accelerate the use of machine perception in commercial products. OpenCV supports various programming languages including Python.

OpenCV has more than 2500 optimized algorithms, which includes a comprehensive set of both classic and state-of-the-art Computer Vision and Machine Learning algorithms. These algorithms can be used to detect and recognize faces, identify objects, classify human actions in videos, track camera movements, track moving objects, extract 3D models of objects, produce 3D point clouds from stereo cameras, stitch images together to produce a high-resolution image of an entire scene, find similar images from an image database, remove red eyes from images taken using flash, follow eye movements, recognize scenery and establish markers to overlay it with augmented reality, etc.

First, here is how you can get opencv to work with Python4Delphi to create GUI with Computer Vision and Machine Learning capabilities:

Note: This is an unofficial pre-built CPU-only OpenCV package for Python.

The following is a code example of opencv to perform perspective transformation of an image  (run this inside the lower Memo of Python4Delphi Demo01 GUI):

Here is the opencv result in Python GUI

Learn To Build A GUI For These 10 Ultimate Python AI Libraries OpenCV taking chances with Queens
OpenCV Demo with Python4Delphi in Windows

Read more:

8. How can I automatically recognize printed characters in images with EasyOCR?

EasyOCR, as the name suggests, is a Python package that allows computer vision developers to effortlessly perform Optical Character Recognition. EasyOCR provides end-to-end, and ready-to-use OCR with 80+ supported languages and all popular writing scripts including Latin, Chinese, Arabic, Devanagari, Cyrillic, etc.

When it comes to OCR, using EasyOCR is by far the most straightforward way to apply Optical Character Recognition:

  • The EasyOCR package can be installed with a single pip command.
  • The dependencies on the EasyOCR package are minimal, making it easy to configure your OCR development environment.
  • Once EasyOCR is installed, only one import statement is required to import the package into your project.
  • From there, all you need is two lines of code to perform OCR — one to initialize the Reader class and then another to OCR the image via the readtext function.

First, here is how you can get easyocr:

Next, we will test the EasyOCR library to detect both Chinese and English characters in this image:

Learn To Build A GUI For These 10 Ultimate Python AI Libraries Chinese Characters
Image Source Reference 13

The following is a basic usage of easyocr to detect both Chinese (ch_sim) and English (en) characters in the sample image above (run this inside the lower Memo of Python4Delphi Demo01 GUI):

What does the easyocr optical character recognition result look like?

Learn To Build A GUI For These 10 Ultimate Python AI Libraries Easy OCR Results
EasyOCR Demo with Python4Delphi in Windows

9. How to gain insight instantly from datasets with Seaborn?

Seaborn is a library for making statistical graphics in Python. It is built on top of matplotlib and is closely integrated with pandas data structures. Seaborn will enhance the matplotlib plotting functionalities.

Here is some of the functionality that Seaborn offers:

  • A dataset-oriented API for examining relationships between multiple variables
  • Specialized support for using categorical variables to show observations or aggregate statistics
  • Options for visualizing univariate or bivariate distributions and for comparing them between subsets of data
  • Automatic estimation and plotting of linear regression models for different kinds of dependent variables
  • Convenient views onto the overall structure of complex datasets
  • High-level abstractions for structuring multi-plot grids that let you easily build complex visualizations
  • Concise control over matplotlib figure styling with several built-in themes
  • Tools for choosing color palettes that faithfully reveal patterns in your data

Do you want to improve Matplotlib plots using Seaborn, like creating Scatterplot with Varying Point Sizes and Hues, in the Windows GUI app? This section will show you how to get started!

First, here is how you can get seaborn:

The following is an introductory example of seaborn to create Scatterplot with Varying Point Sizes and Hues (run this inside the lower Memo of Python4Delphi Demo01 GUI):

Here is the seaborn result in the Python GUI:

Learn To Build A GUI For These 10 Ultimate Python AI Libraries Seaborn results
Seaborn Demo with Python4Delphi in Windows

10. How to bring your data visualizations to another level with Bokeh?

Bokeh is an interactive visualization library to be shown in modern web browsers. It provides elegant, concise construction of versatile graphics, and affords high-performance interactivity over large or streaming datasets. Bokeh can help anyone who would like to quickly and easily make interactive plots, dashboards, and data applications.

At a glance, Bokeh  provides us with:

  • Flexible

Bokeh makes it simple to create common plots but also can handle custom or specialized use-cases.

  • Interactive

Tools and widgets let you and your audience probe “what if” scenarios or drill down into the details of your data.

  • Shareable

Plots, dashboards, and apps can be published on web pages or Jupyter notebooks.

  • Productive

Work in Python close to all the PyData tools you are already familiar with.

  • Powerful

You can always add custom JavaScript to support advanced or specialized cases.

  • Open Source

Everything, including the Bokeh server, is BSD licensed and available on GitHub.

This section will guide you to combine Python4Delphi with the Bokeh library, inside Delphi and C++Builder, from installing Bokeh with pip to Plotting the Interactive Plot of Unemployment Rate.

First, here is how you can get bokeh

The following is a code example of bokeh to Plotting the Interactive Plot of Unemployment Rate in Texas (run this inside the lower Memo of Python4Delphi Demo01 GUI):

bokeh interactive plot result in P4D GUI

Learn To Build A GUI For These 10 Ultimate Python AI Libraries Texas Y'all
Bokeh Demo with Python4Delphi in Windows

Read more:

Are you ready to build awesome things with these Python AI libraries?

We already demonstrate 10 powerful Python libraries for Artificial Intelligence-related tasks (Keras, TensorFlow, scikit-learn, PyTorch, NLTK, Gensim, OpenCV, EasyOCR, Seaborn, and Bokeh). All of them wrapped well inside a powerful GUI provided by Python4Delphi. We can’t wait to see what you build with Python4Delphi!


Want to know some more? Then check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi, and

Download RAD Studio to build more powerful Python GUI Windows Apps 5x Faster with Less Code.


References & further readings

[1] Kavlakoglu, E. (2020).

AI vs. Machine Learning vs. Deep Learning vs. Neural Networks: What’s the Difference? IBM Blog. ibm.com/cloud/blog/ai-vs-machine-learning-vs-deep-learning-vs-neural-networks

[2] Hakim, M. A. (2021).

Article16 – 10 Python’s Artificial Intelligence Libraries.  embarcaderoBlog-repo GitHub. github.com/MuhammadAzizulHakim/ embarcaderoBlog-repo/tree/main/Article16%20-%2010%20Python’s%20Artificial%20Intelligence %20Libraries

[3] Hakim, M. A. (2021).

Artificial Intelligence Solutions With Keras Library In A Windows Python App. PythonGUI.org. Embarcadero Technologies. pythongui.org/artificial-intelligence-solutions-with-keras-library-in-a-windows-python-app

[4] Hakim, M. A. (2021).

Build An Artificial Intelligence Solution With TensorFlow Library In A Delphi Windows App. PythonGUI.org. Embarcadero Technologies. pythongui.org/build-an-artificial-intelligence-solutions-with-tensorflow-library-in-a-delphi-windows-app

[5] Hakim, M. A. (2021).

Build A Machine Learning Solutions With Scikit-Learn Library In A Delphi Windows App. PythonGUI.org. Embarcadero Technologies. pythongui.org/build-a-machine-learning-solutions-with-scikit-learn-library-in-a-delphi-windows-app

[6] Hakim, M. A. (2021).

Build An Artificial Intelligence Solutions With PyTorch Library In A Delphi Windows App. PythonGUI.org. Embarcadero Technologies. pythongui.org/build-an-artificial-intelligence-solutions-with-pytorch-library-in-a-delphi-windows-app

[7] Hakim, M. A. (2021).

Quickly Build A Python GUI App With Powerful Natural Language Processing Capabilities Using NLTK Library In A Delphi Windows App. PythonGUI.org. Embarcadero Technologies. pythongui.org/quickly-build-a-python-gui-app-with-powerful-natural-language-processing-capabilities-using-nltk-library-in-a-delphi-windows-app

[8] Hakim, M. A. (2021).

Integrate Robust Similarity Queries Capabilities To Your Python GUI App With Powerful Gensim Library. PythonGUI.org. Embarcadero Technologies. pythongui.org/integrate-robust-similarity-queries-capabilities-to-your-python-gui-app-with-powerful-gensim-library

[9] Hakim, M. A. (2021).

Learn To Build A Python GUI For Computer Vision Tasks With Powerful OpenCV Library In A Delphi Windows App. PythonGUI.org. Embarcadero Technologies. pythongui.org/learn-to-build-a-python-gui-for-computer-vision-tasks-with-powerful-opencv-library-in-a-delphi-windows-app

[10] Hakim, M. A. (2022).

How To Build A GUI For Optical Character Recognition. PythonGUI.org. Embarcadero Technologies. pythongui.org/how-to-build-a-gui-for-optical-character-recognition

[11] Hakim, M. A. (2021).

3 Ways To Create Enterprise-Grade Graphics Using The Seaborn Library. PythonGUI.org. Embarcadero Technologies. pythongui.org/3-ways-to-create-enterprise-grade-graphics-using-the-seaborn-library

[12] Hakim, M. A. (2021).

Learn To Build A Python GUI For Interactive Data Visualizations Using Bokeh Library In A Delphi Windows App. PythonGUI.org. Embarcadero Technologies. pythongui.org/learn-to-build-a-python-gui-for-interactive-data-visualizations-using-bokeh-library-in-a-delphi-windows-app

[13] cms.qz.com/wp-content/uploads/2017/06/china-english-road-signs-2017-e1498204314511.jpg?quality=75&strip=all&w=1600&h=903

Related posts
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

CodeIDELearn PythonPythonPython GUITkinter

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

CodeIDELearn PythonPythonPython GUITkinter

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

Leave a Reply

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