Spaces:
Running
Running
Alexey Kalinin
commited on
Commit
·
f4107c5
1
Parent(s):
01fad96
add the blanks
Browse files- app.py +46 -0
- inference.py +6 -0
app.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import arxiv
|
3 |
+
from inference import classify, load_model # Replace with your actual module
|
4 |
+
|
5 |
+
@st.cache_resource
|
6 |
+
def get_model():
|
7 |
+
return load_model()
|
8 |
+
|
9 |
+
def get_arxiv_article_info(url):
|
10 |
+
"""Extracts title and abstract from an arXiv article link."""
|
11 |
+
paper_id = url.split("/abs/")[-1]
|
12 |
+
search = arxiv.Search(id_list=[paper_id])
|
13 |
+
|
14 |
+
for result in search.results():
|
15 |
+
return result.title, result.summary
|
16 |
+
return None, None
|
17 |
+
|
18 |
+
# Load model once
|
19 |
+
model = get_model()
|
20 |
+
|
21 |
+
st.title("ArXiv Article Classifier")
|
22 |
+
|
23 |
+
# Input method selection
|
24 |
+
input_method = st.radio("Select input method:", ("ArXiv Link", "Manual Input"))
|
25 |
+
|
26 |
+
title, abstract = None, None
|
27 |
+
|
28 |
+
if input_method == "ArXiv Link":
|
29 |
+
arxiv_url = st.text_input("Enter ArXiv article link:")
|
30 |
+
if st.button("Classify"):
|
31 |
+
if arxiv_url:
|
32 |
+
title, abstract = get_arxiv_article_info(arxiv_url)
|
33 |
+
else:
|
34 |
+
st.error("Please enter a valid ArXiv link.")
|
35 |
+
elif input_method == "Manual Input":
|
36 |
+
title = st.text_input("Enter Article Title:")
|
37 |
+
abstract = st.text_area("Enter Article Abstract:")
|
38 |
+
if st.button("Classify"):
|
39 |
+
if not title or not abstract:
|
40 |
+
st.error("Please provide both title and abstract.")
|
41 |
+
|
42 |
+
# Classification and output
|
43 |
+
if title and abstract:
|
44 |
+
category = classify(title, abstract)
|
45 |
+
st.write(f"### Title: {title}")
|
46 |
+
st.write(f"**Predicted Category:** {category}")
|
inference.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def load_model():
|
2 |
+
pass
|
3 |
+
|
4 |
+
def classify(title, abstract):
|
5 |
+
return "physics"
|
6 |
+
|