Update app.py
Browse files
app.py
CHANGED
@@ -33,11 +33,14 @@ def predict_toxicity(comment):
|
|
33 |
|
34 |
return {labels[i]: float(probabilities[i]) for i in range(len(labels))}
|
35 |
|
|
|
|
|
36 |
def format_toxicity_data(comment):
|
37 |
"""Formats the toxicity scores for a modern bar graph."""
|
38 |
scores = predict_toxicity(comment)
|
39 |
-
|
40 |
-
return
|
|
|
41 |
|
42 |
# Gradio interface
|
43 |
demo = gr.Interface(
|
|
|
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(
|