Update app.py
Browse files
app.py
CHANGED
@@ -61,7 +61,7 @@ id2label = {
|
|
61 |
|
62 |
# #Get the file path
|
63 |
|
64 |
-
file = st.file_uploader("File upload", type=[
|
65 |
|
66 |
if uploaded_file is not None:
|
67 |
|
@@ -71,36 +71,36 @@ if uploaded_file is not None:
|
|
71 |
temp.write(bytes_data)
|
72 |
print(temp.name)
|
73 |
|
74 |
-
#
|
75 |
-
|
76 |
|
77 |
-
|
78 |
-
|
79 |
|
80 |
-
#
|
81 |
-
|
82 |
|
83 |
-
|
84 |
|
85 |
-
#
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
|
97 |
-
#
|
98 |
-
|
99 |
|
100 |
-
#
|
101 |
-
|
102 |
|
103 |
|
104 |
-
|
105 |
-
|
106 |
|
|
|
61 |
|
62 |
# #Get the file path
|
63 |
|
64 |
+
file = st.file_uploader("File upload", type=['pdf', 'docx', 'txt'])
|
65 |
|
66 |
if uploaded_file is not None:
|
67 |
|
|
|
71 |
temp.write(bytes_data)
|
72 |
print(temp.name)
|
73 |
|
74 |
+
# # Process file
|
75 |
+
par_list = get_paragraphs(temp.name)
|
76 |
|
77 |
+
### Make predictions
|
78 |
+
preds = vg_model(par_list)
|
79 |
|
80 |
+
# Get label names
|
81 |
+
preds_list = preds.tolist()
|
82 |
|
83 |
+
predictions_names=[]
|
84 |
|
85 |
+
# loop through each prediction
|
86 |
+
for ele in preds_list:
|
87 |
+
try:
|
88 |
+
index_of_one = ele.index(1)
|
89 |
+
except ValueError:
|
90 |
+
index_of_one = "NA"
|
91 |
+
if index_of_one != "NA":
|
92 |
+
name = id2label[index_of_one]
|
93 |
+
else:
|
94 |
+
name = "NA"
|
95 |
+
predictions_names.append(name)
|
96 |
|
97 |
+
# Combine the paragraphs and labels to a dataframe
|
98 |
+
df_predictions = pd.DataFrame({'Paragraph': par_list, 'Prediction': predictions_names})
|
99 |
|
100 |
+
# Drop all "Other" and "NA" predictions
|
101 |
+
filtered_df = df[df['Prediction'].isin(['Other', 'NA'])]
|
102 |
|
103 |
|
104 |
+
#####################################
|
105 |
+
st.write(df)
|
106 |
|