Deploying AI/ML models as static websites

I am fan of static websites. They are cheap to operate, and can even be free with services like GitLab/GitHub Pages.

Yesterday I watched a webinar on deploying ML models through FastAPI, which included backend call to the model. But with the recent advancements in model size, and the power that is available for browsers through WASM and perhaps GPU access, is it possible to deploy AI/ML models completely as a static resources? So that the inference is done completely in browser without any dynamic backend at all.

1 Like

Certain ML models are deployed on the app itself without a server, also embedded ML is achieved on the microprocessor. It depends on the size and requirements of the ML model, if its small it could be deployed directly on device or page.

So, how to deploy models directly on web pages?

1 Like

The tf data and deployment specialization maybe a nice place where to get info about this.

1 Like

Does it really cover it?

1 Like

You can check it out!

1 Like

From https://www.coursera.org/learn/browser-based-models-tensorflow?specialization=tensorflow-data-and-deployment

This will allow you to use machine learning directly in the browser as well as on backend servers like Node.js.

Not sure if using ML directly in browser is 100% the same as using ML from a static website. Inference may use browser GPU, but still access backend parts on a Node.js server.

Static sites are just repositories and servers of the html/javascript/css code, and other static assets like images. The browser connects to the site, fetches these resources, and does the local processing in the client. The host of the static site merely stores and serves the resources.

Python, on the other hand, is an interpreted language that is executed in top of a Python virtual machine. You could say that Python is both interpreted and compiled. Also, the ML model requires CPU or GPU. The host of the virtual machine and the model need more resources than just storing the files. So I don’t see how an ML model could be hosted as a static website.

1 Like

Regarding model deployments: As @gent.spah suggests, the MLOPS specialization will help you with this aspect. Most probably you’ll have to enable an API on your model so that it can be consumed by other apps. In MLOps you’ll learn about FastAPI, a framework to build APIs for python.

1 Like

I know about FastAPI already. Seen it in a webinar 4 days ago. But thanks for the Tensorflow.js pointer. I guess I should just try to deploy something to GitHub Pages. I am hesitant to start the course, because I am unlikely to accomplish to in just 7 days, and I will feel bad about it. Maybe later when I find a job they will require me to learn something. Otherwise there is too much stuff to learn.

You should try to do Course 1 of MLOps at least. I think you can finish it within 7 days.

12 hours of learning over 7 days looks feasible. But there won’t be any certificate to add to LinkedIn profile, right?

I also love static pages and encourage you to look into TensorFlow.js. I looked into using this for a Chrome extension, but my guess is it will also work right “in the browser” by hosting the model/inference as a static .js file.

1 Like