Viewing pm4py image rendering AttributeError: 'NoneType' object has no attribute 'read'

Hi, how can I view PM4PY image as image in container?

My codes:

import pm4py
from PIL import Image

def prepare_df():
    df1 = df[["case_id", "activity_id", "timestamp"]]
    df1["case_id"] = df1["case_id"].astype(str)
    df1["activity_id"] = df1["activity_id"].astype(str)
    df_log = pm4py.format_dataframe(df1, case_id='case_id', activity_key='activity_id', timestamp_key='timestamp')
    return df_log

df_log = prepare_df()

map2 = pm4py.discover_heuristics_net(df_log)
image2 =

with bpm_discovery:
    st.image(image2, caption='Heuristic Minners algorithm')

I am getting AttributeError: ‘NoneType’ object has no attribute ‘read’

It looks like you have not defined “df_log”

@cualr Thanks for the reply, sorry I didn’t enclose the rest of the code from the start.
df_log is defined previously in other function and stored in cache, I could access and use it in other containers