Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
adjust deprecated functionality
Browse files
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 |
-
|
| 161 |
-
#
|
| 162 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|