How to deploy a Panel app to Hugging Face using Docker?
Key Takeaways
This video teaches how to deploy a Panel app to Hugging Face using Docker
Full Transcript
hello everyone welcome to my Channel today I'd like to show you how to deploy a panel app to hugging face with five simple steps why do you want to do this because it's free and it's super simple and you can share your panel app with the world and uh yeah so why not let's get started the first step is to go to the hiking phase spaces page and click create new space the second step is just to fill out this form and create a new space let's call it panel example you need to select the space SDK then select docker you can also use streamlit or gradient because I'm a panel user I love panel and hugging face doesn't support panel yet so we can use a Docker image to deploy our Panel App it is okay it's actually not as hard as you might imagine it's actually quite simple I'll show you in a bit we can Define if either we want our space to be public or private let's make it private first we can make it public later now we can do step 3 which is cloning this GitHub repo to your machine and and then we can start coding copy and paste the Slime git clone open your terminal I use item but you can do use whichever terminal tool you like to use you can do it in base code directly also do get along okay cool now you should be able to go to this directory and then we can see there's a readme there I can check out what's in this readme yeah just hugging face configurations we can ignore that for now okay step four is the most important step which is to create the three files we need for our Panel App let's open up our vs code let's make it bigger cool let's open up this folder in vs code and we need to create three files app dot Pi is where we write our Panel App and then requirements.txt is where we Define our package dependencies and what kind of packages we need to run this app and then finally we need a Docker file to be able to run our app in a Docker image in a Docker container let's start with app.pi to create a panel app here so previously I have written an article called three ways to build a panel visualization dashboard um in this article I listed three ways to build a panel app I'm just going to copy and paste uh the code I have also made a video on this so check it out if you're interested bye for now we're just gonna copy this file and this app should be ready to go and now we can go to the requirement.txt we need two packages for this project one is panel and another one is HP plot HP plot is a plotting tool that is super easy to use both piano and HP plot are in the hollowvest ecosystem so I encourage you to check out the docs and learn more about those if you're interested and finally in the docker file let's go back to the hugging face instructions let's just copy and paste this for now and then we can revise based on our needs in the stalker file we specify the base image from python39 says the working directory AS Slash code copy the requirements.txt file to the container wrong PIV install to install packages into container and then CMD provides the commands to run our app for the container we need to change this to be able to run our panel apps what do we what we need to do is to do panel serve code app.pi panel serve will serve this app and then we need to define the address which is 0.0.0.0 port the default port in hacking face is 7860 so that's what we need right here and then we need um allow web socket origin as this will be my account name and the space name FS space please remember to change this to your username and this to your space name okay that's step four now the final step is just to commit all the files to hug and face and we're done let's see get status yes we created three files and then I'm just gonna add everything and then get status get commit Panel App push okay now we should see all those files we just created yay and then let's wait for hugging face to build our app and now after a few minutes you can see your app showing up on cutting face space and it's fully interactive you can play with this app you can share this link to whoever you want to share oh before you share that you need to make it public let's make it public first make the space public that's the five steps you need to know to deploy your panda app isn't it easy you might wonder what if I need to troubleshoot things I want to run it locally before I deploy it yes actually sometimes we need to do that and that's a very good practice so let's see how that works first of all you probably need to install Docker after you have a Docker installed you should be able to use Docker commands in your command line okay the only thing we need to change here is instead of this hugging face um URL we need to change it to our localhost zero zero zero zero dot 80 60. so so that the app will show up in our localhost okay let's see how Docker works first of all we need to build a Docker image we call it panel image and we build based on everything in this folder next we can run this Docker image Docker ROM give it a name we name the container called panel container 82 86.80 and then the image name you can see there's a conflict because I have written this before so which means I need to run Docker remove to remove this container first before I can build it again remove oh sorry typo panel container and then we can run Docker run again cool now let's see if we can see our app over here great we can see our app running locally can we serve multiple panel apps at the same time on hanging face yes you absolutely can here is an example where I hosted three panel apps um I have one app called panel Interactive and I can go back I have a text analysis app where we do some topic modeling and sentiment analysis and Grant analysis and then we'll have a trivia game that um will give us trivia questions so yeah so that's it for this video hope you find it helpful let me know if you have deployed a panel app to hugging face and please share with me I would like to see it thank you bye
Original Description
- How to deploy a Panel app to Hugging Face using Docker?
- How to run Docker locally?
- Can we serve multiple Panel apps at the same time on Hugging Face?
- Blog post: https://towardsdatascience.com/how-to-deploy-a-panel-app-to-hugging-face-using-docker-6189e3789718?sk=9c2bbd9bdbc3917e39dbd1fc9d1a5771
- Hugging Face Space 1: https://huggingface.co/spaces/sophiamyang/panel_example
- Standalone app link 1: https://sophiamyang-panel-example.hf.space/app
- Hugging Face Space 2: https://huggingface.co/spaces/sophiamyang/Panel_apps
- Standalone app link 2: https://sophiamyang-panel-apps.hf.space/
Mentioned in the video:
- Blog post 3 ways to build a Panel visualization dashboard: https://towardsdatascience.com/3-ways-to-build-a-panel-visualization-dashboard-6e14148f529d?sk=2cd93ae39586305bae8cfaead2bf7bb4
UPDATES:
- To run Docker locally, instead of changing sophiamyang-panel-example.hf.space to 0.0.0.0:7860. A better way is to add 0.0.0.0:7860 to the allowed WebSockets in addition to the Hugging Face URL in the DockerFile: CMD ["panel", "serve", "/code/app.py", "--address", "0.0.0.0", "--port", "7860", "--allow-websocket-origin", "sophiamyang-panel-example.hf.space", "--allow-websocket-origin", "0.0.0.0:7860"]
🌼 About me 🌼
Sophia Yang is a Senior Data Scientist working at a tech company.
🔔 SUBSCRIBE to my channel: https://www.youtube.com/c/SophiaYangDS?sub_confirmation=1
⭐ Stay in touch ⭐
▶ YouTube: https://youtube.com/SophiaYangDS
✍️ Medium: https://sophiamyang.medium.com
🐦 Twitter: https://twitter.com/sophiamyang
🤝 Linkedin: https://www.linkedin.com/in/sophiamyang/
📚 DS/ML Book Club: https://dsbookclub.github.io
💚 #datascience
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Sophia Yang · Sophia Yang · 28 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
▶
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Customer lifetime value in a discrete-time contractual setting (math and Python implementation)
Sophia Yang
Time series analysis using Prophet in Python — Math explained
Sophia Yang
Multiclass logistic/softmax regression from scratch
Sophia Yang
Deploy a Python Visualization Panel App to Google Cloud App Engine
Sophia Yang
Deploy a Python Visualization Panel App to Google Cloud Run
Sophia Yang
[Read a paper (with code)] Beyond Accuracy: Behavioral Testing of NLP models with CheckList
Sophia Yang
5-step data science workflow
Sophia Yang
Multi-armed bandit algorithms - ETC Explore then Commit
Sophia Yang
Multi-armed bandit algorithms - Epsilon greedy algorithm
Sophia Yang
User retention analysis framework | data science product sense
Sophia Yang
Visualization and Interactive Dashboard in Python: My favorite Python Viz tools — HoloViz
Sophia Yang
Multi-armed bandit algorithms: Thompson Sampling
Sophia Yang
The Easiest Way to Create an Interactive Dashboard in Python
Sophia Yang
Big Data Visualization Using Datashader in Python | How does Datashader work and why is it so fast?
Sophia Yang
Why do you want to be a data scientist? Don't be a data scientist if ...
Sophia Yang
Johnny Depp v Amber Heard Twitter Sentiment Analysis | Is Camille Vasquez the real winner | 🤗 NLP
Sophia Yang
How to build a product that sells itself | Product-led Growth | Book Summary | Read a book with me
Sophia Yang
Designing Machine Learning Systems | book summary | Read a book with me
Sophia Yang
Where do data scientists/analysts go next? Love and hate in data analytics (ft. Shashank Kalanithi)
Sophia Yang
Meet the Author: Fundamentals of Data Engineering | DS/ML book club
Sophia Yang
What's new in hvPlot releases 0.8.0 & 0.8.1?
Sophia Yang
Meet the Author: Machine Learning Design Patterns | What do ML/Research Engineers do at Google?
Sophia Yang
Machine Learning Design Patterns | Google Executive | Investor | Meet the Author
Sophia Yang
How to solve data quality issues | Data Reliability | Meet the Author
Sophia Yang
Reliable Machine Learning author interview | DS/ML book club
Sophia Yang
Toronto VLOG | First vlog | Meet my favorite author | Toronto ML Summit conference
Sophia Yang
TOP 6 tech news in 2022 #shorts
Sophia Yang
How to deploy a Panel app to Hugging Face using Docker?
Sophia Yang
Tech news this week | ChatGPT, Hacks, Snowflake, CES #shorts
Sophia Yang
🗞️ Tech news this week: ChatGPT, DreamerV3, Muse, VALL-E, Mineral, DoNotPay, Tesla, SBF... #shorts
Sophia Yang
Tech news this week | Boston Dynamics, Microsoft, Snowflake, Google, and more #shorts
Sophia Yang
The story of Metaflow | Effective Data Science Infrastructure | Book author interview
Sophia Yang
Tech news this week #shorts
Sophia Yang
A day in life of a data scientist | Data Day Texas | Interview 12 authors/speakers
Sophia Yang
Tech news this week #shorts
Sophia Yang
Explainable AI with Shapley Values (Part 1: Game Theory)
Sophia Yang
Explainable AI with Shapley Values (Part 2: Estimate Shapley Values)
Sophia Yang
Explainable AI with Shapley Values (Part 3: KernelSHAP)
Sophia Yang
Tech news this week | AI search war between Microsoft and Google #shorts
Sophia Yang
The Story of ChatGPT's creator OpenAI | From Riches to Fame
Sophia Yang
Explainable AI for Practitioners | Must-read for XAI | author interview
Sophia Yang
Train your own language model with nanoGPT | Let’s build a songwriter
Sophia Yang
The easiest way to work with large language models | Learn LangChain in 10min
Sophia Yang
The BEST browser? AI article summary, image generation, website insights. Microsoft Edge Copilot!
Sophia Yang
startup scene in data | insights from 50+ data startups from Data Council
Sophia Yang
NLP with Transformers author interview with Lewis Tunstall from Hugging Face
Sophia Yang
4 ways to do question answering in LangChain | chat with long PDF docs | BEST method
Sophia Yang
5 Steps to Build a Question Answering PDF Chatbot: LangChain + OpenAI + Panel + HuggingFace.
Sophia Yang
4 Autonomous AI Agents: “Westworld” simulation, Camel, BabyAGI, AutoGPT, Camel ⭐ LangChain ⭐
Sophia Yang
MiniGPT4: image understanding & open-source!
Sophia Yang
BEST Practices in Prompt Engineering: Learnings and Thoughts from Andrew Ng's New Course
Sophia Yang
Designing Machine Learning Systems author interview with Chip Huyen
Sophia Yang
Tech news this week: code interpreter, Mojo, Redpajama, MPT7b, StarCoder #shorts
Sophia Yang
🤗 Hugging Face Transformers Agent | LangChain comparisons
Sophia Yang
📢 Tech news this week #shorts
Sophia Yang
📢 Tech news this week #shorts
Sophia Yang
The BEST ChatGPT Plugins | Brand NEW Bing Search | Web browsing, CODING, summarizing, and more
Sophia Yang
Tech news this week #shorts #short
Sophia Yang
📢 Tech news this week #shorts
Sophia Yang
Deep Learning with PyTorch Author Interview with Eli Stevens, Luca Antiga, and Thomas Viehmann
Sophia Yang
More on: Docker & Containers
View skill →Related Reads
📰
📰
📰
📰
Musk thanks Micron for chips, and builds a $55bn fab to replace it
The Next Web AI
Jensen Huang calls the AI jobs panic ‘complete nonsense’, and takes aim at his peers
The Next Web AI
IMF says Africa has to keep lights on before it can bet on AI
TechCabal
What Does Job Security Even Look Like In 2026? It Starts With Skills
Forbes Innovation
🎓
Tutor Explanation
DeepCamp AI