Daanalytics

Plotting F1 Circuit Locations into a map on Streamlit on Hugging Face using Folium

In my last blogpost I showed how to plot F1 Circuit Locations into a map using Folium on Streamlit Cloud. The idea is to switch between the World, a possible Continent and a possible Country. Check the video below.

Streamlit App – Plotting F1 Circuit Locations into a map on Streamlit Cloud using Folium

Hugging Face

Alternative step would be setting things up Streamlit on Hugging Face. The Hugging Face setup for Streamlit is pretty clear in the documentation.

Create a Streamlit Space

  • Give the Space a Name
  • Select License (optional)
  • Select the Space SDK
    • Streamlit
  • Select the Space Hardware
  • Choose Public or Private
  • Create Space

Get started with your Streamlit Space

I chose to go for the hint and ‘Create the app.py file right in your browser alternatively’. Make sure you call your app-file; app.py otherwise it doesn’t work.

I used the same code as I used previously. The only thing I had to change is the connection to Snowflake. In Streamlit Cloud I use the secrets in the settings of the app. In Hugging Face it’s a similar concept where I used separate environment variables.

Via the settings tab you can add the necessary environment variabels to connect to Snowflake:

  • user
  • password
  • role
  • account

The way these environment variable work between Hugging Face and Snowflake is slightly different.

Don’t forget to add the requirements.txt-file. Make sure you have the right (and in my case the latest) versions of the libraries you use in your code.

The app will start building.

After a while, the app complets building and is; ‘Running’

Closing Statements

In the previous example(s) I provided the steps to plot F1 Circuit Locations into a map using Folium; a Python library used for visualizing Geospatial Data.

In the first example it was a very static version where I plotted the F1 Circuit Locations either for the World, Europe or France. These options were hardcoded in the notebook and showed after each other.

In the second example I added some interactivity with Streamlit. The idea was to switch between the World, a possible Continent and a possible Country based on selected radio buttons in the sidebar.

The third example shows the same setup but then from the Streamlit Cloud. The code is on GitHub.

In this final example I went over to deploy the same app on Hugging Face.

Till next time.

Daan Bakboord – DaAnalytics

Bekijk ook:

Snowflake’s Data Classification in Snowsight

Snowflake Data Governance directly from Snowsight

Last year I blogged about how to use Snowflake functionality to; “Know your Data”. Especially in these times where Generative AI becomes more and more mainstream, it’s essential to know what data is input for the LLM’s. Now Snowflake has made this a few clicks easier, offering classifying functionalities directly from Snowsight.

Lees verder »