mginoben commited on
Commit
74731c1
β€’
1 Parent(s): b5dd2c8

modified app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -128,7 +128,7 @@ def predict(tweet):
128
  if type(prediction) == dict:
129
  print(prediction)
130
  error_message = prediction['error']
131
- return error_message, []
132
 
133
  prediction = prediction[0][0]["label"]
134
 
@@ -136,9 +136,9 @@ def predict(tweet):
136
  print("DETECTED PROFANITY:", matched_profanity)
137
  print("LABEL:", prediction, "\n")
138
 
139
- return prediction, matched_profanity
140
 
141
- return "No Profanity", []
142
 
143
 
144
  demo = gr.Interface(
@@ -146,7 +146,7 @@ demo = gr.Interface(
146
 
147
  inputs=[gr.components.Textbox(lines=5, placeholder='Enter your input here', label='INPUT')],
148
 
149
- outputs=[gr.components.Text(label="PREDICTION"), gr.JSON(label="PROFANITIES")],
150
 
151
  examples=['Tangina mo naman sobrang yabang mo gago!!😠😀 @davidrafael',
152
  'Napakainit ngayong araw pakshet namaaan!!',
@@ -159,4 +159,4 @@ demo = gr.Interface(
159
  title="Tagalog Profanity Classifier"
160
  )
161
 
162
- demo.launch(debug=True)
 
128
  if type(prediction) == dict:
129
  print(prediction)
130
  error_message = prediction['error']
131
+ return error_message, [[]]
132
 
133
  prediction = prediction[0][0]["label"]
134
 
 
136
  print("DETECTED PROFANITY:", matched_profanity)
137
  print("LABEL:", prediction, "\n")
138
 
139
+ return prediction, [matched_profanity]
140
 
141
+ return "No Profanity", [[]]
142
 
143
 
144
  demo = gr.Interface(
 
146
 
147
  inputs=[gr.components.Textbox(lines=5, placeholder='Enter your input here', label='INPUT')],
148
 
149
+ outputs=[gr.components.Text(label="PREDICTION"), gr.List(label="PROFANITIES")],
150
 
151
  examples=['Tangina mo naman sobrang yabang mo gago!!😠😀 @davidrafael',
152
  'Napakainit ngayong araw pakshet namaaan!!',
 
159
  title="Tagalog Profanity Classifier"
160
  )
161
 
162
+ demo.launch(debug=True)