Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -45,21 +45,21 @@ if uploaded_image:
|
|
45 |
'Surprise': '#FFA500',
|
46 |
'Fear': '#000000'
|
47 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
-
#
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
# ax_bar.set_xlabel('Emotion')
|
60 |
-
# ax_bar.set_ylabel('Count')
|
61 |
-
# ax_bar.set_title("Emotion Count")
|
62 |
-
# ax_bar.yaxis.set_major_locator(plt.MaxNLocator(integer=True))
|
63 |
-
# for i in ax_bar.patches:
|
64 |
-
# ax_bar.text(i.get_x() + i.get_width() / 2, i.get_height() + 0.1, str(int(i.get_height())), ha='center', va='bottom')
|
65 |
-
# st.pyplot(fig_bar)
|
|
|
45 |
'Surprise': '#FFA500',
|
46 |
'Fear': '#000000'
|
47 |
}
|
48 |
+
pie_colors = [color_map.get(emotion, '#999999') for emotion in emotion_counts.index]
|
49 |
+
# Pie chart visualization
|
50 |
+
fig_pie, ax_pie = plt.subplots(figsize=(4, 4))
|
51 |
+
ax_pie.pie(emotion_counts, labels=emotion_counts.index, autopct='%1.1f%%', startangle=140, colors=pie_colors)
|
52 |
+
ax_pie.axis('equal')
|
53 |
+
ax_pie.set_title("Emotion Distribution")
|
54 |
+
st.pyplot(fig_pie)
|
55 |
|
56 |
+
# Bar chart visualization
|
57 |
+
fig_bar, ax_bar = plt.subplots(figsize=(4, 4))
|
58 |
+
emotion_counts.plot(kind='bar', color=pie_colors, ax=ax_bar)
|
59 |
+
ax_bar.set_xlabel('Emotion')
|
60 |
+
ax_bar.set_ylabel('Count')
|
61 |
+
ax_bar.set_title("Emotion Count")
|
62 |
+
ax_bar.yaxis.set_major_locator(plt.MaxNLocator(integer=True))
|
63 |
+
for i in ax_bar.patches:
|
64 |
+
ax_bar.text(i.get_x() + i.get_width() / 2, i.get_height() + 0.1, str(int(i.get_height())), ha='center', va='bottom')
|
65 |
+
st.pyplot(fig_bar)
|
|
|
|
|
|
|
|
|
|
|
|
|
|