Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,25 +41,21 @@ 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=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.
|
| 57 |
|
| 58 |
-
|
| 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 |
|
|
@@ -76,4 +72,4 @@ demo = gr.Interface(
|
|
| 76 |
|
| 77 |
# Launch the Gradio app
|
| 78 |
if __name__ == "__main__":
|
| 79 |
-
demo.launch()
|
|
|
|
| 41 |
categories = list(toxicity_scores.keys())
|
| 42 |
scores = list(toxicity_scores.values())
|
| 43 |
|
| 44 |
+
plt.figure(figsize=(12, 7), dpi=300, facecolor='black')
|
| 45 |
ax = plt.gca()
|
| 46 |
ax.set_facecolor('black')
|
| 47 |
+
bars = plt.bar(categories, scores, color='#20B2AA', edgecolor='white', width=0.5) # Sea green
|
| 48 |
|
| 49 |
+
plt.xticks(color='white', fontsize=14, rotation=25, ha='right')
|
| 50 |
plt.yticks(color='white', fontsize=14)
|
| 51 |
plt.title("Toxicity Score Analysis", color='white', fontsize=16)
|
| 52 |
+
plt.ylim(0, 1.1)
|
| 53 |
|
| 54 |
for bar in bars:
|
| 55 |
yval = bar.get_height()
|
| 56 |
+
plt.text(bar.get_x() + bar.get_width()/2, yval + 0.03, f'{yval:.2f}', ha='center', color='white', fontsize=12, fontweight='bold')
|
| 57 |
|
| 58 |
+
plt.tight_layout(pad=2)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
plt.savefig("toxicity_chart.png", facecolor='black', bbox_inches='tight')
|
| 60 |
plt.close()
|
| 61 |
|
|
|
|
| 72 |
|
| 73 |
# Launch the Gradio app
|
| 74 |
if __name__ == "__main__":
|
| 75 |
+
demo.launch()
|