streamlit code example

Example 1: streamlit pip

pip install streamlit

Example 2: streamlit dropdown

# Add selectbox in streamlit
>>> option = st.selectbox(
...     'How would you like to be contacted?',
...     ('Email', 'Home phone', 'Mobile phone'))
>>>
>>> st.write('You selected:', option)

Example 3: streamlit python install

pip install streamlit

Example 4: streamlit python install

streamlit run myfile.py

Example 5: streamlit download image

result = Image.fromarray(predicted_img)

def get_image_download_link(img):
	"""Generates a link allowing the PIL image to be downloaded
	in:  PIL image
	out: href string
	"""
	buffered = BytesIO()
	img.save(buffered, format="JPEG")
	img_str = base64.b64encode(buffered.getvalue()).decode()
	href = f'<a href="data:file/jpg;base64,{img_str}">Download result</a>'
	return href

st.markdown(get_image_download_link(result), unsafe_allow_html=True)