gilramos commited on
Commit
69eadf1
1 Parent(s): 366759b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -33,10 +33,19 @@ def predict(text, chosen_model):
33
  # Initialize the pipeline with the chosen model
34
  model_pipeline = pipeline("text-classification", model=chosen_model)
35
  result = model_pipeline(text)
36
- label = result[0]['label']
37
- score = result[0]['score']
38
 
39
- return label#, score
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  inputs = [
42
  gr.Textbox(label="Text", value= app_examples[0][0]),
@@ -45,7 +54,6 @@ inputs = [
45
 
46
  outputs = [
47
  gr.Label(label="Result"),
48
- #gr.Markdown()
49
  ]
50
 
51
 
 
33
  # Initialize the pipeline with the chosen model
34
  model_pipeline = pipeline("text-classification", model=chosen_model)
35
  result = model_pipeline(text)
 
 
36
 
37
+ predicted_label = result[0]['label']
38
+ predicted_score = result[0]['score']
39
+
40
+ non_predicted_label = "Hate Speech" if predicted_label == "Non Hate Speech" else "Non Hate Speech"
41
+ non_predicted_score = 1 - predicted_score
42
+
43
+ scores_dict = {
44
+ predicted_label: predicted_score,
45
+ non_predicted_label: non_predicted_score
46
+ }
47
+
48
+ return scores_dict#, predicted_label
49
 
50
  inputs = [
51
  gr.Textbox(label="Text", value= app_examples[0][0]),
 
54
 
55
  outputs = [
56
  gr.Label(label="Result"),
 
57
  ]
58
 
59