I am trying to display results of PM4PY algorithm on streamlit webApp. I was advised to display it as image (it doesn't need to be image if you have other recommendation), however I am facing AttributeError: 'NoneType' object has no attribute 'read' when doing so - the error is coming from image.open()
| case_id | activity_id | timestamp |
|---|---|---|
| 1 | Accepted | 2021-12-20T15:52:47 |
| 1 | Awaiting Documentation | 2021-12-20T14:57:58 |
| 1 | Complete Activated | 2021-12-20T14:59:14 |
| 2 | Approved | 2021-12-20T14:57:59 |
My code:
import pm4py
import streamlit as st
from PIL import Image
@st.cache
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()
bpm_discovery = st.container()
map2 = pm4py.discover_heuristics_net(df_log)
image2 = Image.open(pm4py.view_heuristics_net(map2))
with bpm_discovery:
st.image(image2, caption=‘Heuristic Minners algorithm’)
The error I am getting:
AttributeError: 'NoneType' object has no attribute 'read'
Traceback:
File "C:\Users\HAXY8W\PycharmProjects\processAnalysisApp\venv\lib\site-packages\streamlit\scriptrunner\script_runner.py", line 443, in _run_script
exec(code, module.__dict__)
File "C:\Users\HAXY8W\PycharmProjects\processAnalysisApp\processAnalysis.py", line 83, in <module>
image2 = Image.open(pm4py.view_heuristics_net(map2))
File "C:\Users\HAXY8W\PycharmProjects\processAnalysisApp\venv\lib\site-packages\PIL\Image.py", line 3074, in open
fp = io.BytesIO(fp.read())
