added tabs
Browse files
app.py
CHANGED
@@ -6,25 +6,6 @@ import pickle
|
|
6 |
import requests
|
7 |
import base64
|
8 |
|
9 |
-
@st.cache_data(ttl=3600)
|
10 |
-
def read_model(url):
|
11 |
-
response = requests.get(url)
|
12 |
-
open("temp.pkl", "wb").write(response.content)
|
13 |
-
with open("temp.pkl", "rb") as f:
|
14 |
-
svm_classifier = pickle.load(f)
|
15 |
-
return svm_classifier
|
16 |
-
|
17 |
-
|
18 |
-
def read_tf(url):
|
19 |
-
response = requests.get(url)
|
20 |
-
open("temp.pkl", "wb").write(response.content)
|
21 |
-
with open("temp.pkl", "rb") as f:
|
22 |
-
preprocessing = pickle.load(f)
|
23 |
-
return preprocessing
|
24 |
-
|
25 |
-
svm_classifier = read_model("https://github.com/manika-lamba/ml/raw/main/model2.pkl")
|
26 |
-
preprocessing = read_tf("https://github.com/manika-lamba/ml/raw/main/preprocessing.pkl")
|
27 |
-
|
28 |
|
29 |
|
30 |
# Create sidebar
|
@@ -33,8 +14,7 @@ preprocessing = read_tf("https://github.com/manika-lamba/ml/raw/main/preprocessi
|
|
33 |
st.sidebar.header("Choose CSV File with 'Abstract' field")
|
34 |
uploaded_file = st.sidebar.file_uploader("", type=["csv"])
|
35 |
|
36 |
-
|
37 |
-
st.sidebar.text("Download the tagged results as a CSV file.")
|
38 |
|
39 |
|
40 |
|
@@ -60,6 +40,25 @@ with tab2:
|
|
60 |
st.dataframe(df)
|
61 |
|
62 |
# Function to predict the category for a given abstract
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
def predict_category(abstract):
|
64 |
# Preprocess the abstract
|
65 |
abstract_preprocessed = preprocessing.transform([abstract])
|
@@ -70,6 +69,8 @@ def predict_category(abstract):
|
|
70 |
with tab3:
|
71 |
#===download result===
|
72 |
# Create a download button
|
|
|
|
|
73 |
|
74 |
if st.sidebar.button("Download"):
|
75 |
csv = df.to_csv(index=False)
|
|
|
6 |
import requests
|
7 |
import base64
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
|
11 |
# Create sidebar
|
|
|
14 |
st.sidebar.header("Choose CSV File with 'Abstract' field")
|
15 |
uploaded_file = st.sidebar.file_uploader("", type=["csv"])
|
16 |
|
17 |
+
|
|
|
18 |
|
19 |
|
20 |
|
|
|
40 |
st.dataframe(df)
|
41 |
|
42 |
# Function to predict the category for a given abstract
|
43 |
+
@st.cache_data(ttl=3600)
|
44 |
+
def read_model(url):
|
45 |
+
response = requests.get(url)
|
46 |
+
open("temp.pkl", "wb").write(response.content)
|
47 |
+
with open("temp.pkl", "rb") as f:
|
48 |
+
svm_classifier = pickle.load(f)
|
49 |
+
return svm_classifier
|
50 |
+
|
51 |
+
|
52 |
+
def read_tf(url):
|
53 |
+
response = requests.get(url)
|
54 |
+
open("temp.pkl", "wb").write(response.content)
|
55 |
+
with open("temp.pkl", "rb") as f:
|
56 |
+
preprocessing = pickle.load(f)
|
57 |
+
return preprocessing
|
58 |
+
|
59 |
+
svm_classifier = read_model("https://github.com/manika-lamba/ml/raw/main/model2.pkl")
|
60 |
+
preprocessing = read_tf("https://github.com/manika-lamba/ml/raw/main/preprocessing.pkl")
|
61 |
+
|
62 |
def predict_category(abstract):
|
63 |
# Preprocess the abstract
|
64 |
abstract_preprocessed = preprocessing.transform([abstract])
|
|
|
69 |
with tab3:
|
70 |
#===download result===
|
71 |
# Create a download button
|
72 |
+
st.sidebar.header("Download Results")
|
73 |
+
st.sidebar.text("Download the tagged results as a CSV file.")
|
74 |
|
75 |
if st.sidebar.button("Download"):
|
76 |
csv = df.to_csv(index=False)
|