How to deploy a Panel app to Hugging Face using Docker?

Sophia Yang · Intermediate ·📰 AI News & Updates ·3y ago

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 Customer lifetime value in a discrete-time contractual setting (math and Python implementation)
Customer lifetime value in a discrete-time contractual setting (math and Python implementation)
Sophia Yang
2 Time series analysis using Prophet in Python — Math explained
Time series analysis using Prophet in Python — Math explained
Sophia Yang
3 Multiclass logistic/softmax regression from scratch
Multiclass logistic/softmax regression from scratch
Sophia Yang
4 Deploy a Python Visualization Panel App to Google Cloud App Engine
Deploy a Python Visualization Panel App to Google Cloud App Engine
Sophia Yang
5 Deploy a Python Visualization Panel App to Google Cloud Run
Deploy a Python Visualization Panel App to Google Cloud Run
Sophia Yang
6 [Read a paper (with code)] Beyond Accuracy: Behavioral Testing of NLP models with CheckList
[Read a paper (with code)] Beyond Accuracy: Behavioral Testing of NLP models with CheckList
Sophia Yang
7 5-step data science workflow
5-step data science workflow
Sophia Yang
8 Multi-armed bandit algorithms - ETC Explore then Commit
Multi-armed bandit algorithms - ETC Explore then Commit
Sophia Yang
9 Multi-armed bandit algorithms - Epsilon greedy algorithm
Multi-armed bandit algorithms - Epsilon greedy algorithm
Sophia Yang
10 User retention analysis framework | data science product sense
User retention analysis framework | data science product sense
Sophia Yang
11 Visualization and Interactive Dashboard in Python: My favorite Python Viz tools — HoloViz
Visualization and Interactive Dashboard in Python: My favorite Python Viz tools — HoloViz
Sophia Yang
12 Multi-armed bandit algorithms: Thompson Sampling
Multi-armed bandit algorithms: Thompson Sampling
Sophia Yang
13 The Easiest Way to Create an Interactive Dashboard in Python
The Easiest Way to Create an Interactive Dashboard in Python
Sophia Yang
14 Big Data Visualization Using Datashader in Python | How does Datashader work and why is it so fast?
Big Data Visualization Using Datashader in Python | How does Datashader work and why is it so fast?
Sophia Yang
15 Why do you want to be a data scientist? Don't be a data scientist if ...
Why do you want to be a data scientist? Don't be a data scientist if ...
Sophia Yang
16 Johnny Depp v Amber Heard Twitter Sentiment Analysis | Is Camille Vasquez the real winner | 🤗 NLP
Johnny Depp v Amber Heard Twitter Sentiment Analysis | Is Camille Vasquez the real winner | 🤗 NLP
Sophia Yang
17 How to build a product that sells itself | Product-led Growth | Book Summary | Read a book with me
How to build a product that sells itself | Product-led Growth | Book Summary | Read a book with me
Sophia Yang
18 Designing Machine Learning Systems | book summary | Read a book with me
Designing Machine Learning Systems | book summary | Read a book with me
Sophia Yang
19 Where do data scientists/analysts go next? Love and hate in data analytics (ft. Shashank Kalanithi)
Where do data scientists/analysts go next? Love and hate in data analytics (ft. Shashank Kalanithi)
Sophia Yang
20 Meet the Author: Fundamentals of Data Engineering | DS/ML book club
Meet the Author: Fundamentals of Data Engineering | DS/ML book club
Sophia Yang
21 What's new in hvPlot releases 0.8.0 & 0.8.1?
What's new in hvPlot releases 0.8.0 & 0.8.1?
Sophia Yang
22 Meet the Author: Machine Learning Design Patterns | What do ML/Research Engineers do at Google?
Meet the Author: Machine Learning Design Patterns | What do ML/Research Engineers do at Google?
Sophia Yang
23 Machine Learning Design Patterns | Google Executive | Investor | Meet the Author
Machine Learning Design Patterns | Google Executive | Investor | Meet the Author
Sophia Yang
24 How to solve data quality issues | Data Reliability | Meet the Author
How to solve data quality issues | Data Reliability | Meet the Author
Sophia Yang
25 Reliable Machine Learning author interview | DS/ML book club
Reliable Machine Learning author interview | DS/ML book club
Sophia Yang
26 Toronto VLOG | First vlog | Meet my favorite author | Toronto ML Summit conference
Toronto VLOG | First vlog | Meet my favorite author | Toronto ML Summit conference
Sophia Yang
27 TOP 6 tech news in 2022 #shorts
TOP 6 tech news in 2022 #shorts
Sophia Yang
How to deploy a Panel app to Hugging Face using Docker?
How to deploy a Panel app to Hugging Face using Docker?
Sophia Yang
29 Tech news this week | ChatGPT, Hacks, Snowflake, CES #shorts
Tech news this week | ChatGPT, Hacks, Snowflake, CES #shorts
Sophia Yang
30 🗞️ Tech news this week: ChatGPT, DreamerV3, Muse, VALL-E, Mineral, DoNotPay, Tesla, SBF... #shorts
🗞️ Tech news this week: ChatGPT, DreamerV3, Muse, VALL-E, Mineral, DoNotPay, Tesla, SBF... #shorts
Sophia Yang
31 Tech news this week | Boston Dynamics, Microsoft, Snowflake, Google, and more #shorts
Tech news this week | Boston Dynamics, Microsoft, Snowflake, Google, and more #shorts
Sophia Yang
32 The story of Metaflow | Effective Data Science Infrastructure | Book author interview
The story of Metaflow | Effective Data Science Infrastructure | Book author interview
Sophia Yang
33 Tech news this week #shorts
Tech news this week #shorts
Sophia Yang
34 A day in life of a data scientist | Data Day Texas | Interview 12 authors/speakers
A day in life of a data scientist | Data Day Texas | Interview 12 authors/speakers
Sophia Yang
35 Tech news this week #shorts
Tech news this week #shorts
Sophia Yang
36 Explainable AI with Shapley Values (Part 1: Game Theory)
Explainable AI with Shapley Values (Part 1: Game Theory)
Sophia Yang
37 Explainable AI with Shapley Values (Part 2: Estimate Shapley Values)
Explainable AI with Shapley Values (Part 2: Estimate Shapley Values)
Sophia Yang
38 Explainable AI with Shapley Values (Part 3: KernelSHAP)
Explainable AI with Shapley Values (Part 3: KernelSHAP)
Sophia Yang
39 Tech news this week | AI search war between Microsoft and Google #shorts
Tech news this week | AI search war between Microsoft and Google #shorts
Sophia Yang
40 The Story of ChatGPT's creator OpenAI | From Riches to Fame
The Story of ChatGPT's creator OpenAI | From Riches to Fame
Sophia Yang
41 Explainable AI for Practitioners | Must-read for XAI | author interview
Explainable AI for Practitioners | Must-read for XAI | author interview
Sophia Yang
42 Train your own language model with nanoGPT | Let’s build a songwriter
Train your own language model with nanoGPT | Let’s build a songwriter
Sophia Yang
43 The easiest way to work with large language models | Learn LangChain in 10min
The easiest way to work with large language models | Learn LangChain in 10min
Sophia Yang
44 The BEST browser? AI article summary, image generation, website insights. Microsoft Edge Copilot!
The BEST browser? AI article summary, image generation, website insights. Microsoft Edge Copilot!
Sophia Yang
45 startup scene in data | insights from 50+ data startups from Data Council
startup scene in data | insights from 50+ data startups from Data Council
Sophia Yang
46 NLP with Transformers author interview with Lewis Tunstall from Hugging Face
NLP with Transformers author interview with Lewis Tunstall from Hugging Face
Sophia Yang
47 4 ways to do question answering in LangChain | chat with long PDF docs | BEST method
4 ways to do question answering in LangChain | chat with long PDF docs | BEST method
Sophia Yang
48 5 Steps to Build a Question Answering PDF Chatbot: LangChain + OpenAI + Panel + HuggingFace.
5 Steps to Build a Question Answering PDF Chatbot: LangChain + OpenAI + Panel + HuggingFace.
Sophia Yang
49 4 Autonomous AI Agents: “Westworld” simulation, Camel, BabyAGI, AutoGPT, Camel ⭐ LangChain ⭐
4 Autonomous AI Agents: “Westworld” simulation, Camel, BabyAGI, AutoGPT, Camel ⭐ LangChain ⭐
Sophia Yang
50 MiniGPT4: image understanding & open-source!
MiniGPT4: image understanding & open-source!
Sophia Yang
51 BEST Practices in Prompt Engineering: Learnings and Thoughts from Andrew Ng's New Course
BEST Practices in Prompt Engineering: Learnings and Thoughts from Andrew Ng's New Course
Sophia Yang
52 Designing Machine Learning Systems author interview with Chip Huyen
Designing Machine Learning Systems author interview with Chip Huyen
Sophia Yang
53 Tech news this week: code interpreter, Mojo, Redpajama, MPT7b, StarCoder #shorts
Tech news this week: code interpreter, Mojo, Redpajama, MPT7b, StarCoder #shorts
Sophia Yang
54 🤗 Hugging Face Transformers Agent | LangChain comparisons
🤗 Hugging Face Transformers Agent | LangChain comparisons
Sophia Yang
55 📢 Tech news this week #shorts
📢 Tech news this week #shorts
Sophia Yang
56 📢 Tech news this week #shorts
📢 Tech news this week #shorts
Sophia Yang
57 The BEST ChatGPT Plugins | Brand NEW Bing Search | Web browsing, CODING, summarizing, and more
The BEST ChatGPT Plugins | Brand NEW Bing Search | Web browsing, CODING, summarizing, and more
Sophia Yang
58 Tech news this week #shorts #short
Tech news this week #shorts #short
Sophia Yang
59 📢 Tech news this week #shorts
📢 Tech news this week #shorts
Sophia Yang
60 Deep Learning with PyTorch Author Interview with Eli Stevens, Luca Antiga, and Thomas Viehmann
Deep Learning with PyTorch Author Interview with Eli Stevens, Luca Antiga, and Thomas Viehmann
Sophia Yang

Related Reads

📰
Musk thanks Micron for chips, and builds a $55bn fab to replace it
Elon Musk thanks Micron for providing Tesla with a significant allocation of memory chips, highlighting the scarcity of this crucial component in the AI boom
The Next Web AI
📰
Jensen Huang calls the AI jobs panic ‘complete nonsense’, and takes aim at his peers
Nvidia CEO Jensen Huang dismisses AI job replacement panic as 'complete nonsense', offering a contrasting view to his peers
The Next Web AI
📰
IMF says Africa has to keep lights on before it can bet on AI
Africa's AI ambitions are hindered by unreliable electricity, highlighting the need for basic infrastructure before investing in AI
TechCabal
📰
What Does Job Security Even Look Like In 2026? It Starts With Skills
Job security in 2026 requires adapting to AI and economic uncertainty by acquiring in-demand skills
Forbes Innovation
Up next
Catch Me Live on Earn Your Leisure Talking AI
Alicia Lyttle
Watch →