BK-AI commited on
Commit
a09bb13
1 Parent(s): 6286028

adjust deprecated functionality

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -14,6 +14,7 @@ from langdetect import detect
14
  from matplotlib import pyplot as plt
15
  import imageio
16
  import logging
 
17
 
18
  logging.getLogger().setLevel(logging.INFO)
19
 
@@ -157,9 +158,13 @@ def textclassification(SubmittedText):
157
 
158
  for pipe, barnames in zip((pipeDep, pipeOffice), (labelsDep, labelsOffice)):
159
  plt.clf()
160
- prediction = pipe(SubmittedText[0:1000], top_k=None)
161
- # print(prediction)
162
- rates = [row["score"] for row in prediction]
 
 
 
 
163
 
164
  # Create barplot & output text
165
  im, barnames = create_bar_plot(rates, barnames)
 
14
  from matplotlib import pyplot as plt
15
  import imageio
16
  import logging
17
+ import warnings
18
 
19
  logging.getLogger().setLevel(logging.INFO)
20
 
 
158
 
159
  for pipe, barnames in zip((pipeDep, pipeOffice), (labelsDep, labelsOffice)):
160
  plt.clf()
161
+
162
+ # catch deprecation warning, as new functionality following the deprecated way
163
+ # sorts results the wrong way and cannot be easily fixed
164
+ with warnings.catch_warnings():
165
+ warnings.filterwarnings("ignore")
166
+ prediction = pipe(SubmittedText[0:1000], return_all_scores=True)
167
+ rates = [row["score"] for row in prediction[0]]
168
 
169
  # Create barplot & output text
170
  im, barnames = create_bar_plot(rates, barnames)