
Hugging Face Spaces
- By Bruce Nielson
- ML & AI Specialist
We’ve talked a lot about Hugging Face’s ecosystem in past post. One thing I’ve not touched on yet—that deserves some attention—is Hugging Face’s “Spaces.” Hugging Face Spaces is a free (cpu) or paid (gpu) service that allows you to run your AI demos. It’s a great way to make your AI demo available on the internet to get real life use.
Getting Started with Hugging Face Spaces
Go to huggingface.co and login and then click on the ‘Spaces’ tab:
This will take you to the Spaces page:
You can find the documentation for Spaces here. ([Overview found here].4)
Let’s try someone else’s Space out. I’m going to try this one:
I can then enter a comic style:
And click “GO” and I’ll get a Superman comic book:
This is a program someone created in Hugging Face Spaces and made available for free. Not bad, eh?
Creating Your Own Space
Click on the “New Spaces” button to start the process of making your own Space:
You will then need to fill in some information such as a name for your space and a description:
Notice also that you have several options for what SDK to use as well as the ability to specify what hardware to use (GPUs cost money) and if it is public or private:
Note that Gradio is one of the options. This is a great way to get started with Gradio. However, Gradio can technically host sites for you themselves. But that will have to be a separate post.
For now, let’s select Gradio and create a text-to-image demo:
Then create the Space:
You’ll see the Space getting built:
Your Space is now built:
You’ll also see a pop-up like this:
This explains how to clone down your space so that you can update the code and push it back to the Space. Yes, Hugging Face Spaces is a sort of mini Github with a demo of your software.
Creating a Token
You will probably need a Hugging Face Token and I don’t seem to have covered anywhere else how to get one, so let me do a brief aside to explain how to do that. You should already be logged in, so click on the profile icon:
That will drop a menu where one of the options is “Access Token.”
It may make you login again. But then you’ll see this page. On this page, you can click ‘new’ to make a token:
Learning Gradio Using Spaces
One reason I wanted to introduce Hugging Face Spaces is because it’s a great way to learn the SDKs available. The first time I used Gradio I just downloaded one of the example apps I had created in Spaces and ran it locally by cloning the repo it had created for me. I plan to play with Streamlit this way as well.
See All Your Spaces
To see all your Spaces, go to your profile. Click the profile icon in the upper right-hand corner again and select your profile:
Your Profile shows you what Spaces you currently have:
Modify Your Space Settings
When in your space, there is a Settings option:
Click it and you’ll see this page:
This is where you can set environment variables and secrets for your Space:
Or delete it:
Conclusions
This is a short introduction to Hugging Face Spaces. Hugging Face Spaces is a great way to build an AI demo online and share it with the world for low or no cost. It’s also a great way to start learning AI related UI SDKs like Gradio and Streamlit.