【发布时间】:2022-08-16 10:01:13
【问题描述】:
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\")
我想使用 st.download_button 下载图像结果。我知道我不能使用cropped_image 结果,因为它是一个np 数组。我将图像数组转换为 PIL 图像,但我不知道如何从此处获取结果图像文件名。你能给我一些想法如何解决这个问题吗?