File size: 2,114 Bytes
c684f94 5528cae 5a9443d c684f94 e09c2af b076b9c e6fdcd2 e09c2af b076b9c e6fdcd2 c684f94 b076b9c c684f94 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
import os
import streamlit as st
import torch
import pandas as pd
def get_device_map() -> str:
return 'cuda' if torch.cuda.is_available() else 'cpu'
device = get_device_map() # 'cpu'
custom_css = f"""
<style>
/* Making the Streamlit header sticky */
{HEADER_SELECTOR} {{
position: -webkit-sticky !important; /* For Safari */
position: sticky !important;
top: 0 !important;
z-index: 9999 !important; /* Very high z-index */
background-color: #90EE90 !important; /* Or your app's header background color */
/* Add a subtle shadow to make it feel more distinct when content scrolls under */
/* box-shadow: 0 2px 4px -1px rgba(0,0,0,0.1); */
/*.reportview-container .main .block-container{{ */
/* padding-top: 0rem; */
/* }} */
}}
def setup_page():
with st.spinner("In progress..."):
hf_token = os.getenv('HF_TOKEN')
df_chapters = pd.read_csv("SBS_V2_0/Chapter_Index_Rows_with_total.csv")
st.image("images/SBS_Chapter_Index.png", use_container_width=True)
st.subheader("Select specific Chapter for quicker results")
st.write(df_chapters.head())
/* Adding padding to the main content area to prevent overlap with the sticky header */
{MAIN_CONTENT_SELECTOR} {{
padding-top: 10px !important; /* {HEADER_HEIGHT} !important; */
/* background-color: yellow !important; */
/* border-style: solid !important; */
/* border-color: red !important; */
}}
/* Optional: If your app is set to wide mode and the header isn't spanning full width */
/* This might be needed if the sticky positioning affects its width calculation. */
/*
#{HEADER_SELECTOR} {{
# width: 100% !important;
#}}
#*/
</style>
"""
if __name__ == "__main__":
st.markdown(custom_css, unsafe_allow_html=True)
st.set_page_config(page_title="Sticky Header test", layout="wide")
setup_page()
|