update
Browse files- src/streamlit_app.py +71 -47
src/streamlit_app.py
CHANGED
|
@@ -3,53 +3,77 @@ from datasets import load_dataset
|
|
| 3 |
|
| 4 |
st.set_page_config(page_title="Paper Explorer", layout="wide")
|
| 5 |
|
| 6 |
-
# 1. Initialize Session
|
|
|
|
|
|
|
| 7 |
if 'page_number' not in st.session_state:
|
| 8 |
st.session_state.page_number = 0
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
st.set_page_config(page_title="Paper Explorer", layout="wide")
|
| 5 |
|
| 6 |
+
# 1. Initialize Session States
|
| 7 |
+
if 'current_view' not in st.session_state:
|
| 8 |
+
st.session_state.current_view = "trending" # Default view
|
| 9 |
if 'page_number' not in st.session_state:
|
| 10 |
st.session_state.page_number = 0
|
| 11 |
|
| 12 |
+
# --- 2. Custom Top Navigation ---
|
| 13 |
+
nav_container = st.container()
|
| 14 |
+
with nav_container:
|
| 15 |
+
col1, col2, col3, col4, col5 = st.columns([1, 1.5, 2, 1, 1])
|
| 16 |
+
|
| 17 |
+
with col1:
|
| 18 |
+
st.markdown("### π PWC")
|
| 19 |
+
with col2:
|
| 20 |
+
# When clicked, this button sets the view to "trending"
|
| 21 |
+
if st.button("π₯ Trending", use_container_width=True):
|
| 22 |
+
st.session_state.current_view = "trending"
|
| 23 |
+
with col3:
|
| 24 |
+
if st.button("π Browse SOTA", use_container_width=True):
|
| 25 |
+
st.session_state.current_view = "sota"
|
| 26 |
+
with col4:
|
| 27 |
+
if st.button("π Datasets", use_container_width=True):
|
| 28 |
+
st.session_state.current_view = "datasets"
|
| 29 |
+
with col5:
|
| 30 |
+
if st.button("π§© Methods", use_container_width=True):
|
| 31 |
+
st.session_state.current_view = "methods"
|
| 32 |
+
|
| 33 |
+
st.divider()
|
| 34 |
+
|
| 35 |
+
# --- 3. View Logic ---
|
| 36 |
+
|
| 37 |
+
if st.session_state.current_view == "trending":
|
| 38 |
+
st.subheader("Trending Papers")
|
| 39 |
+
|
| 40 |
+
# Pagination UI
|
| 41 |
+
PAGE_SIZE = 10
|
| 42 |
+
c1, c2, c3 = st.columns([1, 2, 1])
|
| 43 |
+
|
| 44 |
+
with c1:
|
| 45 |
+
if st.button("β¬
οΈ Previous", disabled=(st.session_state.page_number == 0)):
|
| 46 |
+
st.session_state.page_number -= 1
|
| 47 |
+
st.rerun() # Refresh to update data
|
| 48 |
+
with c2:
|
| 49 |
+
st.write(f"Center: Page {st.session_state.page_number + 1}")
|
| 50 |
+
with c3:
|
| 51 |
+
if st.button("Next β‘οΈ"):
|
| 52 |
+
st.session_state.page_number += 1
|
| 53 |
+
st.rerun()
|
| 54 |
+
|
| 55 |
+
# Data Fetching
|
| 56 |
+
offset = st.session_state.page_number * PAGE_SIZE
|
| 57 |
+
with st.spinner("Loading papers..."):
|
| 58 |
+
dataset = load_dataset("pwc-archive/papers-with-abstracts", split="train", streaming=True)
|
| 59 |
+
papers = list(dataset.skip(offset).take(PAGE_SIZE))
|
| 60 |
+
|
| 61 |
+
# Display Papers
|
| 62 |
+
for p in papers:
|
| 63 |
+
with st.container():
|
| 64 |
+
st.markdown(f"### {p['title']}")
|
| 65 |
+
st.write(p['abstract'][:500] + "...")
|
| 66 |
+
if p.get('arxiv_id'):
|
| 67 |
+
st.link_button("View on ArXiv", f"https://arxiv.org/abs/{p['arxiv_id']}")
|
| 68 |
+
st.divider()
|
| 69 |
+
|
| 70 |
+
elif st.session_state.current_view == "sota":
|
| 71 |
+
st.title("π State-of-the-Art")
|
| 72 |
+
st.info("Leaderboards coming soon! This page will show rankings for different ML tasks.")
|
| 73 |
+
if st.button("Back to Trending"):
|
| 74 |
+
st.session_state.current_view = "trending"
|
| 75 |
+
st.rerun()
|
| 76 |
+
|
| 77 |
+
else:
|
| 78 |
+
st.title("Under Construction")
|
| 79 |
+
st.write(f"The **{st.session_state.current_view}** section is currently being indexed.")
|