TensorFlow.js - Serve deep learning models with Node.js and Express
Key Takeaways
This video demonstrates how to serve deep learning models with Node.js and Express using TensorFlow.js, covering the setup of a web server to host deep learning web applications and serve static files.
Full Transcript
what's up guys in this video we'll go through the process of getting a web server set up to host deep learning web applications and serve deep learning models with Express for nodejs so let's get to it to build deep learning applications that run in the browser we need a way to host these applications and a way to host the models so then really we just need a way to serve static files if you follow the series on deploying Kerris models then you know that we already have a relatively easy way of hosting static files and that's with flask blast though is written in Python and while it would work perfectly fine to host the tensorflow j/s applications will be developing it makes sense that we might want to use a JavaScript based technology to host our apps since we're kind of breaking away from Python and embracing JavaScript in this series so enter Express for nodejs express is a minimalist web framework very similar to flask but is for node.js not Python and if you're not already familiar with node.js then you're probably wondering what it is as well no js' which will refer to most of the time as just node is an open-source runtime environment that executes JavaScript on the server side C historically JavaScript has been used mainly for client-side applications like browser applications for example but node allows us to write server-side code using JavaScript will specifically be making use of express to host our web applications and serve our models so let's see how we can do that now first things first we need to install node.js I'm here on the downloads page of nodes website so you just need to navigate to this page choose the installation for your operating system and get it installed I've installed node on a Windows machine but you'll still be able to follow the demos we'll see in a few moments even if you're running another operating system all right after we've got node installed we need to create a directory that will hold all of our project files so we have this directory here I've called tensorflow j/s within this directory we'll create a sub directory called local server which is where the Express code that will run our web server will reside and will also create a static directory which is where our web pages and eventually our models will reside within this local server we create a package.json file which is going to allow us to specify the packages that our project depends on let's go ahead and open this file I've opened this with Visual Studio code which is a free open source code editor developed by Microsoft that can run on Windows Linux and Mac OS this is what we'll be using to write our code so you can download it and use it yourself as well or you can use any other editor that you'd like all right back to the package.json file within package.json we're going to specify a name for our project which we're calling in tensorflow j s all lowercase per the requirements of this file will also specify the version of our project there are some specs that the format of this version has to meet but most simplistically it has to be in an xxx format so we're just going to go with the default of 1.0.0 all right name and version are the only two requirements for this file but there are several other optional items we can add like a description the author and a few others we're not going to worry about this stuff but we are going to add one more thing the dependencies this specifies the dependencies that our project needs to run we're specifying Express here since that's what we'll be using to host our web apps and we're also specifying the version now we're going to open PowerShell and we have the ability to open it from right within this editor by navigating to view and then integrated terminal and you should have the ability to open the terminal of your choice that's appropriate for your operating system if you're running on Linux for example and don't have PowerShell otherwise you can just open a terminal outside of the editor if you'd like all right so from within PowerShell we make sure we're inside of the local server directory where the package.json file is and we're going to run NPM install NPM stands for node package manager and by running NPM install NPM will download and install the dependencies listed in our package JSON file so let's run NPM install we'll see it installs Express and when this is finished you can see that we now have an added node modules directory that contains the downloaded packages and we additionally have this package law JSON file that we didn't have before it contains information about the downloaded dependencies don't delete these things all right so at this point we have node we have Express now we need to write a node program that will start the Express server and will host the files that we specify let's see that makes sense to do this we'll create this file called server jeaious inside a server j/s we first import Express using require Express using require like this will import the Express module and give our program access to it you can think of a module and node as being analogous to a library in JavaScript or Python just a group of functions that we want to have access to from within our program and then we create an Express application using the Express module which we assign to app an Express app is essentially a series of calls to functions that we call middleware functions middleware functions have access to the HTTP request and response objects as well as the next function in the applications request response cycle which just passes control to the next handler so within this app when a request comes in we're doing two things we're first logging information about the request to the terminal where the Express server is running and we then pass control to the next handler which will respond by serving any static files that we've placed in this directory called static that's right within the root directory of our tensorflow j/s project so in our case the middleware functions I mentioned are here and here note that the calls to app dot use are only called once and that's when the server is started the app dot used calls specify the middleware functions and calls to those middleware functions will be executed each time a request comes into the server lastly we call app dot listen to specify what pour Express should listen on i've specified port 81 here but you can specify whichever unused port you'd like when the server starts up and starts listening on this port this function will be called which will log this message letting us know that the server is up and running alright we're all set up let's drop a sample HTML file into our static directory then start up the Express server and see if we can browse to the page we're going to actually just place the web application called predicta HTML that we created in the Charis deployment series into this directory as a proof-of-concept so we place that here you can use any HTML file you'd like though to test this now to start express we use PowerShell let's make sure we're inside of the local server directory and we run a node server j/s we get our output message letting us know that Express is serving files from our static directory on port 81 so now let's browse to localhost or whatever the IP address is that you're running Express on port 81 slash predict HTML which is the name of the file we put into the static directory and here we go this is indeed the webpage we wanted to be served also check out the output from this request in PowerShell to view the logging that we specified so good we now have node and Express setup to be able to serve our models and host our tensorflow j/s apps that will be developing coming up give me a signal in the comments if you were able to get everything up and running and I'll see you in the next video [Music]
Original Description
To build deep learning applications that run in the browser, we need a way to host these applications and a way to host the models. So then, really, we just a way to serve static files.
Let's go through the process of getting a web server set up to host deep learning web applications and serve TensorFlow.js models with Express for Node.js.
Enter Express for Node.js. Express is a minimalist web framework, very similar to Flask, but is for Node.js, not Python. If you're not already familiar with Node.js, it is an open-source run-time environment that executes Javascript code on the server-side.
We'll be making use of Node.js and Express to deploy our TensorFlow.js deep learning applications.
🕒🦎 VIDEO SECTIONS 🦎🕒
00:00 Welcome to DEEPLIZARD - Go to deeplizard.com for learning resources
00:30 Help deeplizard add video timestamps - See example in the description
07:57 Collective Intelligence and the DEEPLIZARD HIVEMIND
💥🦎 DEEPLIZARD COMMUNITY RESOURCES 🦎💥
👋 Hey, we're Chris and Mandy, the creators of deeplizard!
👉 Check out the website for more learning material:
🔗 https://deeplizard.com
💻 ENROLL TO GET DOWNLOAD ACCESS TO CODE FILES
🔗 https://deeplizard.com/resources
🧠 Support collective intelligence, join the deeplizard hivemind:
🔗 https://deeplizard.com/hivemind
🧠 Use code DEEPLIZARD at checkout to receive 15% off your first Neurohacker order
👉 Use your receipt from Neurohacker to get a discount on deeplizard courses
🔗 https://neurohacker.com/shop?rfsn=6488344.d171c6
👀 CHECK OUT OUR VLOG:
🔗 https://youtube.com/deeplizardvlog
❤️🦎 Special thanks to the following polymaths of the deeplizard hivemind:
Tammy
Mano Prime
Ling Li
🚀 Boost collective intelligence by sharing this video on social media!
👀 Follow deeplizard:
Our vlog: https://youtube.com/deeplizardvlog
Facebook: https://facebook.com/deeplizard
Instagram: https://instagram.com/deeplizard
Twitter: https://twitter.com/deeplizard
Patreon: https://patreon.com/deeplizard
YouTube:
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from deeplizard · deeplizard · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Install Jaxx cryptocurrency wallet on Windows 10 and verify file hash
deeplizard
Jaxx cryptocurrency wallet overview - A Blockchain Interface
deeplizard
Remove Jaxx cryptocurrency wallet from Windows 10
deeplizard
Install Jaxx cryptocurrency wallet Chrome extension
deeplizard
Send Litecoin from GDAX to Jaxx wallet
deeplizard
Send Litecoin from Jaxx wallet to GDAX
deeplizard
Backup and restore Jaxx wallet with passphrase
deeplizard
Send Litecoin to Bittrex using Jaxx and monitor confirmations with BlockCypher
deeplizard
Join a mining pool on Waves platform and lease Waves
deeplizard
ZCASH Explained | An introduction to a privacy based cryptocurrency
deeplizard
ZCash t address creation with Jaxx wallet and private key blockchain discussion
deeplizard
Buy ZCash with Litecoin using the Shifty button in the Jaxx wallet
deeplizard
Buy ZCash with Litecoin using ShapeShift - FAILURE
deeplizard
Litecoin | Jaxx | Shapeshift | zcash | failed
deeplizard
Buy ZCash with Litecoin using ShapeShift - SUCCESS even with Jaxx issues
deeplizard
Explore ZCash blockchain with Zchain block explorer
deeplizard
Zchain ZCash block explorer API - PowerShell Code
deeplizard
Zchain ZCash block explorer API - Introduction
deeplizard
Zchain ZCash block explorer API - Application
deeplizard
Coinbase's Trading Platform | Previously known as GDAX
deeplizard
Coinbase Social Security Number (SSN) Requirement Explained
deeplizard
Who owns Coinbase? Here are some KEY people
deeplizard
How does Coinbase/GDAX secure Bitcoin, Litecoin, Ether?
deeplizard
Coinbase | HackerOne bug bounty program
deeplizard
Is Bitcoin safe at Coinbase/GDAX?
deeplizard
Coinbase Login Demo Using Google Authenticator (2FA)
deeplizard
Coinbase Pro - GDAX | Trading Interface Overview
deeplizard
Coinbase gives $10 in Bitcoin | Watch this before signing up
deeplizard
Coinbase around the globe | What countries are supported?
deeplizard
Order book explained | Trading concept to know
deeplizard
Bid/Ask spread explained | Trading concept to know
deeplizard
Maker vs Taker | Trading concept to know
deeplizard
Market Orders are Always TAKERS (HIGHER FEES)!
deeplizard
Buy as a MAKER (LOWER FEE) on Coinbase Pro - GDAX | Limit Order - Part 1
deeplizard
Buy as a MAKER (LOWER FEE) on Coinbase Pro - GDAX | Limit Order - Part 2
deeplizard
Time-in-force explained | Trading concept to know
deeplizard
Stop order explained | How to stop a loss | Coinbase Pro - GDAX
deeplizard
Stop Order on Coinbase Pro - GDAX | What the WARNINGS Mean
deeplizard
Market price vs Last price | Trading concept to know
deeplizard
Stop Order on Coinbase Pro - GDAX | How it is ACTIVATED
deeplizard
Stop-limit order | How to set the limit | Coinbase Pro - GDAX
deeplizard
Flash CRASH Part 1 | ETH/USD currency pair traded at $0.10
deeplizard
Slippage explained | Trading concept to know
deeplizard
Flash CRASH Part 2 | How did Coinbase Respond?
deeplizard
Buy side stop-limit order | Crypto trading strategy for buying a breakout
deeplizard
Buy side stop-limit order | Triggering under the market price
deeplizard
What is an order book?
deeplizard
What is a market?
deeplizard
What is an exchange?
deeplizard
What is a broker-dealer?
deeplizard
Keras prerequisites
deeplizard
Change Keras backend to Theano
deeplizard
#1 Order types and parameters | Trading on Coinbase Pro - GDAX
deeplizard
Trading strategy for stopping a loss | Don't trade all at once!
deeplizard
#2 Order matching engine | Trading on Coinbase Pro - GDAX
deeplizard
Batch Size in a Neural Network explained
deeplizard
Deep Learning playlist overview & Machine Learning intro
deeplizard
Artificial Neural Networks explained
deeplizard
Regularization in a Neural Network explained
deeplizard
Create confusion matrix for predictions from Keras model
deeplizard
More on: ML Pipelines
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
Applying Scalability in Backend (CodeBuddy)
Medium · LLM
Why Every Backend Developer Should Learn Nginx Before Going to Production
Medium · DevOps
Connecting Frontend to Backend: A Backend Engineer’s Reality Check
Medium · Programming
Build Secure Authentication System Using Access and Refresh Tokens
Medium · Python
Chapters (3)
Welcome to DEEPLIZARD - Go to deeplizard.com for learning resources
0:30
Help deeplizard add video timestamps - See example in the description
7:57
Collective Intelligence and the DEEPLIZARD HIVEMIND
🎓
Tutor Explanation
DeepCamp AI