Streamlit Python
Streamlit Python
desiging WebApp
●
Streamlit is a free and open-source framework to rapidly build
and share beautiful machine learning and data science web
apps.
●
It is a Python-based library specifically designed for machine
learning engineers.
●
Data scientists or machine learning engineers are not web
developers and they're not interested in spending weeks learning
to use these frameworks to build web apps
●
Streamlit allows you to create a stunning-looking application
with only a few lines of code.
Web Application:
– No front-end (html, js, css) experience or knowledge is required.
– No need to create web-app but can create beautiful machine
learning or datascience app with in few hours
– Compatible with majority of Python libraries like Pandas,
Numpy, matplotlib, seaborn, ploty, etc.,
– Data caching simplifies and speeds up computation pipelines
Install Streamlit on Linux
Invoke the terminal Ctrl+Alt+T
$ sudo apt-get install python3-pip
$ pip3 install pipenv
$ cd project_folder_name
$ pipenv shell
$ pip install streamlit
$ streamlit hello
●
How to run your Streamlit code
– streamlit run file_name.py
●
Display texts with Streamlit
– import streamlit as st
– st.write("Hello ,let's learn how to build a streamlit app together")
– st.title ("this is the app title")
– st.header("this is the markdown")
– st.markdown("this is the header")
– st.subheader("this is the subheader")
– st.caption("this is the caption")
– st.code("x=2021")
– st.latex(r''' a+a r^1+a r^2+a r^3 ''')
●
Display an image, video or audio file with Streamlit
– st.image("kid.jpg")
– st.audio("Audio.mp3")
– st.video("video.mp4")
●
Input widgets
– st.checkbox('yes')
– st.button('Click')
– st.radio('Pick your gender',['Male','Female'])
– st.selectbox('Pick your gender',['Male','Female'])
– st.multiselect('choose a planet',['Jupiter', 'Mars', 'neptune'])
– st.select_slider('Pick a mark', ['Bad', 'Good', 'Excellent'])
– st.slider('Pick a number', 0,50)
●
st.number_input('Pick a number', 0,10)
●
st.text_input('Email address')
●
st.date_input('Travelling date')
●
st.time_input('School time')
●
st.text_area('Description')
●
st.file_uploader('Upload a photo')
●
st.color_picker('Choose your favorite color')
●
Display progress and status with Streamlit
– st.balloons()
– st.progress(10)
– with st.spinner('Wait for it...'): time.sleep(10)
– st.success("You did it !")
– st.error("Error")
– st.warnig("Warning")
– st.info("It's easy to build a streamlit app")
– st.exception(RuntimeError("RuntimeError exception"))