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

Modified app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
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.List(label="PROFANITIES")],
150
 
151
  examples=['Tangina mo naman sobrang yabang mo gago!!😠😀 @davidrafael',
152
  'Napakainit ngayong araw pakshet namaaan!!',
@@ -159,5 +159,4 @@ demo = gr.Interface(
159
  title="Tagalog Profanity Classifier"
160
  )
161
 
162
- demo.launch(debug=True)
163
- predict("Tangina mo naman gag0 ka ba")
 
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.JSON(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)