streamlit download image code example
Example: 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'Download result'
return href
st.markdown(get_image_download_link(result), unsafe_allow_html=True)