
We built a Gradio app to demo our AI models. But it only ran on your local computer (localhost) so How do you show it to a client, a friend, or a recruiter? To make your app accessible online, you’ll need to learn about Hugging Face Spaces Deployment.
Hugging Face Spaces Is a free hosting platform specifically for machine learning demos.
Step 1: Create a Space
- Go to huggingface.co/spaces.
- Click “Create new Space”.
- Name:
my-sentiment-analyzer. - SDK: Select Gradio.
- Hardware: Select CPU basic (free).
- Click “Create Space”.
Step 2: The Files
You need to upload two files to this new Space (you can do this via the web interface or Git).
File 1: requirements.txt Tell Hugging Face what libraries to install.
transformers torch
File 2: app.py This is your standard Gradio code.
import gradio as gr
from transformers import pipeline
# Load the pipeline
classifier = pipeline("sentiment-analysis")
def analyze(text):
return classifier(text)[0]['label']
# Create the interface
iface = gr.Interface(fn=analyze, inputs="text", outputs="text")
# Important: Do NOT use iface.launch(). Just define the variable.
iface.launch()Step 3: Commit and Run
Once you “Commit” these files, Hugging Face will automatically:
- Build a container.
- Install your requirements.
- Launch your app.
In about 2 minutes, your app will be live at https://huggingface.co/spaces/YourUsername/my-sentiment-analyzer!
Key Takeaways
- You can showcase your Gradio app using Hugging Face Spaces, a free platform for machine learning demos.
- To create a Space, visit huggingface.co/spaces and click ‘Create new Space’.
- Name your Space ‘my-sentiment-analyzer’, choose Gradio SDK, and select ‘CPU basic (free)’.
- Upload two essential files: ‘requirements.txt’ for libraries and ‘app.py’ for your Gradio code.
- Once you commit the files, Hugging Face will build the container, install dependencies, and launch your app live.





