BK-AI commited on
Commit
d1d936a
1 Parent(s): 638d345

add logging

Browse files
Files changed (1) hide show
  1. app.py +12 -2
app.py CHANGED
@@ -13,6 +13,9 @@ from sklearn import preprocessing
13
  from langdetect import detect
14
  from matplotlib import pyplot as plt
15
  import imageio
 
 
 
16
 
17
  DESCRIPTION = """Diese Anwendung teilt Vorstösse an das federführende Departement zu und
18
  macht einen Vorschlag für das zuständige Amt. Der Vorschlag der Anwendung ist nicht
@@ -135,6 +138,9 @@ labelencoderOffice.classes_ = np.load("classes_office.npy")
135
 
136
  def textclassification(SubmittedText):
137
  language = detect(SubmittedText)
 
 
 
138
 
139
  # Translate the input to german if necessary
140
  if language == "fr":
@@ -151,8 +157,9 @@ def textclassification(SubmittedText):
151
 
152
  for pipe, barnames in zip((pipeDep, pipeOffice), (labelsDep, labelsOffice)):
153
  plt.clf()
154
- prediction = pipe(SubmittedText[0:1000], return_all_scores=True)
155
- rates = [row["score"] for row in prediction[0]]
 
156
 
157
  # Create barplot & output text
158
  im, barnames = create_bar_plot(rates, barnames)
@@ -162,6 +169,9 @@ def textclassification(SubmittedText):
162
  chosenCategoryTexts.append(chosenCategoryText)
163
 
164
  # return chosenCategoryText & image for both predictions
 
 
 
165
  return chosenCategoryTexts[0], images[0], chosenCategoryTexts[1], images[1]
166
 
167
 
 
13
  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
 
20
  DESCRIPTION = """Diese Anwendung teilt Vorstösse an das federführende Departement zu und
21
  macht einen Vorschlag für das zuständige Amt. Der Vorschlag der Anwendung ist nicht
 
138
 
139
  def textclassification(SubmittedText):
140
  language = detect(SubmittedText)
141
+ logging.info(
142
+ f"SubmittedText received. Detected language: {language}. SubmittedText: {SubmittedText}"
143
+ )
144
 
145
  # Translate the input to german if necessary
146
  if language == "fr":
 
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)
 
169
  chosenCategoryTexts.append(chosenCategoryText)
170
 
171
  # return chosenCategoryText & image for both predictions
172
+ logging.info(
173
+ f"Prediction Department: {chosenCategoryTexts[0]}\n\n, Prediction Amt: {chosenCategoryTexts[1]}"
174
+ )
175
  return chosenCategoryTexts[0], images[0], chosenCategoryTexts[1], images[1]
176
 
177