Mario Faundez commited on
Commit
7b02514
·
1 Parent(s): b74aea4

chore: better description texts in app gradio

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -5,14 +5,14 @@ import tensorflow_hub as hub
5
  import tensorflow_text as text
6
  import numpy as np
7
  np.set_printoptions(suppress=True)
8
- # https://www.kaggle.com/datasets/mrmorj/hate-speech-and-offensive-language-dataset
9
  labels = [
10
  "hate speech",
11
  "offensive language",
12
  "neither"
13
  ]
14
 
15
- # model
16
  with tf.keras.utils.custom_object_scope({'AdamWeightDecay': AdamWeightDecay(), 'WarmUp': WarmUp}):
17
  classifier_model = tf.keras.models.load_model('classifier_model.h5',
18
  custom_objects={'KerasLayer': hub.KerasLayer})
@@ -28,13 +28,17 @@ examples = [
28
  ["This is wonderful!"],
29
  ]
30
 
 
 
31
  hate_speech = gr.Interface(
32
  fn=run_model,
33
  inputs=gr.Textbox(lines=5,
34
- placeholder="Enter a positive or negative sentence here...",
35
  label="Input Text"),
36
  outputs=gr.outputs.Label(),
37
- examples=examples
 
 
38
  )
39
 
40
  hate_speech.launch()
 
5
  import tensorflow_text as text
6
  import numpy as np
7
  np.set_printoptions(suppress=True)
8
+
9
  labels = [
10
  "hate speech",
11
  "offensive language",
12
  "neither"
13
  ]
14
 
15
+
16
  with tf.keras.utils.custom_object_scope({'AdamWeightDecay': AdamWeightDecay(), 'WarmUp': WarmUp}):
17
  classifier_model = tf.keras.models.load_model('classifier_model.h5',
18
  custom_objects={'KerasLayer': hub.KerasLayer})
 
28
  ["This is wonderful!"],
29
  ]
30
 
31
+ short_description = "This application classifies text into three categories: hate speech, offensive language, and neither, using a deep learning model trained on the Hate Speech and Offensive Language Dataset. Enter a sentence and the model will predict its category."
32
+
33
  hate_speech = gr.Interface(
34
  fn=run_model,
35
  inputs=gr.Textbox(lines=5,
36
+ placeholder="Enter a sentence here...",
37
  label="Input Text"),
38
  outputs=gr.outputs.Label(),
39
+ examples=examples,
40
+ title="Hate Speech and Offensive Language Classifier",
41
+ description=short_description
42
  )
43
 
44
  hate_speech.launch()