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

modified app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -128,17 +128,16 @@ 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
 
135
  print("\nTWEET:", 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 +145,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.List(label="PROFANITIES")],
150
 
151
  examples=['Tangina mo naman sobrang yabang mo gago!!😠😀 @davidrafael',
152
  'Napakainit ngayong araw pakshet namaaan!!',
@@ -159,4 +158,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
  prediction = prediction[0][0]["label"]
133
 
134
  print("\nTWEET:", tweet)
135
  print("DETECTED PROFANITY:", matched_profanity)
136
  print("LABEL:", prediction, "\n")
137
 
138
+ return prediction, matched_profanity
139
 
140
+ return "No Profanity", {}
141
 
142
 
143
  demo = gr.Interface(
 
145
 
146
  inputs=[gr.components.Textbox(lines=5, placeholder='Enter your input here', label='INPUT')],
147
 
148
+ outputs=[gr.components.Text(label="PREDICTION"), gr.JSON(label="PROFANITIES")],
149
 
150
  examples=['Tangina mo naman sobrang yabang mo gago!!😠😀 @davidrafael',
151
  'Napakainit ngayong araw pakshet namaaan!!',
 
158
  title="Tagalog Profanity Classifier"
159
  )
160
 
161
+ demo.launch(debug=True)