As you may see in the download_button function, there is an if alse statement if picle_it, inside else statement there is another if else statement in which it checks the distance.
you can see that there is written that if instance is pd.DataFrame, then you should use method ‘to_csv’
you need to change it to: pd.dataframe.to_excel() for more info check it here:pandas.DataFrame.to_excel — pandas 1.2.4 documentation
Hi, I am using similar function however when I call the function, along with the Download CSV hyperlink, I also get the None. Any idea how I can fix this?
Thanks for the answer it worked perfectly. Is it possible to send the bin_str in a mail as a hyperlink? I tried but was only able to get to display the wanted text with HTML but it was not clickable
My code is:
def send_email(email_address, download_link):
sender_email = ""
password = ""
msg = MIMEMultipart("alternative")
msg["Subject"] = "Your results are in!"
msg["From"] = sender_email
msg["To"] = email_address
html_line ="""<html> random text {download_link}</html>""".format(download_link=download_link)
print(download_link)
part = MIMEText(html_line, "html")
msg.attach(part)
context = ssl.create_default_context()
with smtplib.SMTP_SSL("smtp.gmail.com", 465, context=context) as server:
server.login(sender_email, password)
server.sendmail(
sender_email, email_address, msg.as_string()
)
download_link is the whole href output from get_binary_file_downloader_html
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 no use the cropped_image result since an np array. I converted the image array to a PIL image but I don’t know what I need to do from here to get the result image filename or how to pass the result image to the st.download_button. Could anyone please give me some ideas how to solve this issue.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.