SlideShare a Scribd company logo
1 of 34
Download to read offline
PyTorch for Delphi
with the
Python Data Science Libraries
June 9th, 2022
jim.mckeeth@embarcadero.com
Slides, links, replay: https://blogs.embarcadero.com/?p=145025
PyTorch for Delphi with the Python Data Sciences Libraries
The next installment of the Embarcadero Open Source Live Stream takes a look at the Delphi side of the Python
Ecosystem with the new Python Data Sciences Libraries and related projects that make it super easy write Delphi
code against Python libraries and easily deploy on Windows, Linux, MacOS, and Android. Specific examples with
the Python Natural Language Toolkit and PyTorch, the library that powers projects like Tesla Autopilot, Uber's
Pyro, Hugging Face's Transformers.
This is part of a series of regular live streams discussing the latest in Embarcadero open source projects. Hosted
by Jim McKeeth and joined by members of the community and developers involved in these open source projects,
as well as members of Embarcadero and Idera’s Product Management. A great opportunity to see behind the
scenes and help shape the future of Embarcadero’s Open Source projects.
If you are interested in machine learning, artificial intelligence, or data sciences then you want to join this webinar!
Description
Slides, replay, links, etc. blogs.embarcadero.com/?p=145025
Who’s on the Stream?
● Jim McKeeth - Embarcadero Developer Relations
● Kunarapu Priyatham - Python Developer & Tech Writer
● Lucas Moura Belo - Delphi & Python Developer
● Kiriakos Vlahos - Maintainer of PyScripter and Python4Delphi
● Chris Gardner - Whole Tomato Visual Assist Lead Developer
● Marco Cantu - RAD Studio & Delphi PM
● And others who may or may not chime in . . .
Priyatham
Jim
Lucas
Chris
Kiriakos
We Need More Components!
● We are more productive when there is an
existing component or library already
● Delphi and C++Builder has a huge rich
ecosystem of Tech Partners and open source
● But wouldn’t be great to have EVEN MORE?
● Python has one of the richest ecosystems,
especially for data sciences, AI, & ML
● What if Delphi & C++Builder could easily
USE THEM ALL?
XKCD on Python
There is a package for everything!
● xkcd.com/353/ from December 5th, 2007
● explainxkcd.com/wiki/index.php/353:_Python
[A friend is talking to Cueball, who is floating in the sky.]
Friend: You're flying! How?
Cueball: Python!
Cueball: I learned it last night! Everything is so simple!
Cueball: Hello world is just pr i nt " He l l o, W
or l d! "
Friend: I dunno... Dynamic typing? Whitespace?
Cueball: Come join us! Programming is fun again! It's a whole
new world up here!
Friend: But how are you flying?
Cueball: I just typed 'i mpor t a nt i gr a vi t y'
Friend: That's it?
Cueball: ...I also sampled everything in the medicine cabinet for
comparison.
Cueball: But I think this is the python.
In response to this comic, the Python developers implemented the
module a nt i gr a vi t y. When you import it, the default web
browser will open this comic.
General Notes and Comments
● Most all projects are open source, MIT licensed, and hosted on GitHub.
● Embarcadero is directly sponsoring the developers and development.
● While the focus is on Delphi, we expect C++Builder will work eventually.
○ Once the Delphi side is stable we will look more closely at C++Builder where it makes sense.
○ There are already resources showing how to use Python4Delphi with C++Builder.
● All of these projects are available and mostly working today.
○ They are under active development, so consider them beta or alpha releases….
● Unless otherwise stated, everything works on
○ Android, Windows (32 & 64-bit), MacOS (x86 & ARM), and Linux
● We are looking for feedback, pull requests, contributors, and forks on all
Embarcadero Open Source projects!
● ⭐ Starring a project is a great way to show your interest!
It’s not a Competition
● Language choice isn’t a zero sum game.
● Developers have multiple tools on their workbench.
● When tools work together then a developer can use both!
● It is about finding the right tool for each task.
● We use SQL to talk to databases, JavaScript and HTML run
the web.
● Having specialized tools for different tasks doesn’t detract
from favorite tools.
● You can always find a specific task
that another tool is better for,
but no one tool is that best
for all tasks.
Python Delphi
Tensorflow
NumPy
etc.
GitHub
GetIt
Boss
Chocolatey
PyPi
Conda
Forge
Python Developers
Delphi
Developers
Delphi Extensions
for Python
Python4Delphi
PyScripter
DelphiVCL
DelphiFMX
Lightweight
Python
Wrappers
P4D
Data Sciences
Python
Environments
PIP
FMX App Builder D4P Exporter
Python and Delphi Ecosystem
1. Free Python IDE and libraries
○ Free give away to Python developers.
2. Use designer export from Delphi
○ Dipping toe into Delphi CE or a free trial.
3. Import Python libraries into Delphi
○ Starting to explore the power of hybrid apps.
4. Build native Delphi modules for Python
○ Use Delphi’s native compiler to add speed and features to
Python.
5. Full Hybrid Delphi + Python Power
○ The ultimate stage of development, ushering in the final
technological singularity, leading to total universal domination
and the enlightenment of all humankind.
PyScripter, DelphiFMX,
DelphiVCL
Lightweight Python
Wrappers
& Data Sciences
Python4Delphi &
Delphi Extensions
for Python
Available via GetIt.
Python4Delphi: The Bridge
Python for Delphi (P4D) is a set of components that wrap up the Python Library into Delphi. They let
Delphi developers easily execute Python scripts, create new Python modules, and new Python
types. You can create Python extension modules and much more. P4D provides different levels of
functionality:
● Low-level access to the Python API
● High-level bi-directional interaction with Python
● Access to Python objects using Delphi custom
variants (VarPyth.pas)
● Wrapping of Delphi objects for use in Python
scripts using RTTI (WrapDelphi.pas)
● Creating Python extension modules with Delphi classes and functions
Supports Android (64-bit ARM), Windows (32 & 64-bit x86), MacOS (x86 & ARM), and Linux (64-bit x86)
Embarcadero’s Fork of P4D
github.com/Embarcadero/Python4Delphi
Originally maintained by Kiriakos Vlahos (aka PyScripter)
● GitHub - Where all the projects are hosted: github.com/embarcadero
● GetIt - The Embarcadero package manager. When the projects for Delphi developers are
ready for general use they can easily be installed via GetIt. getitnow.embarcadero.com
● Boss - Delphi dependency manager. Plan to use to make it easy to manage
dependencies between projects. github.com/hashload/boss
● Chocolatey - General Windows package manager. Simplify deployment and installation
of development builds.
● pip - Package Installer for Python pip.pypa.io
● PyPi - The Python Package Index is the official third-party software repository for
Python. Default source for pip. pypi.org/user/Embarcadero
● Conda - Alternative and very popular Python package manager. docs.conda.io
● Conda Forge - Community-led collection of distributions for the conda package
manager. conda-forge.org
Other Pieces in the Ecosystem GitHub
Boss
Chocolatey
PyPi
Conda
Forge
GetIt
pip
For Delphi Developers
Bringing the best of Python to Delphi developers.
Pure Object Pascal access to Python libraries.
Goals
● Give Delphi (and eventually C++Builder)
developers access to all Python libraries
● No Python knowledge or code required
● But still give full access
● Simple development setup
● Simple end user deployment
● No internet connection required
● Cross platform
This is an early access preview, but you
are invited to start using and contributing.
Three All New Projects
Powered by Python4Delphi
Python Environments
● Delphi components that simplify the deployment and configuration of Python
environments
● Freeing Delphi developers from needing to worry about Python
● Supports Python versions 3.7, 3.8, 3.9, & 3.10
● Currently 3 different options:
○ Use an existing Python environment
○ Redistribute or download a Python environment archive
○ Embed the redistributable within the program
● At runtime it automatically verifies and configures the environment, including
PIP or Conda package managers
● The framework is very modular, flexible, and customizable
● Installs necessary Python modules
● Working on Android, Windows (32 & 64-bit), MacOS (x86 & ARM), and Linux
Early Alpha - Should mostly work, still adding features
github.com/Embarcadero/PythonEnviroments/
For Delphi
Developers
Lightweight Python Wrappers
● Framework for creating a lightweight wrapper around a Python library
turning it into a Delphi component
● Makes adding a new Python library super quick and easy
● Manages the necessary Python modules via pip or Conda
● Allows for a simple translation of Python code into Delphi code
● Uses late binding giving it a more flexible syntax
● Letting Delphi developers use pure Delphi to access Python libraries
To Do:
● Automatic wrapper generation
● Python to Delphi code translation
● Code completion and better IDE integration
● Your suggestions!
Early Alpha - Should mostly work, still adding features
github.com/Embarcadero/Lightweight-Python-Wrappers
For Delphi
Developers
P4D Data Sciences
● Based on the Lightweight Python Wrappers, Python Environments, and
Python4Delphi
● Delphi components for popular Python Data Sciences tools
● Currently includes:
○ Tensorflow, NumPy, PyTorch Vision, PyTorch, MatPlotLib, Natural Language
Toolkit (NLTK), OpenCV, and Scikit-learn
● Even includes some samples
● Surprisingly easy to make and use
○ Literally a couple hours work to add and test a new library
● Looking at additional libraries to add….
Early Alpha - Should mostly work, still adding features
github.com/Embarcadero/P4D-Data-Sciences
Even includes some demos
For Delphi
Developers
Example of adding a library:
Natural Language Toolkit
(NLTK)
For Delphi
Developers
Natural Language
Toolkit (NLTK)
● This is the code to wrap a new
Python library for Delphi
● Looking into automatic importer
● All the details and complexity are
encapsulated in the Lightweight
Python Wrappers
● The Python Environment handles all
the requirements and installation
unit NLTK;
procedure TNLTK.Prepare( const AModel: TPyPackageModel);
begin
inherited ;
with AModel do begin
PackageName := 'nltk' ;
PackageManagers.Add(TPyPackageManagerKind. pip ,
TPyPackageManagerPip.Create( 'nltk' ));
end;
end;
● Name of Python
module
● Package manager for
installation
For Delphi
Developers
● Simple code found on nltk.org
● Showing off basic functionality
● Python code running in the REPL,
with results displayed inline
Demo Tokenize and tag some text:
>>> import nltk
>>> nltk.download( 'popular' )
>>> sentence = """At eight o'clock on Thursday morning
... Arthur didn't feel very good."""
>>> tokens = nltk . word_tokenize(sentence)
>>> tokens
['At', 'eight', "o'clock", 'on', 'Thursday', 'morning',
'Arthur', 'did', "n't", 'feel', 'very', 'good', '.']
>>> tagged = nltk . pos_tag(tokens)
>>> tagged[ 0: 6]
[('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'),
('Thursday', 'NNP'), ('morning', 'NN')]
Identify named entities:
>>> entities = nltk . chunk . ne_chunk(tagged)
>>> entities
Tree('S', [('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'),
('on', 'IN'), ('Thursday', 'NNP'), ('morning', 'NN'),
Tree('PERSON', [('Arthur', 'NNP')]),
('did', 'VBD'), ("n't", 'RB'), ('feel', 'VB'),
('very', 'RB'), ('good', 'JJ'), ('.', '.')])
Downloads the required data.
Only necessary once.
● There are a series of event handlers
notifying your program of state of the
Python Environment.
● Here is the Delphi version of the
Python code.
● The output of each step is displayed
in the list boxes.
● When compiled there is a single EXE.
● At runtime the Environment sets up a
nested Python environment with all
the necessary dependencies.
Demo with NLTK1 do begin
nltk.download( 'popular' );
var tokens :=
nltk.word_tokenize(memo1.lines.Text);
VarPyToStrings(tokens,ListBox1.Items);
var tagged :=
nltk.pos_tag(tokens);
VarPyToStrings(tagged,ListBox2.Items);
var entities :=
nltk.chunk.ne_chunk(tagged);
VarPyToStrings(entities, ListBox3.Items);
end;
For Delphi
Developers
● Add the following components:
○ TPythonEngine
○ TPyEmbeddedResEnvironment310
○ TNumPy
○ TNLTK
● Connect the components
● Make the UI
● Leave the Tokenize button disabled, then use an
event handler from the Environment to enable it
when everything is setup.
Demo
For Delphi
Developers
● One first run the Environment is setup
with all dependencies. Usually takes a
few seconds.
● On subsequent runs it takes a second to
validate the environment, load the
libraries, and start the engine.
● The program uses the event handlers to
enable the user interface based on the
state.
Demo
For Delphi
Developers
● The Python environment can be installed
anywhere (or an existing one can be used) but
the default is the EXE folder.
● It can also be created during the installation
process, before the program first runs.
● Here we see our sample program in 43 MB.
● And it extracted and created a 95 MB Python
environment.
● The same project can compile and run
identically on Android, Windows (32 & 64-bit),
MacOS (x86 & ARM), and Linux
Demo
For Delphi
Developers
Demo with Delphi
For Delphi
Developers
Demo
● PyTorch is an open source machine learning framework 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)
● Used in projects like Tesla Autopilot, Uber's Pyro, Hugging Face's Transformers,
and others
● Delphi demo is part of P4D Data Sciences
○ This is a Thumbs Up and Thumbs Down image classification system with mobile image collection
○ github.com/Embarcadero/P4D-Data-Sciences/tree/main/demos/PyTorch/
■ App - Android App Source
■ Install - Installs dependencies and sets up environment on server
■ Server - WebBroker server
■ Train - Called by server to do the training and process the data
■ Training_Data - Pre collected images
What’s Next?
It’s still early access, but
what else is possible?
What’s Next
● Still more work - in early stages of
development
● Automatic wrapper generation
● More libraries
● Python to Delphi code translation
○ Translate Python sample code
● Documentation for the full stack and for
using the imported libraries
● Code completion and better IDE integration
● Your suggestions!
Other Potential Python Libraries
● Keras - ML library that runs on both CPU and GPU
● LightGBM by Microsoft - Used for ML ranking, classification, etc.
● Aesara - Multi-dimensional arrays mathematical expressions
● BeautifulSoup - Scrapes data from web pages
● Pillow - Image manipulation
● MoviePy - Video Editing
● Seaborn - Drawing attractive statistical graphics
● YOLOv5 - Pretrained object detection architectures and models
lightgbm.readthedocs.io
aesara.readthedocs.io
keras.io
crummy.com/software/BeautifulSoup/
Python Pillow
python-pillow.org
zulko.github.io/moviepy
seaborn.pydata.org
For Delphi
Developers
● See the list of the most popular Python
packages on PyPi in the last 30 days.
● None of these are on the previous slides.
● Can every Python library be available for
Delphi developers? One way to find out….
pypistats.org/top - pypi.org
Tip of the Iceberg Rank Library Downloads
1 boto3 343,267,820
2 urllib3 214,453,654
3 botocore 211,027,562
4 requests 206,502,136
5 idna 176,641,902
6 setuptools 173,382,430
7 s3transfer 171,067,399
8 typing-extensions 165,570,269
9 six 156,492,192
10 certifi 151,478,041
11 python-dateutil 149,953,838
12 pyyaml 142,509,567
13 charset-normalizer 139,528,384
14 awscli 122,370,481
15 click 117,707,552
16 wheel 115,961,643
17 cryptography 110,978,677
18 jinja2 109,342,363
19 pyparsing 103,909,140
20 rsa 103,612,934
For Delphi
Developers
● Try the projects
● Star the projects on GitHub
● File bug reports
● Make a fork
● Issue a pull request
● Add features and fix bugs
● Tell your friends
● Write a blog post
● Make a demo
We Need Your Help!
Q & A
General Notes and Comments
● Most all projects are open source, MIT licensed, and hosted on GitHub.
● Embarcadero is directly sponsoring the developers and development.
● While the focus is on Delphi, we expect C++Builder will work eventually.
○ Once the Delphi side is stable we will look more closely at C++Builder where it makes sense.
○ There are already resources showing how to use Python4Delphi with C++Builder.
● All of these projects are available and mostly working today.
○ They are under active development, so consider them beta or alpha releases….
● Unless otherwise stated, everything works on
○ Android, Windows (32 & 64-bit), MacOS (x86 & ARM), and Linux
● We are looking for feedback, pull requests, contributors, and forks on all
Embarcadero Open Source projects!
● ⭐ Starring a project is a great way to show your interest!
PyTorch for Delphi
with the
Python Data Science Libraries

More Related Content

Similar to PyTorch for Delphi - Python Data Sciences Libraries.pdf

Python.pptx
Python.pptxPython.pptx
Python.pptxabclara
 
Docker based-Pipelines with Codefresh
Docker based-Pipelines with CodefreshDocker based-Pipelines with Codefresh
Docker based-Pipelines with CodefreshCodefresh
 
Introductory session flutter festival
Introductory session   flutter festivalIntroductory session   flutter festival
Introductory session flutter festivalApoorveGoyal2
 
Introduction to PHP (SDPHP)
Introduction to PHP   (SDPHP)Introduction to PHP   (SDPHP)
Introduction to PHP (SDPHP)Eric Johnson
 
Using Delphi as a no code development environment
Using Delphi as a no code development environmentUsing Delphi as a no code development environment
Using Delphi as a no code development environmentpprem
 
Docker based-pipelines
Docker based-pipelinesDocker based-pipelines
Docker based-pipelinesDevOps.com
 
Migration of Applications to Python is the most prudent Decision
Migration of Applications to Python is the most prudent DecisionMigration of Applications to Python is the most prudent Decision
Migration of Applications to Python is the most prudent DecisionMindfire LLC
 
Python 101 For The Net Developer
Python 101 For The Net DeveloperPython 101 For The Net Developer
Python 101 For The Net DeveloperSarah Dutkiewicz
 
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabVoxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabRon Munitz
 
What is Python? An overview of Python for science.
What is Python? An overview of Python for science.What is Python? An overview of Python for science.
What is Python? An overview of Python for science.Nicholas Pringle
 
"About Firebird and Flamerobin" by Marius Popa @ eLiberatica 2007
"About Firebird and Flamerobin" by Marius Popa @ eLiberatica 2007"About Firebird and Flamerobin" by Marius Popa @ eLiberatica 2007
"About Firebird and Flamerobin" by Marius Popa @ eLiberatica 2007eLiberatica
 
PHP vs Python Which is Best for Web Development.pdf
PHP vs Python Which is Best for Web Development.pdfPHP vs Python Which is Best for Web Development.pdf
PHP vs Python Which is Best for Web Development.pdfchristiemarie4
 
Python For All | Software Professionals, QA & DevOps professionals
Python For All | Software Professionals, QA & DevOps professionalsPython For All | Software Professionals, QA & DevOps professionals
Python For All | Software Professionals, QA & DevOps professionalsNilesh Sutar
 

Similar to PyTorch for Delphi - Python Data Sciences Libraries.pdf (20)

Python.pptx
Python.pptxPython.pptx
Python.pptx
 
Docker based-Pipelines with Codefresh
Docker based-Pipelines with CodefreshDocker based-Pipelines with Codefresh
Docker based-Pipelines with Codefresh
 
Introductory session flutter festival
Introductory session   flutter festivalIntroductory session   flutter festival
Introductory session flutter festival
 
Introduction to PHP (SDPHP)
Introduction to PHP   (SDPHP)Introduction to PHP   (SDPHP)
Introduction to PHP (SDPHP)
 
Why learn python in 2017?
Why learn python in 2017?Why learn python in 2017?
Why learn python in 2017?
 
Features of python.pptx
Features of python.pptxFeatures of python.pptx
Features of python.pptx
 
Summer Training Project.pdf
Summer Training Project.pdfSummer Training Project.pdf
Summer Training Project.pdf
 
Using Delphi as a no code development environment
Using Delphi as a no code development environmentUsing Delphi as a no code development environment
Using Delphi as a no code development environment
 
Docker based-pipelines
Docker based-pipelinesDocker based-pipelines
Docker based-pipelines
 
Migration of Applications to Python is the most prudent Decision
Migration of Applications to Python is the most prudent DecisionMigration of Applications to Python is the most prudent Decision
Migration of Applications to Python is the most prudent Decision
 
Flutter festival ppt
Flutter festival ppt Flutter festival ppt
Flutter festival ppt
 
Python 101 For The Net Developer
Python 101 For The Net DeveloperPython 101 For The Net Developer
Python 101 For The Net Developer
 
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabVoxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
 
What is Python? An overview of Python for science.
What is Python? An overview of Python for science.What is Python? An overview of Python for science.
What is Python? An overview of Python for science.
 
Lecture 1.pptx
Lecture 1.pptxLecture 1.pptx
Lecture 1.pptx
 
"About Firebird and Flamerobin" by Marius Popa @ eLiberatica 2007
"About Firebird and Flamerobin" by Marius Popa @ eLiberatica 2007"About Firebird and Flamerobin" by Marius Popa @ eLiberatica 2007
"About Firebird and Flamerobin" by Marius Popa @ eLiberatica 2007
 
PHP vs Python Which is Best for Web Development.pdf
PHP vs Python Which is Best for Web Development.pdfPHP vs Python Which is Best for Web Development.pdf
PHP vs Python Which is Best for Web Development.pdf
 
Python For All | Software Professionals, QA & DevOps professionals
Python For All | Software Professionals, QA & DevOps professionalsPython For All | Software Professionals, QA & DevOps professionals
Python For All | Software Professionals, QA & DevOps professionals
 
Python for All
Python for All Python for All
Python for All
 
Introduction to python
Introduction to python Introduction to python
Introduction to python
 

More from Embarcadero Technologies

Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...Embarcadero Technologies
 
Linux GUI Applications on Windows Subsystem for Linux
Linux GUI Applications on Windows Subsystem for LinuxLinux GUI Applications on Windows Subsystem for Linux
Linux GUI Applications on Windows Subsystem for LinuxEmbarcadero Technologies
 
FMXLinux Introduction - Delphi's FireMonkey for Linux
FMXLinux Introduction - Delphi's FireMonkey for LinuxFMXLinux Introduction - Delphi's FireMonkey for Linux
FMXLinux Introduction - Delphi's FireMonkey for LinuxEmbarcadero Technologies
 
Python for Delphi Developers - Part 1 Introduction
Python for Delphi Developers - Part 1 IntroductionPython for Delphi Developers - Part 1 Introduction
Python for Delphi Developers - Part 1 IntroductionEmbarcadero Technologies
 
RAD Industrial Automation, Labs, and Instrumentation
RAD Industrial Automation, Labs, and InstrumentationRAD Industrial Automation, Labs, and Instrumentation
RAD Industrial Automation, Labs, and InstrumentationEmbarcadero Technologies
 
Embeddable Databases for Mobile Apps: Stress-Free Solutions with InterBase
Embeddable Databases for Mobile Apps: Stress-Free Solutions with InterBaseEmbeddable Databases for Mobile Apps: Stress-Free Solutions with InterBase
Embeddable Databases for Mobile Apps: Stress-Free Solutions with InterBaseEmbarcadero Technologies
 
Rad Server Industry Template - Connected Nurses Station - Setup Document
Rad Server Industry Template - Connected Nurses Station - Setup DocumentRad Server Industry Template - Connected Nurses Station - Setup Document
Rad Server Industry Template - Connected Nurses Station - Setup DocumentEmbarcadero Technologies
 
Move Desktop Apps to the Cloud - RollApp & Embarcadero webinar
Move Desktop Apps to the Cloud - RollApp & Embarcadero webinarMove Desktop Apps to the Cloud - RollApp & Embarcadero webinar
Move Desktop Apps to the Cloud - RollApp & Embarcadero webinarEmbarcadero Technologies
 
Getting Started Building Mobile Applications for iOS and Android
Getting Started Building Mobile Applications for iOS and AndroidGetting Started Building Mobile Applications for iOS and Android
Getting Started Building Mobile Applications for iOS and AndroidEmbarcadero Technologies
 
ER/Studio 2016: Build a Business-Driven Data Architecture
ER/Studio 2016: Build a Business-Driven Data ArchitectureER/Studio 2016: Build a Business-Driven Data Architecture
ER/Studio 2016: Build a Business-Driven Data ArchitectureEmbarcadero Technologies
 
The Secrets of SQL Server: Database Worst Practices
The Secrets of SQL Server: Database Worst PracticesThe Secrets of SQL Server: Database Worst Practices
The Secrets of SQL Server: Database Worst PracticesEmbarcadero Technologies
 
Driving Business Value Through Agile Data Assets
Driving Business Value Through Agile Data AssetsDriving Business Value Through Agile Data Assets
Driving Business Value Through Agile Data AssetsEmbarcadero Technologies
 
Troubleshooting Plan Changes with Query Store in SQL Server 2016
Troubleshooting Plan Changes with Query Store in SQL Server 2016Troubleshooting Plan Changes with Query Store in SQL Server 2016
Troubleshooting Plan Changes with Query Store in SQL Server 2016Embarcadero Technologies
 
Agile, Automated, Aware: How to Model for Success
Agile, Automated, Aware: How to Model for SuccessAgile, Automated, Aware: How to Model for Success
Agile, Automated, Aware: How to Model for SuccessEmbarcadero Technologies
 
What's New in DBArtisan and Rapid SQL 2016
What's New in DBArtisan and Rapid SQL 2016What's New in DBArtisan and Rapid SQL 2016
What's New in DBArtisan and Rapid SQL 2016Embarcadero Technologies
 

More from Embarcadero Technologies (20)

Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
 
Linux GUI Applications on Windows Subsystem for Linux
Linux GUI Applications on Windows Subsystem for LinuxLinux GUI Applications on Windows Subsystem for Linux
Linux GUI Applications on Windows Subsystem for Linux
 
FMXLinux Introduction - Delphi's FireMonkey for Linux
FMXLinux Introduction - Delphi's FireMonkey for LinuxFMXLinux Introduction - Delphi's FireMonkey for Linux
FMXLinux Introduction - Delphi's FireMonkey for Linux
 
Python for Delphi Developers - Part 2
Python for Delphi Developers - Part 2Python for Delphi Developers - Part 2
Python for Delphi Developers - Part 2
 
Python for Delphi Developers - Part 1 Introduction
Python for Delphi Developers - Part 1 IntroductionPython for Delphi Developers - Part 1 Introduction
Python for Delphi Developers - Part 1 Introduction
 
RAD Industrial Automation, Labs, and Instrumentation
RAD Industrial Automation, Labs, and InstrumentationRAD Industrial Automation, Labs, and Instrumentation
RAD Industrial Automation, Labs, and Instrumentation
 
Embeddable Databases for Mobile Apps: Stress-Free Solutions with InterBase
Embeddable Databases for Mobile Apps: Stress-Free Solutions with InterBaseEmbeddable Databases for Mobile Apps: Stress-Free Solutions with InterBase
Embeddable Databases for Mobile Apps: Stress-Free Solutions with InterBase
 
Rad Server Industry Template - Connected Nurses Station - Setup Document
Rad Server Industry Template - Connected Nurses Station - Setup DocumentRad Server Industry Template - Connected Nurses Station - Setup Document
Rad Server Industry Template - Connected Nurses Station - Setup Document
 
TMS Google Mapping Components
TMS Google Mapping ComponentsTMS Google Mapping Components
TMS Google Mapping Components
 
Move Desktop Apps to the Cloud - RollApp & Embarcadero webinar
Move Desktop Apps to the Cloud - RollApp & Embarcadero webinarMove Desktop Apps to the Cloud - RollApp & Embarcadero webinar
Move Desktop Apps to the Cloud - RollApp & Embarcadero webinar
 
Useful C++ Features You Should be Using
Useful C++ Features You Should be UsingUseful C++ Features You Should be Using
Useful C++ Features You Should be Using
 
Getting Started Building Mobile Applications for iOS and Android
Getting Started Building Mobile Applications for iOS and AndroidGetting Started Building Mobile Applications for iOS and Android
Getting Started Building Mobile Applications for iOS and Android
 
Embarcadero RAD server Launch Webinar
Embarcadero RAD server Launch WebinarEmbarcadero RAD server Launch Webinar
Embarcadero RAD server Launch Webinar
 
ER/Studio 2016: Build a Business-Driven Data Architecture
ER/Studio 2016: Build a Business-Driven Data ArchitectureER/Studio 2016: Build a Business-Driven Data Architecture
ER/Studio 2016: Build a Business-Driven Data Architecture
 
The Secrets of SQL Server: Database Worst Practices
The Secrets of SQL Server: Database Worst PracticesThe Secrets of SQL Server: Database Worst Practices
The Secrets of SQL Server: Database Worst Practices
 
Driving Business Value Through Agile Data Assets
Driving Business Value Through Agile Data AssetsDriving Business Value Through Agile Data Assets
Driving Business Value Through Agile Data Assets
 
Troubleshooting Plan Changes with Query Store in SQL Server 2016
Troubleshooting Plan Changes with Query Store in SQL Server 2016Troubleshooting Plan Changes with Query Store in SQL Server 2016
Troubleshooting Plan Changes with Query Store in SQL Server 2016
 
Great Scott! Dealing with New Datatypes
Great Scott! Dealing with New DatatypesGreat Scott! Dealing with New Datatypes
Great Scott! Dealing with New Datatypes
 
Agile, Automated, Aware: How to Model for Success
Agile, Automated, Aware: How to Model for SuccessAgile, Automated, Aware: How to Model for Success
Agile, Automated, Aware: How to Model for Success
 
What's New in DBArtisan and Rapid SQL 2016
What's New in DBArtisan and Rapid SQL 2016What's New in DBArtisan and Rapid SQL 2016
What's New in DBArtisan and Rapid SQL 2016
 

Recently uploaded

Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 

Recently uploaded (20)

Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 

PyTorch for Delphi - Python Data Sciences Libraries.pdf

  • 1. PyTorch for Delphi with the Python Data Science Libraries June 9th, 2022 jim.mckeeth@embarcadero.com Slides, links, replay: https://blogs.embarcadero.com/?p=145025
  • 2. PyTorch for Delphi with the Python Data Sciences Libraries The next installment of the Embarcadero Open Source Live Stream takes a look at the Delphi side of the Python Ecosystem with the new Python Data Sciences Libraries and related projects that make it super easy write Delphi code against Python libraries and easily deploy on Windows, Linux, MacOS, and Android. Specific examples with the Python Natural Language Toolkit and PyTorch, the library that powers projects like Tesla Autopilot, Uber's Pyro, Hugging Face's Transformers. This is part of a series of regular live streams discussing the latest in Embarcadero open source projects. Hosted by Jim McKeeth and joined by members of the community and developers involved in these open source projects, as well as members of Embarcadero and Idera’s Product Management. A great opportunity to see behind the scenes and help shape the future of Embarcadero’s Open Source projects. If you are interested in machine learning, artificial intelligence, or data sciences then you want to join this webinar! Description Slides, replay, links, etc. blogs.embarcadero.com/?p=145025
  • 3. Who’s on the Stream? ● Jim McKeeth - Embarcadero Developer Relations ● Kunarapu Priyatham - Python Developer & Tech Writer ● Lucas Moura Belo - Delphi & Python Developer ● Kiriakos Vlahos - Maintainer of PyScripter and Python4Delphi ● Chris Gardner - Whole Tomato Visual Assist Lead Developer ● Marco Cantu - RAD Studio & Delphi PM ● And others who may or may not chime in . . . Priyatham Jim Lucas Chris Kiriakos
  • 4. We Need More Components! ● We are more productive when there is an existing component or library already ● Delphi and C++Builder has a huge rich ecosystem of Tech Partners and open source ● But wouldn’t be great to have EVEN MORE? ● Python has one of the richest ecosystems, especially for data sciences, AI, & ML ● What if Delphi & C++Builder could easily USE THEM ALL?
  • 5. XKCD on Python There is a package for everything! ● xkcd.com/353/ from December 5th, 2007 ● explainxkcd.com/wiki/index.php/353:_Python [A friend is talking to Cueball, who is floating in the sky.] Friend: You're flying! How? Cueball: Python! Cueball: I learned it last night! Everything is so simple! Cueball: Hello world is just pr i nt " He l l o, W or l d! " Friend: I dunno... Dynamic typing? Whitespace? Cueball: Come join us! Programming is fun again! It's a whole new world up here! Friend: But how are you flying? Cueball: I just typed 'i mpor t a nt i gr a vi t y' Friend: That's it? Cueball: ...I also sampled everything in the medicine cabinet for comparison. Cueball: But I think this is the python. In response to this comic, the Python developers implemented the module a nt i gr a vi t y. When you import it, the default web browser will open this comic.
  • 6. General Notes and Comments ● Most all projects are open source, MIT licensed, and hosted on GitHub. ● Embarcadero is directly sponsoring the developers and development. ● While the focus is on Delphi, we expect C++Builder will work eventually. ○ Once the Delphi side is stable we will look more closely at C++Builder where it makes sense. ○ There are already resources showing how to use Python4Delphi with C++Builder. ● All of these projects are available and mostly working today. ○ They are under active development, so consider them beta or alpha releases…. ● Unless otherwise stated, everything works on ○ Android, Windows (32 & 64-bit), MacOS (x86 & ARM), and Linux ● We are looking for feedback, pull requests, contributors, and forks on all Embarcadero Open Source projects! ● ⭐ Starring a project is a great way to show your interest!
  • 7. It’s not a Competition ● Language choice isn’t a zero sum game. ● Developers have multiple tools on their workbench. ● When tools work together then a developer can use both! ● It is about finding the right tool for each task. ● We use SQL to talk to databases, JavaScript and HTML run the web. ● Having specialized tools for different tasks doesn’t detract from favorite tools. ● You can always find a specific task that another tool is better for, but no one tool is that best for all tasks.
  • 8. Python Delphi Tensorflow NumPy etc. GitHub GetIt Boss Chocolatey PyPi Conda Forge Python Developers Delphi Developers Delphi Extensions for Python Python4Delphi PyScripter DelphiVCL DelphiFMX Lightweight Python Wrappers P4D Data Sciences Python Environments PIP FMX App Builder D4P Exporter
  • 9. Python and Delphi Ecosystem 1. Free Python IDE and libraries ○ Free give away to Python developers. 2. Use designer export from Delphi ○ Dipping toe into Delphi CE or a free trial. 3. Import Python libraries into Delphi ○ Starting to explore the power of hybrid apps. 4. Build native Delphi modules for Python ○ Use Delphi’s native compiler to add speed and features to Python. 5. Full Hybrid Delphi + Python Power ○ The ultimate stage of development, ushering in the final technological singularity, leading to total universal domination and the enlightenment of all humankind. PyScripter, DelphiFMX, DelphiVCL Lightweight Python Wrappers & Data Sciences Python4Delphi & Delphi Extensions for Python Available via GetIt.
  • 10. Python4Delphi: The Bridge Python for Delphi (P4D) is a set of components that wrap up the Python Library into Delphi. They let Delphi developers easily execute Python scripts, create new Python modules, and new Python types. You can create Python extension modules and much more. P4D provides different levels of functionality: ● Low-level access to the Python API ● High-level bi-directional interaction with Python ● Access to Python objects using Delphi custom variants (VarPyth.pas) ● Wrapping of Delphi objects for use in Python scripts using RTTI (WrapDelphi.pas) ● Creating Python extension modules with Delphi classes and functions Supports Android (64-bit ARM), Windows (32 & 64-bit x86), MacOS (x86 & ARM), and Linux (64-bit x86) Embarcadero’s Fork of P4D github.com/Embarcadero/Python4Delphi Originally maintained by Kiriakos Vlahos (aka PyScripter)
  • 11. ● GitHub - Where all the projects are hosted: github.com/embarcadero ● GetIt - The Embarcadero package manager. When the projects for Delphi developers are ready for general use they can easily be installed via GetIt. getitnow.embarcadero.com ● Boss - Delphi dependency manager. Plan to use to make it easy to manage dependencies between projects. github.com/hashload/boss ● Chocolatey - General Windows package manager. Simplify deployment and installation of development builds. ● pip - Package Installer for Python pip.pypa.io ● PyPi - The Python Package Index is the official third-party software repository for Python. Default source for pip. pypi.org/user/Embarcadero ● Conda - Alternative and very popular Python package manager. docs.conda.io ● Conda Forge - Community-led collection of distributions for the conda package manager. conda-forge.org Other Pieces in the Ecosystem GitHub Boss Chocolatey PyPi Conda Forge GetIt pip
  • 12. For Delphi Developers Bringing the best of Python to Delphi developers. Pure Object Pascal access to Python libraries.
  • 13. Goals ● Give Delphi (and eventually C++Builder) developers access to all Python libraries ● No Python knowledge or code required ● But still give full access ● Simple development setup ● Simple end user deployment ● No internet connection required ● Cross platform This is an early access preview, but you are invited to start using and contributing.
  • 14. Three All New Projects Powered by Python4Delphi
  • 15. Python Environments ● Delphi components that simplify the deployment and configuration of Python environments ● Freeing Delphi developers from needing to worry about Python ● Supports Python versions 3.7, 3.8, 3.9, & 3.10 ● Currently 3 different options: ○ Use an existing Python environment ○ Redistribute or download a Python environment archive ○ Embed the redistributable within the program ● At runtime it automatically verifies and configures the environment, including PIP or Conda package managers ● The framework is very modular, flexible, and customizable ● Installs necessary Python modules ● Working on Android, Windows (32 & 64-bit), MacOS (x86 & ARM), and Linux Early Alpha - Should mostly work, still adding features github.com/Embarcadero/PythonEnviroments/ For Delphi Developers
  • 16. Lightweight Python Wrappers ● Framework for creating a lightweight wrapper around a Python library turning it into a Delphi component ● Makes adding a new Python library super quick and easy ● Manages the necessary Python modules via pip or Conda ● Allows for a simple translation of Python code into Delphi code ● Uses late binding giving it a more flexible syntax ● Letting Delphi developers use pure Delphi to access Python libraries To Do: ● Automatic wrapper generation ● Python to Delphi code translation ● Code completion and better IDE integration ● Your suggestions! Early Alpha - Should mostly work, still adding features github.com/Embarcadero/Lightweight-Python-Wrappers For Delphi Developers
  • 17. P4D Data Sciences ● Based on the Lightweight Python Wrappers, Python Environments, and Python4Delphi ● Delphi components for popular Python Data Sciences tools ● Currently includes: ○ Tensorflow, NumPy, PyTorch Vision, PyTorch, MatPlotLib, Natural Language Toolkit (NLTK), OpenCV, and Scikit-learn ● Even includes some samples ● Surprisingly easy to make and use ○ Literally a couple hours work to add and test a new library ● Looking at additional libraries to add…. Early Alpha - Should mostly work, still adding features github.com/Embarcadero/P4D-Data-Sciences Even includes some demos For Delphi Developers
  • 18. Example of adding a library: Natural Language Toolkit (NLTK) For Delphi Developers
  • 19. Natural Language Toolkit (NLTK) ● This is the code to wrap a new Python library for Delphi ● Looking into automatic importer ● All the details and complexity are encapsulated in the Lightweight Python Wrappers ● The Python Environment handles all the requirements and installation unit NLTK; procedure TNLTK.Prepare( const AModel: TPyPackageModel); begin inherited ; with AModel do begin PackageName := 'nltk' ; PackageManagers.Add(TPyPackageManagerKind. pip , TPyPackageManagerPip.Create( 'nltk' )); end; end; ● Name of Python module ● Package manager for installation For Delphi Developers
  • 20. ● Simple code found on nltk.org ● Showing off basic functionality ● Python code running in the REPL, with results displayed inline Demo Tokenize and tag some text: >>> import nltk >>> nltk.download( 'popular' ) >>> sentence = """At eight o'clock on Thursday morning ... Arthur didn't feel very good.""" >>> tokens = nltk . word_tokenize(sentence) >>> tokens ['At', 'eight', "o'clock", 'on', 'Thursday', 'morning', 'Arthur', 'did', "n't", 'feel', 'very', 'good', '.'] >>> tagged = nltk . pos_tag(tokens) >>> tagged[ 0: 6] [('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'), ('Thursday', 'NNP'), ('morning', 'NN')] Identify named entities: >>> entities = nltk . chunk . ne_chunk(tagged) >>> entities Tree('S', [('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'), ('Thursday', 'NNP'), ('morning', 'NN'), Tree('PERSON', [('Arthur', 'NNP')]), ('did', 'VBD'), ("n't", 'RB'), ('feel', 'VB'), ('very', 'RB'), ('good', 'JJ'), ('.', '.')]) Downloads the required data. Only necessary once.
  • 21. ● There are a series of event handlers notifying your program of state of the Python Environment. ● Here is the Delphi version of the Python code. ● The output of each step is displayed in the list boxes. ● When compiled there is a single EXE. ● At runtime the Environment sets up a nested Python environment with all the necessary dependencies. Demo with NLTK1 do begin nltk.download( 'popular' ); var tokens := nltk.word_tokenize(memo1.lines.Text); VarPyToStrings(tokens,ListBox1.Items); var tagged := nltk.pos_tag(tokens); VarPyToStrings(tagged,ListBox2.Items); var entities := nltk.chunk.ne_chunk(tagged); VarPyToStrings(entities, ListBox3.Items); end; For Delphi Developers
  • 22. ● Add the following components: ○ TPythonEngine ○ TPyEmbeddedResEnvironment310 ○ TNumPy ○ TNLTK ● Connect the components ● Make the UI ● Leave the Tokenize button disabled, then use an event handler from the Environment to enable it when everything is setup. Demo For Delphi Developers
  • 23. ● One first run the Environment is setup with all dependencies. Usually takes a few seconds. ● On subsequent runs it takes a second to validate the environment, load the libraries, and start the engine. ● The program uses the event handlers to enable the user interface based on the state. Demo For Delphi Developers
  • 24. ● The Python environment can be installed anywhere (or an existing one can be used) but the default is the EXE folder. ● It can also be created during the installation process, before the program first runs. ● Here we see our sample program in 43 MB. ● And it extracted and created a 95 MB Python environment. ● The same project can compile and run identically on Android, Windows (32 & 64-bit), MacOS (x86 & ARM), and Linux Demo For Delphi Developers
  • 25. Demo with Delphi For Delphi Developers
  • 26. Demo ● PyTorch is an open source machine learning framework 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) ● Used in projects like Tesla Autopilot, Uber's Pyro, Hugging Face's Transformers, and others ● Delphi demo is part of P4D Data Sciences ○ This is a Thumbs Up and Thumbs Down image classification system with mobile image collection ○ github.com/Embarcadero/P4D-Data-Sciences/tree/main/demos/PyTorch/ ■ App - Android App Source ■ Install - Installs dependencies and sets up environment on server ■ Server - WebBroker server ■ Train - Called by server to do the training and process the data ■ Training_Data - Pre collected images
  • 27. What’s Next? It’s still early access, but what else is possible?
  • 28. What’s Next ● Still more work - in early stages of development ● Automatic wrapper generation ● More libraries ● Python to Delphi code translation ○ Translate Python sample code ● Documentation for the full stack and for using the imported libraries ● Code completion and better IDE integration ● Your suggestions!
  • 29. Other Potential Python Libraries ● Keras - ML library that runs on both CPU and GPU ● LightGBM by Microsoft - Used for ML ranking, classification, etc. ● Aesara - Multi-dimensional arrays mathematical expressions ● BeautifulSoup - Scrapes data from web pages ● Pillow - Image manipulation ● MoviePy - Video Editing ● Seaborn - Drawing attractive statistical graphics ● YOLOv5 - Pretrained object detection architectures and models lightgbm.readthedocs.io aesara.readthedocs.io keras.io crummy.com/software/BeautifulSoup/ Python Pillow python-pillow.org zulko.github.io/moviepy seaborn.pydata.org For Delphi Developers
  • 30. ● See the list of the most popular Python packages on PyPi in the last 30 days. ● None of these are on the previous slides. ● Can every Python library be available for Delphi developers? One way to find out…. pypistats.org/top - pypi.org Tip of the Iceberg Rank Library Downloads 1 boto3 343,267,820 2 urllib3 214,453,654 3 botocore 211,027,562 4 requests 206,502,136 5 idna 176,641,902 6 setuptools 173,382,430 7 s3transfer 171,067,399 8 typing-extensions 165,570,269 9 six 156,492,192 10 certifi 151,478,041 11 python-dateutil 149,953,838 12 pyyaml 142,509,567 13 charset-normalizer 139,528,384 14 awscli 122,370,481 15 click 117,707,552 16 wheel 115,961,643 17 cryptography 110,978,677 18 jinja2 109,342,363 19 pyparsing 103,909,140 20 rsa 103,612,934 For Delphi Developers
  • 31. ● Try the projects ● Star the projects on GitHub ● File bug reports ● Make a fork ● Issue a pull request ● Add features and fix bugs ● Tell your friends ● Write a blog post ● Make a demo We Need Your Help!
  • 32. Q & A
  • 33. General Notes and Comments ● Most all projects are open source, MIT licensed, and hosted on GitHub. ● Embarcadero is directly sponsoring the developers and development. ● While the focus is on Delphi, we expect C++Builder will work eventually. ○ Once the Delphi side is stable we will look more closely at C++Builder where it makes sense. ○ There are already resources showing how to use Python4Delphi with C++Builder. ● All of these projects are available and mostly working today. ○ They are under active development, so consider them beta or alpha releases…. ● Unless otherwise stated, everything works on ○ Android, Windows (32 & 64-bit), MacOS (x86 & ARM), and Linux ● We are looking for feedback, pull requests, contributors, and forks on all Embarcadero Open Source projects! ● ⭐ Starring a project is a great way to show your interest!
  • 34. PyTorch for Delphi with the Python Data Science Libraries