streamlit download image

Solutions on MaxInterview for streamlit download image by the best coders in the world

showing results for - "streamlit download image"
Hector
06 Feb 2019
1result = Image.fromarray(predicted_img)
2
3def get_image_download_link(img):
4	"""Generates a link allowing the PIL image to be downloaded
5	in:  PIL image
6	out: href string
7	"""
8	buffered = BytesIO()
9	img.save(buffered, format="JPEG")
10	img_str = base64.b64encode(buffered.getvalue()).decode()
11	href = f'<a href="data:file/jpg;base64,{img_str}">Download result</a>'
12	return href
13
14st.markdown(get_image_download_link(result), unsafe_allow_html=True)