HyperX-Sentience commited on
Commit
236e362
·
verified ·
1 Parent(s): 4f398a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -6,6 +6,7 @@ import torch
6
  import gradio as gr
7
  import numpy as np
8
  import matplotlib.pyplot as plt
 
9
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
10
 
11
  torch.set_num_threads(torch.get_num_threads())
@@ -33,20 +34,18 @@ def predict_toxicity(comment):
33
 
34
  return {labels[i]: float(probabilities[i]) for i in range(len(labels))}
35
 
36
- import pandas as pd
37
-
38
  def format_toxicity_data(comment):
39
  """Formats the toxicity scores for a modern bar graph."""
40
  scores = predict_toxicity(comment)
41
- df = pd.DataFrame(list(scores.items()), columns=["Category", "Score"])
42
  return df
43
 
44
-
45
  # Gradio interface
46
  demo = gr.Interface(
47
  fn=format_toxicity_data,
48
  inputs=gr.Textbox(label="Enter a comment:"),
49
  outputs=gr.BarPlot(
 
50
  x="Category",
51
  y="Score",
52
  title="Toxicity Analysis",
 
6
  import gradio as gr
7
  import numpy as np
8
  import matplotlib.pyplot as plt
9
+ import pandas as pd
10
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
11
 
12
  torch.set_num_threads(torch.get_num_threads())
 
34
 
35
  return {labels[i]: float(probabilities[i]) for i in range(len(labels))}
36
 
 
 
37
  def format_toxicity_data(comment):
38
  """Formats the toxicity scores for a modern bar graph."""
39
  scores = predict_toxicity(comment)
40
+ df = pd.DataFrame({"Category": list(scores.keys()), "Score": list(scores.values())})
41
  return df
42
 
 
43
  # Gradio interface
44
  demo = gr.Interface(
45
  fn=format_toxicity_data,
46
  inputs=gr.Textbox(label="Enter a comment:"),
47
  outputs=gr.BarPlot(
48
+ value=None,
49
  x="Category",
50
  y="Score",
51
  title="Toxicity Analysis",