St.image() not working, returns a DeltaGenerator() object

Hello, I am trying to load an image in my folder that I want to use as a page icon. I am using Jupyter notebook on VS Code.
If I run the PIL function Image.open("assets/fruitbasket.png"), the image instantly displays. However, if I use st.image(image='assets/fruitbasket.png', caption='Fruit Basket', output_format="PNG"), an instance called “DeltaGenerator()” is returned by the cell. No image is displayed. Please help. And what is the DeltaGenerator?

Hi @ASTRONOE

To display an image in-app, you can use:

import streamlit as st
from PIL import Image

image = Image.open('image.png')
st.image(image)
img = Image.open("assets/fruitbasket.png")`

st.set_page_config(page_icon=img)

That’s my code. I stated that PIL.Image.open() works well. St.image() is not functioning at all. All it returns is “DeltaGenerator()”. And I ask, what is this thing. Has anyone encountered it before??

Can you explain what exactly you are trying to do?


The DeltaGenerator is the connection that streamlit creates to link the Python code and the JS element that is served in the web app, so it transfers the HTML to render in the browser and retrieves back its state.

I just realized that it does not render pages on HTML or jupyter notebooks. Hence the reason why it just drops “DeltaGenerator()” as the cell output.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.