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)