SlideShare a Scribd company logo
RESTful Machine
Learning with Flask and
TensorFlow Serving
Carlo Mazzaferro
Data Scientist
ByteCubed
PyData DC 2018
Goals
● Explain some common problems that arise when developing
machine learning products
● Describe some of the solutions that are leveraged to solve those
problems, alongside with their limitations
● Open source a library
Background
● BS Biomed Eng/Bioinformatics
● DNA stuff
○ Lots of data (wrangling)
○ Data pipelines
○ Data management
Background
● BS Biomed Eng/Bioinformatics
● DNA stuff
○ Lots of data (wrangling)
○ Data pipelines
○ Data management
○ Data Science aspirant
● Currently
○ ML Engineering @ ByteCubed
○ Some frontend work
Background
● Currently
○ ML Engineering @ ByteCubed
○ Some frontend work
○ Putting models in the client’s hands
● Since always
○ Workflow optimization for ML/DS
Takeaways
● To make great products
○ Repeatability matters
○ Ease of deployment matters
○ Quick iteration is key
○ 80-20 rule
Ultimately, reduce friction between R&D and the rest of the Software Practice
Takeaways
● To make great products
○ Do machine learning like the great engineer you are, not like the great machine learning expert
you aren’t.
[Google’s best practices for ML]
○ Provide DS with the right tooling, and the entire organization will benefit
TensorFlow Serving
A high-performance serving system for machine learning models, designed for production environments
Capabilities
● High-performance inference
● Model discovery
● RPC interface (gRPC and REST)
● Much more: tensorflow.org/serving
How?
A high-performance serving system for machine learning models, designed for production environments
Capabilities
● Keeping models loaded without needing to restore the dataflow graph and
session
● gRPC interface for high-performance, low-latency inference
● Low-level control on how models are loaded
○ C++ API
● Relies on a C++ API for low-level control
● Undocumented Python API
○ Small subset of features implemented
● gRPC API only
○ REST API (for inference only) introduced in August
Limitations
A high-performance serving system for machine learning models, designed for production environments
● Pythonic API ✅
● JSON + REST ✅
● Test different models, architectures, configurations ✅
● Track models over time ✅
Needs
A high-performance serving system for machine learning models, designed for production environments
Current state
Existing solutions
● Clipper.ai → great, but not very active (last commit in June)
● P/SaaS platforms (Algorithmia, Rekognition, etc.)
● Mlflow.org → R&D, tracking of model performance
● Custom solutions of varied quality
Model deployment frameworks
Introducing racket
Minimalistic framework for ML model deployment & management
● Access to most of the TensorFlow Serving functionality in a Pythonic way
● Model exploration and deployment, consolidated
racket
Motivation
● Automation
○ Quick iteration
● Reduce boilerplate
○ Versioning & serving
● Exploration & visibility
○ Loading a different version
○ Ability to track & query model performance
● Flexibility
○ Multiple models can be loaded and are accessible through a simple API
racket
Features
● Automated model version
● RESTful interface with rich capabilities
○ Loading a different model
○ Loading a different version
○ Ability to track & query model performance
● Automatic API documentation with Swagger
● Train, explore, and deploy with a single tool
● CLI access
● Static typing
ML For Humans
Enabling integration with non-ml experts:
Developer perspective
● REST access
○ Ease of integration
● Ease of deployment
○ Containers not just an afterthought
● Visibility: discover shapes of inputs
needed, shapes of outputs
+
ML For Humans
Enabling integration with non-ml experts:
Data Scientist perspective
from racket import KerasLearner
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras.callbacks import TensorBoard
class KerasModel(KerasLearner):
VERSION = '1.1.1'
MODEL_TYPE = 'regression'
MODEL_NAME = 'keras-simple-regression'
def build_model(self):
optimizer = tf.train.RMSPropOptimizer(0.001)
model = Sequential()
model.add(Dense(24, input_dim=5, kernel_initializer='normal', activation='relu'))
model.add(Dense(48, kernel_initializer='normal', activation='relu'))
model.add(Dense(1, kernel_initializer='normal'))
model.compile(loss='mean_absolute_error', optimizer=optimizer)
return model
def fit(self, x, y, x_val=None, y_val=None, epochs=2, batch_size=20):
self.model.fit(x, y, epochs=epochs, verbose=0, validation_data=(x_val, y_val))
if __name__ == '__main__':
X_train, X_test, y_train, y_test = train_test_split(x, y)
kf = KerasModel()
kf.fit(X_train, y_train, x_val=X_test, y_val=y_test)
kf.store(autoload=True)
● Define model, rest is taken care of
● Scoring done automatically
○ Including user-defined/multiple
metrics
● Access to previous runs’ data
● Multiple models & versions
Quick demo
Demo link: https://asciinema.org/a/xxoebEfyu1bzO84hWWAams577
Docs: https://r-racket.readthedocs-hosted.com/en/latest/
Code: https://github.com/carlomazzaferro/racket
Moving Forward
● Needs
○ Support for batching requests
○ Better testing
○ Deployment guide
■ Kubernetes & co.
○ Feature parity on CLI vs REST access
Questions ?

More Related Content

What's hot (20)

PDF
Machine Learning Platformization & AutoML: Adopting ML at Scale in the Enterp...
Ed Fernandez
 
PDF
Data Versioning and Reproducible ML with DVC and MLflow
Databricks
 
PDF
MLOps for production-level machine learning
cnvrg.io AI OS - Hands-on ML Workshops
 
PDF
Introduction to MLflow
Databricks
 
PPTX
From Data Science to MLOps
Carl W. Handlin
 
PPTX
Customer case - Dynatrace Monitoring Redefined
Michel Duruel
 
PPTX
Dynatrace: New Approach to Digital Performance Management - Gartner Symposium...
Michael Allen
 
PDF
MLOps Bridging the gap between Data Scientists and Ops.
Knoldus Inc.
 
PPTX
MLOps and Reproducible ML on AWS with Kubeflow and SageMaker
Provectus
 
PDF
Experimentation to Industrialization: Implementing MLOps
Databricks
 
PDF
Apply MLOps at Scale by H&M
Databricks
 
PDF
Automated Machine Learning
Yuriy Guts
 
PDF
Knowledge Graphs and Generative AI
Neo4j
 
PPTX
MLOps in action
Pieter de Bruin
 
PDF
Enterprise Knowledge Graph
Lukas Masuch
 
PDF
MLflow: Infrastructure for a Complete Machine Learning Life Cycle
Databricks
 
PDF
Simplifying Model Management with MLflow
Databricks
 
PPTX
MLOps and Data Quality: Deploying Reliable ML Models in Production
Provectus
 
PDF
Drifting Away: Testing ML Models in Production
Databricks
 
PDF
SciPipe - A light-weight workflow library inspired by flow-based programming
Samuel Lampa
 
Machine Learning Platformization & AutoML: Adopting ML at Scale in the Enterp...
Ed Fernandez
 
Data Versioning and Reproducible ML with DVC and MLflow
Databricks
 
MLOps for production-level machine learning
cnvrg.io AI OS - Hands-on ML Workshops
 
Introduction to MLflow
Databricks
 
From Data Science to MLOps
Carl W. Handlin
 
Customer case - Dynatrace Monitoring Redefined
Michel Duruel
 
Dynatrace: New Approach to Digital Performance Management - Gartner Symposium...
Michael Allen
 
MLOps Bridging the gap between Data Scientists and Ops.
Knoldus Inc.
 
MLOps and Reproducible ML on AWS with Kubeflow and SageMaker
Provectus
 
Experimentation to Industrialization: Implementing MLOps
Databricks
 
Apply MLOps at Scale by H&M
Databricks
 
Automated Machine Learning
Yuriy Guts
 
Knowledge Graphs and Generative AI
Neo4j
 
MLOps in action
Pieter de Bruin
 
Enterprise Knowledge Graph
Lukas Masuch
 
MLflow: Infrastructure for a Complete Machine Learning Life Cycle
Databricks
 
Simplifying Model Management with MLflow
Databricks
 
MLOps and Data Quality: Deploying Reliable ML Models in Production
Provectus
 
Drifting Away: Testing ML Models in Production
Databricks
 
SciPipe - A light-weight workflow library inspired by flow-based programming
Samuel Lampa
 

Similar to RESTful Machine Learning with Flask and TensorFlow Serving - Carlo Mazzaferro (20)

PDF
TensorFlow meetup: Keras - Pytorch - TensorFlow.js
Stijn Decubber
 
PDF
Managing the Machine Learning Lifecycle with MLOps
Fatih Baltacı
 
PDF
TensorFlow and Keras: An Overview
Poo Kuan Hoong
 
PDF
MLflow Model Serving
Databricks
 
PPTX
MLflow Model Serving - DAIS 2021
amesar0
 
PPTX
Demystifying-AI-Frameworks-TensorFlow-PyTorch-JAX-and-More (1).pptx
Anant Garg
 
PDF
Reproducible AI using MLflow and PyTorch
Databricks
 
PDF
Scaling up Machine Learning Development
Matei Zaharia
 
PDF
Tensorflow 2.0 and Coral Edge TPU
Andrés Leonardo Martinez Ortiz
 
PPTX
DAIS Europe Nov. 2020 presentation on MLflow Model Serving
amesar0
 
PPTX
python_libraries_for_artificial_intelligence.pptx
salehaalsaleh602
 
PPTX
Machine Learning Toolssssssssssssss.pptx
salehaalsaleh602
 
PDF
Reproducible AI Using PyTorch and MLflow
Databricks
 
PDF
Machine learning from software developers point of view
Pierre Paci
 
PDF
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Universitat Politècnica de Catalunya
 
PDF
running Tensorflow in Production
Matthias Feys
 
PDF
Lecture 4: Deep Learning Frameworks
Mohamed Loey
 
PDF
Reproducible AI Using PyTorch and MLflow
Databricks
 
PDF
DutchMLSchool 2022 - Automation
BigML, Inc
 
PDF
DutchMLSchool. ML Automation
BigML, Inc
 
TensorFlow meetup: Keras - Pytorch - TensorFlow.js
Stijn Decubber
 
Managing the Machine Learning Lifecycle with MLOps
Fatih Baltacı
 
TensorFlow and Keras: An Overview
Poo Kuan Hoong
 
MLflow Model Serving
Databricks
 
MLflow Model Serving - DAIS 2021
amesar0
 
Demystifying-AI-Frameworks-TensorFlow-PyTorch-JAX-and-More (1).pptx
Anant Garg
 
Reproducible AI using MLflow and PyTorch
Databricks
 
Scaling up Machine Learning Development
Matei Zaharia
 
Tensorflow 2.0 and Coral Edge TPU
Andrés Leonardo Martinez Ortiz
 
DAIS Europe Nov. 2020 presentation on MLflow Model Serving
amesar0
 
python_libraries_for_artificial_intelligence.pptx
salehaalsaleh602
 
Machine Learning Toolssssssssssssss.pptx
salehaalsaleh602
 
Reproducible AI Using PyTorch and MLflow
Databricks
 
Machine learning from software developers point of view
Pierre Paci
 
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Universitat Politècnica de Catalunya
 
running Tensorflow in Production
Matthias Feys
 
Lecture 4: Deep Learning Frameworks
Mohamed Loey
 
Reproducible AI Using PyTorch and MLflow
Databricks
 
DutchMLSchool 2022 - Automation
BigML, Inc
 
DutchMLSchool. ML Automation
BigML, Inc
 
Ad

More from PyData (20)

PDF
Michal Mucha: Build and Deploy an End-to-end Streaming NLP Insight System | P...
PyData
 
PDF
Unit testing data with marbles - Jane Stewart Adams, Leif Walsh
PyData
 
PDF
The TileDB Array Data Storage Manager - Stavros Papadopoulos, Jake Bolewski
PyData
 
PDF
Using Embeddings to Understand the Variance and Evolution of Data Science... ...
PyData
 
PDF
Deploying Data Science for Distribution of The New York Times - Anne Bauer
PyData
 
PPTX
Graph Analytics - From the Whiteboard to Your Toolbox - Sam Lerma
PyData
 
PPTX
Do Your Homework! Writing tests for Data Science and Stochastic Code - David ...
PyData
 
PDF
Mining dockless bikeshare and dockless scootershare trip data - Stefanie Brod...
PyData
 
PDF
Avoiding Bad Database Surprises: Simulation and Scalability - Steven Lott
PyData
 
PDF
Words in Space - Rebecca Bilbro
PyData
 
PDF
End-to-End Machine learning pipelines for Python driven organizations - Nick ...
PyData
 
PPTX
Pydata beautiful soup - Monica Puerto
PyData
 
PDF
1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...
PyData
 
PPTX
Extending Pandas with Custom Types - Will Ayd
PyData
 
PDF
Measuring Model Fairness - Stephen Hoover
PyData
 
PDF
What's the Science in Data Science? - Skipper Seabold
PyData
 
PDF
Applying Statistical Modeling and Machine Learning to Perform Time-Series For...
PyData
 
PDF
Solving very simple substitution ciphers algorithmically - Stephen Enright-Ward
PyData
 
PDF
The Face of Nanomaterials: Insightful Classification Using Deep Learning - An...
PyData
 
PDF
Deprecating the state machine: building conversational AI with the Rasa stack...
PyData
 
Michal Mucha: Build and Deploy an End-to-end Streaming NLP Insight System | P...
PyData
 
Unit testing data with marbles - Jane Stewart Adams, Leif Walsh
PyData
 
The TileDB Array Data Storage Manager - Stavros Papadopoulos, Jake Bolewski
PyData
 
Using Embeddings to Understand the Variance and Evolution of Data Science... ...
PyData
 
Deploying Data Science for Distribution of The New York Times - Anne Bauer
PyData
 
Graph Analytics - From the Whiteboard to Your Toolbox - Sam Lerma
PyData
 
Do Your Homework! Writing tests for Data Science and Stochastic Code - David ...
PyData
 
Mining dockless bikeshare and dockless scootershare trip data - Stefanie Brod...
PyData
 
Avoiding Bad Database Surprises: Simulation and Scalability - Steven Lott
PyData
 
Words in Space - Rebecca Bilbro
PyData
 
End-to-End Machine learning pipelines for Python driven organizations - Nick ...
PyData
 
Pydata beautiful soup - Monica Puerto
PyData
 
1D Convolutional Neural Networks for Time Series Modeling - Nathan Janos, Jef...
PyData
 
Extending Pandas with Custom Types - Will Ayd
PyData
 
Measuring Model Fairness - Stephen Hoover
PyData
 
What's the Science in Data Science? - Skipper Seabold
PyData
 
Applying Statistical Modeling and Machine Learning to Perform Time-Series For...
PyData
 
Solving very simple substitution ciphers algorithmically - Stephen Enright-Ward
PyData
 
The Face of Nanomaterials: Insightful Classification Using Deep Learning - An...
PyData
 
Deprecating the state machine: building conversational AI with the Rasa stack...
PyData
 
Ad

Recently uploaded (20)

PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Impact of IEEE Computer Society in Advancing Emerging Technologies including ...
Hironori Washizaki
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 

RESTful Machine Learning with Flask and TensorFlow Serving - Carlo Mazzaferro

  • 1. RESTful Machine Learning with Flask and TensorFlow Serving Carlo Mazzaferro Data Scientist ByteCubed PyData DC 2018
  • 2. Goals ● Explain some common problems that arise when developing machine learning products ● Describe some of the solutions that are leveraged to solve those problems, alongside with their limitations ● Open source a library
  • 3. Background ● BS Biomed Eng/Bioinformatics ● DNA stuff ○ Lots of data (wrangling) ○ Data pipelines ○ Data management
  • 4. Background ● BS Biomed Eng/Bioinformatics ● DNA stuff ○ Lots of data (wrangling) ○ Data pipelines ○ Data management ○ Data Science aspirant ● Currently ○ ML Engineering @ ByteCubed ○ Some frontend work
  • 5. Background ● Currently ○ ML Engineering @ ByteCubed ○ Some frontend work ○ Putting models in the client’s hands ● Since always ○ Workflow optimization for ML/DS
  • 6. Takeaways ● To make great products ○ Repeatability matters ○ Ease of deployment matters ○ Quick iteration is key ○ 80-20 rule Ultimately, reduce friction between R&D and the rest of the Software Practice
  • 7. Takeaways ● To make great products ○ Do machine learning like the great engineer you are, not like the great machine learning expert you aren’t. [Google’s best practices for ML] ○ Provide DS with the right tooling, and the entire organization will benefit
  • 8. TensorFlow Serving A high-performance serving system for machine learning models, designed for production environments Capabilities ● High-performance inference ● Model discovery ● RPC interface (gRPC and REST) ● Much more: tensorflow.org/serving
  • 9. How? A high-performance serving system for machine learning models, designed for production environments Capabilities ● Keeping models loaded without needing to restore the dataflow graph and session ● gRPC interface for high-performance, low-latency inference ● Low-level control on how models are loaded ○ C++ API
  • 10. ● Relies on a C++ API for low-level control ● Undocumented Python API ○ Small subset of features implemented ● gRPC API only ○ REST API (for inference only) introduced in August Limitations A high-performance serving system for machine learning models, designed for production environments
  • 11. ● Pythonic API ✅ ● JSON + REST ✅ ● Test different models, architectures, configurations ✅ ● Track models over time ✅ Needs A high-performance serving system for machine learning models, designed for production environments
  • 12. Current state Existing solutions ● Clipper.ai → great, but not very active (last commit in June) ● P/SaaS platforms (Algorithmia, Rekognition, etc.) ● Mlflow.org → R&D, tracking of model performance ● Custom solutions of varied quality Model deployment frameworks
  • 13. Introducing racket Minimalistic framework for ML model deployment & management ● Access to most of the TensorFlow Serving functionality in a Pythonic way ● Model exploration and deployment, consolidated
  • 14. racket Motivation ● Automation ○ Quick iteration ● Reduce boilerplate ○ Versioning & serving ● Exploration & visibility ○ Loading a different version ○ Ability to track & query model performance ● Flexibility ○ Multiple models can be loaded and are accessible through a simple API
  • 15. racket Features ● Automated model version ● RESTful interface with rich capabilities ○ Loading a different model ○ Loading a different version ○ Ability to track & query model performance ● Automatic API documentation with Swagger ● Train, explore, and deploy with a single tool ● CLI access ● Static typing
  • 16. ML For Humans Enabling integration with non-ml experts: Developer perspective ● REST access ○ Ease of integration ● Ease of deployment ○ Containers not just an afterthought ● Visibility: discover shapes of inputs needed, shapes of outputs +
  • 17. ML For Humans Enabling integration with non-ml experts: Data Scientist perspective from racket import KerasLearner from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense from tensorflow.keras.callbacks import TensorBoard class KerasModel(KerasLearner): VERSION = '1.1.1' MODEL_TYPE = 'regression' MODEL_NAME = 'keras-simple-regression' def build_model(self): optimizer = tf.train.RMSPropOptimizer(0.001) model = Sequential() model.add(Dense(24, input_dim=5, kernel_initializer='normal', activation='relu')) model.add(Dense(48, kernel_initializer='normal', activation='relu')) model.add(Dense(1, kernel_initializer='normal')) model.compile(loss='mean_absolute_error', optimizer=optimizer) return model def fit(self, x, y, x_val=None, y_val=None, epochs=2, batch_size=20): self.model.fit(x, y, epochs=epochs, verbose=0, validation_data=(x_val, y_val)) if __name__ == '__main__': X_train, X_test, y_train, y_test = train_test_split(x, y) kf = KerasModel() kf.fit(X_train, y_train, x_val=X_test, y_val=y_test) kf.store(autoload=True) ● Define model, rest is taken care of ● Scoring done automatically ○ Including user-defined/multiple metrics ● Access to previous runs’ data ● Multiple models & versions
  • 18. Quick demo Demo link: https://asciinema.org/a/xxoebEfyu1bzO84hWWAams577 Docs: https://r-racket.readthedocs-hosted.com/en/latest/ Code: https://github.com/carlomazzaferro/racket
  • 19. Moving Forward ● Needs ○ Support for batching requests ○ Better testing ○ Deployment guide ■ Kubernetes & co. ○ Feature parity on CLI vs REST access