Answers for "streamlit download image"

0

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)
Posted by: Guest on November-28-2020

Python Answers by Framework

Browse Popular Code Answers by Language