st.write("Preview")
#openCV image result cropped_image which is an np array
st.image(cropped_image)
#cropped_image converted to PIL image color
result = Image.fromarray(cropped_image.astype('uint8'), 'RGB')
img = Image.open(result)
btn = st.download_button(
label="Download image",
data=img,
file_name="imagename.png",
mime="image/png")
I want to use st.download_button to download the image result. I know I cannot use the cropped_image result since it is an np array. I converted the image array to a PIL image but I don't know how I can get the result image filename from here . Could you please give me some ideas how to solve this issue?