Update app.py
Browse files
app.py
CHANGED
@@ -41,22 +41,26 @@ def plot_toxicity(comment):
|
|
41 |
categories = list(toxicity_scores.keys())
|
42 |
scores = list(toxicity_scores.values())
|
43 |
|
44 |
-
plt.figure(figsize=(
|
45 |
ax = plt.gca()
|
46 |
ax.set_facecolor('black')
|
47 |
bars = plt.bar(categories, scores, color='#20B2AA', edgecolor='white') # Sea green
|
48 |
|
49 |
-
plt.xticks(color='white', fontsize=
|
50 |
-
plt.yticks(color='white', fontsize=
|
51 |
-
plt.title("Toxicity Score Analysis", color='white', fontsize=
|
52 |
plt.ylim(0, 1)
|
53 |
|
54 |
for bar in bars:
|
55 |
yval = bar.get_height()
|
56 |
-
plt.text(bar.get_x() + bar.get_width()/2, yval + 0.02, f'{yval:.2f}', ha='center', color='white', fontsize=
|
|
|
|
|
|
|
|
|
57 |
|
58 |
plt.tight_layout()
|
59 |
-
plt.savefig("toxicity_chart.png", facecolor='black')
|
60 |
plt.close()
|
61 |
|
62 |
return "toxicity_chart.png"
|
@@ -72,4 +76,4 @@ demo = gr.Interface(
|
|
72 |
|
73 |
# Launch the Gradio app
|
74 |
if __name__ == "__main__":
|
75 |
-
demo.launch()
|
|
|
41 |
categories = list(toxicity_scores.keys())
|
42 |
scores = list(toxicity_scores.values())
|
43 |
|
44 |
+
plt.figure(figsize=(10, 6), dpi=200, facecolor='black')
|
45 |
ax = plt.gca()
|
46 |
ax.set_facecolor('black')
|
47 |
bars = plt.bar(categories, scores, color='#20B2AA', edgecolor='white') # Sea green
|
48 |
|
49 |
+
plt.xticks(color='white', fontsize=14)
|
50 |
+
plt.yticks(color='white', fontsize=14)
|
51 |
+
plt.title("Toxicity Score Analysis", color='white', fontsize=16)
|
52 |
plt.ylim(0, 1)
|
53 |
|
54 |
for bar in bars:
|
55 |
yval = bar.get_height()
|
56 |
+
plt.text(bar.get_x() + bar.get_width()/2, yval + 0.02, f'{yval:.2f}', ha='center', color='white', fontsize=12)
|
57 |
+
|
58 |
+
# Add a curly bracket to group subcategories under "toxic"
|
59 |
+
plt.plot([-0.3, -0.3, 5.3, 5.3], [-0.05, 0.85, 0.85, -0.05], color='white', linewidth=2)
|
60 |
+
plt.text(-0.5, 0.9, "Toxic Subcategories", color='white', fontsize=14, rotation=90, verticalalignment='center')
|
61 |
|
62 |
plt.tight_layout()
|
63 |
+
plt.savefig("toxicity_chart.png", facecolor='black', bbox_inches='tight')
|
64 |
plt.close()
|
65 |
|
66 |
return "toxicity_chart.png"
|
|
|
76 |
|
77 |
# Launch the Gradio app
|
78 |
if __name__ == "__main__":
|
79 |
+
demo.launch()
|