Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import streamlit as st
|
2 |
-
#from streamlit_pills import pills
|
3 |
import torch
|
4 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
5 |
import fitz
|
@@ -31,11 +30,9 @@ def predict_class(text):
|
|
31 |
st.error(f"Error during prediction: {e}")
|
32 |
return None
|
33 |
|
34 |
-
|
35 |
uploaded_files_dir = "uploaded_files"
|
36 |
os.makedirs(uploaded_files_dir, exist_ok=True)
|
37 |
|
38 |
-
|
39 |
class_colors = {
|
40 |
0: "#d62728", # Level 1
|
41 |
1: "#ff7f0e", # Level 2
|
@@ -45,7 +42,6 @@ class_colors = {
|
|
45 |
|
46 |
st.set_page_config(page_title="Paper Citation Classifier", page_icon="logo.png")
|
47 |
|
48 |
-
|
49 |
with st.sidebar:
|
50 |
st.image("logo.png", width=70)
|
51 |
st.markdown('<div style="position: absolute; left: 5px;"></div>', unsafe_allow_html=True)
|
@@ -77,16 +73,12 @@ if option == "Text":
|
|
77 |
keywords_input = st.text_area("Enter Keywords:")
|
78 |
options=["Nursing", "Physics", "Maths", "Chemical", "Nuclear", "Engineering" ,"Other"]
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
selected_categories = st.selectbox("Select WoS categories:", options)
|
83 |
if selected_category == "Other":
|
84 |
custom_category = st.text_input("Enter custom category:")
|
85 |
selected_category = custom_category if custom_category else "Other"
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
combined_text = f"{title_input} [SEP] {keywords_input} [SEP] {abstract_input} [SEP] {full_text_input} [SEP] {affiliations_input} [SEP] {' [SEP] '.join(categories)}"
|
90 |
|
91 |
if st.button("Predict"):
|
92 |
if not any([title_input, abstract_input,keywords_input, full_text_input, affiliations_input]):
|
|
|
1 |
import streamlit as st
|
|
|
2 |
import torch
|
3 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
4 |
import fitz
|
|
|
30 |
st.error(f"Error during prediction: {e}")
|
31 |
return None
|
32 |
|
|
|
33 |
uploaded_files_dir = "uploaded_files"
|
34 |
os.makedirs(uploaded_files_dir, exist_ok=True)
|
35 |
|
|
|
36 |
class_colors = {
|
37 |
0: "#d62728", # Level 1
|
38 |
1: "#ff7f0e", # Level 2
|
|
|
42 |
|
43 |
st.set_page_config(page_title="Paper Citation Classifier", page_icon="logo.png")
|
44 |
|
|
|
45 |
with st.sidebar:
|
46 |
st.image("logo.png", width=70)
|
47 |
st.markdown('<div style="position: absolute; left: 5px;"></div>', unsafe_allow_html=True)
|
|
|
73 |
keywords_input = st.text_area("Enter Keywords:")
|
74 |
options=["Nursing", "Physics", "Maths", "Chemical", "Nuclear", "Engineering" ,"Other"]
|
75 |
|
76 |
+
selected_category = st.selectbox("Select WoS categories:", options)
|
|
|
|
|
77 |
if selected_category == "Other":
|
78 |
custom_category = st.text_input("Enter custom category:")
|
79 |
selected_category = custom_category if custom_category else "Other"
|
80 |
|
81 |
+
combined_text = f"{title_input} [SEP] {keywords_input} [SEP] {abstract_input} [SEP] {full_text_input} [SEP] {affiliations_input} [SEP] {' [SEP] '.join(selected_categories)}"
|
|
|
|
|
82 |
|
83 |
if st.button("Predict"):
|
84 |
if not any([title_input, abstract_input,keywords_input, full_text_input, affiliations_input]):
|