Have you ever thought about building live and shareable Machine Learning apps? As your mentor, I’m here to tell you that the gap between a trained model and a live, shareable app isn’t a chasm you need to spend weeks crossing. It’s a small step you can take in the next 5 minutes. In this article, I’ll explain how to build a shareable live Machine Learning app in 5 minutes.
How to Build a Live Machine Learning App?
Meet Gradio. It’s a pure Python library that lets you build and share a web UI for any ML model with just a few lines of code. It’s designed by and for the ML community, which means it understands exactly what we need: speed and simplicity.
Think of Gradio as a UI wrapper for your Python function. You give it a function (your model’s prediction logic), tell it what the inputs and outputs look like (e.g., an image input, text output), and it does all the heavy lifting of creating an interactive web app.
Let’s get our hands dirty and build one right now.
Build a Live Machine Learning App in 5 Minutes
We’ll build a live app for a powerful sentiment analysis model. This model can take any sentence you give it and tell you if it’s POSITIVE or NEGATIVE. We’ll utilize the impressive Transformers library from Hugging Face to obtain a state-of-the-art model without requiring any training.
Step 1: The Setup
First, let’s install the two necessary libraries. Open your terminal or command prompt and run these two commands:
pip install gradio
pip install transformers
Now, you’re ready to build the app. You can also use a Google Colab notebook for this task.
Step 2: The Code
Please create a new Python file named app.py and write the following code into it. And, if you are using a colab notebook, write the code and run the cell:
import gradio as gr
from transformers import pipeline
# load the pre-trained sentiment analysis model
sentiment_analyzer = pipeline("sentiment-analysis")
# define the function that will wrap our model
def analyze_sentiment(text):
result = sentiment_analyzer(text)[0]
# gradio works best with dictionary outputs
return {result['label']: result['score']}
# create the Gradio Interface
iface = gr.Interface(
fn=analyze_sentiment,
inputs=gr.Textbox(lines=2, placeholder="Enter a sentence here..."),
outputs="label",
title="Sentiment Analysis Bot",
description="Type in a sentence and see if the model thinks it's POSITIVE or NEGATIVE. Built with Gradio and Hugging Face Transformers."
)
# launch the app!
iface.launch()Here’s what’s happening in the above code:
- We used a pipeline(“sentiment-analysis”) to load a powerful, pre-trained model from Hugging Face in one line. No training required!
- We create analyze_sentiment(text). This function is the heart of our app. It takes text as input, passes it to our model, and formats the output into a simple dictionary.
The gr.Interface(…) call is where everything happens. We tell it:
- fn = analyze_sentiment: Use our function to do the work.
- inputs = gr.Textbox(…): The user should get a text box to type in.
- outputs = “label”: The output should be displayed as a clean label.
- title & description: Some nice text to make our app look professional.
- iface.launch(): starts the web server.
Step 3: Run it and Share it Globally
If you are on a colab notebook, run this cell, and you will see such an output (after clicking the public URL in the output):

You can send this link to anyone, anywhere in the world. They can use your machine learning model live from their own browser for the next 72 hours.
If you want to run it locally, go to your terminal, make sure you’re in the same directory as your app.py file, and run this command:
python app.py
Your terminal will come to life, and you’ll see something like this:
Running on local URL: http://127.0.0.1:7860
Running on public URL: https://a1b2c3d4.gradio.app
You just deployed a machine learning model without using servers, containers and web development frameworks.
Final Words
Now, build a new Machine Learning model from scratch and create a live shareable app. The deployment process will take you less than 5 minutes, and the impact it will have on how others perceive your work will be enormous. I hope you liked this article on how to build a shareable live Machine Learning app in 5 minutes. Feel free to ask valuable questions in the comments section below. You can follow me on Instagram for many more resources.






Great! I made some sentiment bot to react emotionally in a negotiation; well in this case if I text …Sugar is good POSITIVE…, if I text …Sugar is bad NEGATIVE…, what is your consideration about it.