I make app which visualizate 3 cameras in real time(in while) and 1 statical pdf(outide loop) 1.5Mb with text and images.
If I use only cameras I have around 5 fps, if I add pdf it become less than 1.
I trued use cache. but this not help
@st.cache_data
def pdf():
with st.sidebar:
st.markdown(pdf_viewer.show_pdf(st.session_state.pdf_file_path), unsafe_allow_html=True)
# Function to read PDF and return content
@st.cache_data
def read_pdf(file_path):
# Replace with your PDF reading logic
with open(file_path, "rb") as f:
base64_pdf = base64.b64encode(f.read()).decode("utf-8")
return base64_pdf
# Function to display PDF content
@st.cache_data
def display_pdf(base64_pdf):
pdf_display = f'<embed src="data:application/pdf;base64, {base64_pdf}" width="500" height="600" ' \
f'type="application/pdf"> '
return pdf_display
@st.cache_data
def show_pdf(pdf_file_path):
pdf_content = read_pdf(pdf_file_path)
pdf_display = display_pdf(pdf_content)
return pdf_display
Locally
Streamlit 1.31 and Python 3.11