st-chat icon indicating copy to clipboard operation
st-chat copied to clipboard

Images pass to the avatar won't appear on streamlit share

Open le-baronysard opened this issue 1 year ago • 0 comments

The avatar argument in st.chat_message doesnt work with custom images. When putting the streamlit in streamlit share instead of the custom image this is what is shown :

Capture d’écran 2023-07-06 à 23 47 05

I'm passing the custom image like that

avatar = Pil.Image.open("static/avatar.jpg")
with` st.chat_message("assistant",avatar=avatar):   
        with st.spinner("Thinking..."):
            response = "Something the bot say"
            st.write(response)  

I have also tried to read the images differently : avatar = open("static/avatar.jpg", "rb").read() avatar = np.array(Image.open("data/avatar.jpg"))

All the methods works fine when running streamlit in local but fails in streamlit share

Edit : I have noticed that the little image of my bot is served this way in htmle <img src="/media/121f19f90f4c90cef78b3269ceb860024967c4a93b3e1ceee23993e3.jpg" <-- my image was named avatar.jpg If i remove the "/" in the beginning in the html code of the page it works <img src="media/121f19f90f4c90cef78b3269ceb860024967c4a93b3e1ceee23993e3.jpg" Maybe it could be a clue

le-baronysard avatar Jul 06 '23 22:07 le-baronysard