Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
update plot for office classification, upload training notebook
Browse files- app.py +8 -6
- office_classification_BERT.ipynb +0 -0
app.py
CHANGED
@@ -81,9 +81,7 @@ def translate_to_de(SubmittedText):
|
|
81 |
return text
|
82 |
|
83 |
|
84 |
-
def create_bar_plot(rates,
|
85 |
-
barnames = BARS_DEP_FR if language == "fr" else BARS_DEP_DE
|
86 |
-
|
87 |
y_pos = np.arange(len(barnames))
|
88 |
plt.barh(y_pos, rates)
|
89 |
plt.yticks(y_pos, barnames)
|
@@ -128,7 +126,7 @@ def show_chosen_category(barnames, rates, language):
|
|
128 |
|
129 |
|
130 |
pipeDep = load_model("saved_model_dep")
|
131 |
-
pipeOffice = load_model("
|
132 |
|
133 |
labelencoderOffice = preprocessing.LabelEncoder()
|
134 |
labelencoderOffice.classes_ = np.load("classes_office.npy")
|
@@ -147,12 +145,16 @@ def textclassification(SubmittedText):
|
|
147 |
# Make the prediction with the 1000 first characters
|
148 |
images = []
|
149 |
chosenCategoryTexts = []
|
150 |
-
|
|
|
|
|
|
|
|
|
151 |
prediction = pipe(SubmittedText[0:1000], return_all_scores=True)
|
152 |
rates = [row["score"] for row in prediction[0]]
|
153 |
|
154 |
# Create barplot & output text
|
155 |
-
im, barnames = create_bar_plot(rates,
|
156 |
images.append(im)
|
157 |
|
158 |
chosenCategoryText = show_chosen_category(barnames, rates, language)
|
|
|
81 |
return text
|
82 |
|
83 |
|
84 |
+
def create_bar_plot(rates, barnames):
|
|
|
|
|
85 |
y_pos = np.arange(len(barnames))
|
86 |
plt.barh(y_pos, rates)
|
87 |
plt.yticks(y_pos, barnames)
|
|
|
126 |
|
127 |
|
128 |
pipeDep = load_model("saved_model_dep")
|
129 |
+
pipeOffice = load_model("saved_model_office")
|
130 |
|
131 |
labelencoderOffice = preprocessing.LabelEncoder()
|
132 |
labelencoderOffice.classes_ = np.load("classes_office.npy")
|
|
|
145 |
# Make the prediction with the 1000 first characters
|
146 |
images = []
|
147 |
chosenCategoryTexts = []
|
148 |
+
|
149 |
+
labelsDep = BARS_DEP_FR if language == "fr" else BARS_DEP_DE
|
150 |
+
labelsOffice = labelencoderOffice.classes_
|
151 |
+
|
152 |
+
for pipe, barnames in zip((pipeDep, pipeOffice), (labelsDep, labelsOffice)):
|
153 |
prediction = pipe(SubmittedText[0:1000], return_all_scores=True)
|
154 |
rates = [row["score"] for row in prediction[0]]
|
155 |
|
156 |
# Create barplot & output text
|
157 |
+
im, barnames = create_bar_plot(rates, barnames)
|
158 |
images.append(im)
|
159 |
|
160 |
chosenCategoryText = show_chosen_category(barnames, rates, language)
|
office_classification_BERT.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|