I’ve deployed a Streamlit app on Google Cloud Run and I’m having issues with displaying an image. The image is loaded using Image.open() and displayed using st.image() . Initially, the image was displayed correctly, but after a day or two, part of the image becomes a black box as shown below:
My guess is that the Image is never closed, so each time the app is rerun, a new pointer is created without properly handling the previous open action. Do you get the same issue using a context manager?
import streamlit as st
from PIL import Image
from pathlib import Path
DATA = Path(".")
with Image.open(DATA/"logo.jpeg") as title_image:
Just curious, is there a particular reason to not pass the path to st.image directly?