leavoigt commited on
Commit
89edccb
1 Parent(s): eb5bd0f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -25
app.py CHANGED
@@ -61,7 +61,7 @@ id2label = {
61
 
62
  # #Get the file path
63
 
64
- file = st.file_uploader("File upload", type=["pdf"])
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
- # # Process file
75
- # par_list = get_paragraphs(uploaded_file)
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
 
 
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