-
Image Classification as A Service in Node.js
In the previous article, we discussed how WebAssembly could tie together native TensorFlow, Node.js JavaScript, and Rust functions to create high performance and safe web services for AI. In this article, we will discuss how to apply this approach to ImageNet's MobileNet image classification model, and more importantly, how to create web applications for your own retrained MobileNet models. NOTE This article demonstrates how to call operating system native programs from the SSVM.…
RustJavaScripttensorflowWebAssemblyNode.jsAI as a serviceFaaSAIImage Classification
-
Use Binary Data as Function Input and Output
In the previous article, we demonstrated how a Second State FaaS function could handle text-based input and output. Through JSON support, we can encode arbitrary data types into text. However, for functions focused on media processing, binary-based input and output is far more efficient and more performant. In this article, we will show you how to use a Second State FaaS function to add watermark to an image. The source code for the watermark example in this article is available on Github.…
RustJavaScriptWebAssemblyNode.jsFaaSRust FaaSServerlessCloud computing
-
High performance and safe AI as a Service in Node.js
Today’s dominant programming language for AI is Python. Yet, the programming language for the web is JavaScript. To provide AI capabilities as a service on the web, we need to wrap AI algorithms in JavaScript, particularly Node.js. However, neither Python nor JavaScript by itself is suitable for computationally intensive AI applications. They are high-level, ie, slow, languages with heavy-weight runtimes. Their ease-of-use comes at the cost of low performance. Python got around this by wrapping AI computation in native C/C++ modules.…
RustJavaScripttensorflowWebAssemblyNode.jsAI as a serviceFaaSAIFace detection
-
The rustwasmc tool
Throughout our examples, we make extensive use of the rustwasmc tool. It is inspired by the wasm-pack project but is optimized for edge cloud and device applications. Specifically, it supports the WasmEdge WebAssembly runtime. Prerequisites The rustwasmc depends on the Rust cargo toolchain to compile Rust source code to WebAssembly. You must have Rust installed on your machine. $ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh $ source $HOME/.cargo/env $ rustup override set 1.…
-
Access JavaScript functions from Rust
In this tutorial, we will show you how to use the nodejs-helper crate to call Node.js functions from Rust code. Rust functions can now access the file system, network, database, and other system resources from within the WebAssembly container. It is important to note that a better way for Rust programs to access system resources is through the WebAssembly WASI extension, as well as numerous host extensions provided by the SSVM.…
-
WebAssembly in the browser
WebAssembly was originally invented as a technology solution to speed up code execution inside web browsers. It does not provide a full replacement for JavaScript, but rather works side-by-side with JavaScript. The idea is that JavaScript functions could pass computationally intensive tasks to WebAssembly functions. In this tutorial, we will demonstrate how a simple WebAssembly in-browser application works. The source code of the tutorial is here. A WebAssembly application typically has two parts.…
-
Rust and WebAssembly
In this tutorial, we will create a very simple but complete WebAssembly application. A WebAssembly application typically has two parts. The bytecode program that runs inside the WebAssembly virtual machine to perform computing tasks The host application that provides UI, networking, database, and calls the WebAssembly program to perform key computing tasks or business logic In this tutorial, the host application is written in JavaScript and runs inside a web browser.…