I just started using Streamlit (sorry if I’ve missed it in the docs!) but I still don’t know how to display an image with its image url instead of loading and opening an image locally using st.image
My current product is to get a user image and gives out a label after the classification model. Then based on the label, it matches with the loaded csv file that contains a list of labels and the associated product names, urls and image urls. I could display product names and urls as recommended products, but not the images. Any advice or help would be great!
Thank you so much for replying! Sorry I have been trying it many times and I’m still having some trouble.
I tested it and the image doesn’t show up:
I think it’s the way I call these image links - it works if I directly put the link in as your example shows, but since the link is generated depending on my model, I wouldn’t be able to insert it directly since I don’t know what image would be shown.
currently, product1 would get the first link that is returned through my recommendation system, and I would like to display it
I believe you are getting an error because when you are obtaining the image URL after converting the product_img column of the dataframe df into a list product_img , it is a string object.
Two logical issues🤔:
Whenever we write markdown syntax(to the best of my knowledge) it is not possible to add load values from variables (or any data structures like strings, lists,etc)
Even if you just had the URL, you need to paste it without any quotes like the following✅:
st.image(
"https://s3-us-west-2.amazonaws.com/uw-s3-cdn/wp-content/uploads/sites/6/2017/11/04133712/waterfall.jpg",
width=400, # Manually Adjust the width of the image as per requirement
)
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.