Frameworks & Templates
Streamlit

Streamlit

Streamlit (opens in a new tab) is an open-source Python library that makes it easy to create and share beautiful, custom web apps for machine learning and data science.

Hello World

This is a simple example of a Streamlit app that takes a name as input and returns a greeting as output:

import streamlit as st
 
st.title("Hello World!")

Use templates

We have several templates for streamlit apps. You could find them below. They can be deployed to ModelZ directly.

Build from scratch

You could also build your own app from scratch. You could use our template modelz-template-streamlit (opens in a new tab) to bootstrap your project.

You will need to provide three key components:

  • A main.py file: This file contains the code for making predictions.
  • A requirements.txt file: This file lists all the dependencies required for the server code to run.
  • A Dockerfile or a simpler build.envd (opens in a new tab): This file contains instructions for building a Docker image that encapsulates the server code and its dependencies.

In the Dockerfile, you need to define the instructions for building a Docker image that encapsulates the server code and its dependencies.

In most cases, you could use the template in the repository.

docker build -t docker.io/USER/IMAGE .
docker push docker.io/USER/IMAGE
 
# GPU
docker build -t docker.io/USER/IMAGE -f Dockerfile.gpu .
docker push docker.io/USER/IMAGE

On the other hand, a build.envd (opens in a new tab) is a simplified alternative to a Dockerfile. It provides python-based interfaces that contains configuration settings for building a image.

It is easier to use than a Dockerfile as it involves specifying only the dependencies of your machine learning model, not the instructions for CUDA, conda, and other system-level dependencies.

envd build --output type=image,name=docker.io/USER/IMAGE,push=true
# GPU
envd build --output type=image,name=docker.io/USER/IMAGE,push=true -f :build_gpu

Deploy Gradio apps to ModelZ

You could deploy your Gradio app to ModelZ following the Deploy section in the Getting Started guide.