Spaces:
Sleeping
Sleeping
Raman Hasymau commited on
Commit ·
f58df3f
1
Parent(s): d6e3dc6
add load from arxiv
Browse files- requirements.txt +1 -0
- src/streamlit_app.py +28 -2
requirements.txt
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
altair
|
|
|
|
| 2 |
pandas
|
| 3 |
streamlit
|
| 4 |
transformers
|
|
|
|
| 1 |
altair
|
| 2 |
+
arxiv
|
| 3 |
pandas
|
| 4 |
streamlit
|
| 5 |
transformers
|
src/streamlit_app.py
CHANGED
|
@@ -1,9 +1,15 @@
|
|
| 1 |
import os
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
st.set_page_config(page_title="ArXiv Paper Classifier", page_icon="📄")
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
@st.cache_resource
|
| 9 |
def load_pipeline():
|
|
@@ -16,10 +22,30 @@ classifier = load_pipeline()
|
|
| 16 |
st.title("ArXiv Paper Classifier")
|
| 17 |
st.write("Enter a paper's title and abstract to predict its subject category.")
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
if st.button("Classify"):
|
|
|
|
|
|
|
|
|
|
| 23 |
if not title.strip() and not abstract.strip():
|
| 24 |
st.error("Please provide at least a title or an abstract.")
|
| 25 |
st.stop()
|
|
|
|
| 1 |
import os
|
| 2 |
+
import arxiv
|
| 3 |
import streamlit as st
|
| 4 |
from transformers import pipeline
|
| 5 |
|
| 6 |
st.set_page_config(page_title="ArXiv Paper Classifier", page_icon="📄")
|
| 7 |
|
| 8 |
+
if "auto_title" not in st.session_state:
|
| 9 |
+
st.session_state["auto_title"] = ""
|
| 10 |
+
if "auto_abstract" not in st.session_state:
|
| 11 |
+
st.session_state["auto_abstract"] = ""
|
| 12 |
+
|
| 13 |
|
| 14 |
@st.cache_resource
|
| 15 |
def load_pipeline():
|
|
|
|
| 22 |
st.title("ArXiv Paper Classifier")
|
| 23 |
st.write("Enter a paper's title and abstract to predict its subject category.")
|
| 24 |
|
| 25 |
+
with st.expander("Load from link", expanded=True):
|
| 26 |
+
arxiv_url = st.text_input("ArXiv URL", placeholder="https://arxiv.org/abs/1706.03762")
|
| 27 |
+
if st.button("Fetch paper data"):
|
| 28 |
+
if "arxiv.org/abs/" not in arxiv_url:
|
| 29 |
+
st.warning("Please enter a valid ArXiv URL containing 'arxiv.org/abs/'.")
|
| 30 |
+
else:
|
| 31 |
+
paper_id = arxiv_url.rstrip("/").split("/")[-1].split("v")[0]
|
| 32 |
+
with st.spinner("Fetching from ArXiv..."):
|
| 33 |
+
try:
|
| 34 |
+
search = arxiv.Search(id_list=[paper_id])
|
| 35 |
+
paper = next(search.results())
|
| 36 |
+
st.session_state["auto_title"] = paper.title
|
| 37 |
+
st.session_state["auto_abstract"] = paper.summary
|
| 38 |
+
st.success(f"Loaded: {paper.title}")
|
| 39 |
+
except Exception as e:
|
| 40 |
+
st.error(f"Failed to fetch paper: {e}")
|
| 41 |
+
|
| 42 |
+
st.text_input("Title", key="auto_title")
|
| 43 |
+
st.text_area("Abstract", height=200, key="auto_abstract")
|
| 44 |
|
| 45 |
if st.button("Classify"):
|
| 46 |
+
title = st.session_state["auto_title"]
|
| 47 |
+
abstract = st.session_state["auto_abstract"]
|
| 48 |
+
|
| 49 |
if not title.strip() and not abstract.strip():
|
| 50 |
st.error("Please provide at least a title or an abstract.")
|
| 51 |
st.stop()
|