Hugging Face Spaces

Hugging Face Spaces

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:

Image 1. Will add detailed description at a later date.

This will take you to the Spaces page:

Image 2. Will add detailed description at a later date.

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:

Image 3. Will add detailed description at a later date.

I can then enter a comic style:

Image 4. Will add detailed description at a later date.

And click “GO” and I’ll get a Superman comic book:

Image 5. Will add detailed description at a later date.

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:

Image 6. Will add detailed description at a later date.

You will then need to fill in some information such as a name for your space and a description:

Image 7. Will add detailed description at a later date.

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:

Image 8. Will add detailed description at a later date.

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:

Image 9. Will add detailed description at a later date.

Then create the Space:

Image 10. Will add detailed description at a later date.

You’ll see the Space getting built:

Image 11. Will add detailed description at a later date.

Your Space is now built:

Image 12. Will add detailed description at a later date.

You’ll also see a pop-up like this:

Image 13. Will add detailed description at a later date.

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:

Image 14. Will add detailed description at a later date.

That will drop a menu where one of the options is “Access Token.”

Image 15. Will add detailed description at a later date.

It may make you login again. But then you’ll see this page. On this page, you can click ‘new’ to make a token:

Image 16. Will add detailed description at a later date.

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:

Image 17. Will add detailed description at a later date.

Your Profile shows you what Spaces you currently have:

Image 18. Will add detailed description at a later date.

Modify Your Space Settings

When in your space, there is a Settings option:

Image 19. Will add detailed description at a later date.

Click it and you’ll see this page:

Image 20. Will add detailed description at a later date.

This is where you can set environment variables and secrets for your Space:

Image 21. Will add detailed description at a later date.

Or delete it:

Image 22. Will add detailed description at a later date.

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.

SHARE


comments powered by Disqus

Follow Us

Latest Posts

subscribe to our newsletter