xtlyxt commited on
Commit
9e9c3e5
·
verified ·
1 Parent(s): ee48256

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -86,31 +86,31 @@ if st.button("Predict Emotions") and selected_images:
86
  # Add more emotions and their corresponding colors here
87
  }
88
 
89
- #https://link.springer.com/article/10.3758/s13428-015-0598-8#:~:text=The%20color%20red%20was%20most%20associated%20with%20anger%2C%20green%20with,%E2%80%9D%20or%20%E2%80%9Cfeeling%20blue.%E2%80%9D
 
90
 
91
- #The color red was most associated with anger, green with disgust, black with fear, yellow with happiness, blue with sadness,
92
- #and bright with surprise. These associations may be a result of various expressions containing color terms that are used in the
93
- #English language—for example, “seeing red” or “feeling blue.”May 19, 2015
94
-
95
  # Use the color map to assign colors to the pie chart
96
  pie_colors = [color_map.get(emotion, '#999999') for emotion in emotion_counts.index] # Default to grey if not found
97
 
98
- # Plot pie chart
99
  st.write("Emotion Distribution (Pie Chart):")
100
  fig_pie, ax_pie = plt.subplots()
101
  ax_pie.pie(emotion_counts, labels=emotion_counts.index, autopct='%1.1f%%', startangle=140, colors=pie_colors)
102
  ax_pie.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
 
 
103
  st.pyplot(fig_pie)
104
 
105
  # Use the same color map for the bar chart
106
  bar_colors = [color_map.get(emotion, '#999999') for emotion in emotion_counts.index] # Default to grey if not found
107
 
108
- # Plot bar chart
109
  st.write("Emotion Distribution (Bar Chart):")
110
  fig_bar, ax_bar = plt.subplots()
111
  emotion_counts.plot(kind='bar', color=bar_colors, ax=ax_bar)
112
  ax_bar.set_xlabel('Emotion')
113
  ax_bar.set_ylabel('Count')
114
- ax_bar.set_title('Emotion Distribution')
 
115
  ax_bar.yaxis.set_major_locator(plt.MaxNLocator(integer=True)) # Ensure integer ticks on Y-axis
116
  st.pyplot(fig_bar)
 
86
  # Add more emotions and their corresponding colors here
87
  }
88
 
89
+ # Calculate the total number of faces analyzed
90
+ total_faces = len(selected_images)
91
 
 
 
 
 
92
  # Use the color map to assign colors to the pie chart
93
  pie_colors = [color_map.get(emotion, '#999999') for emotion in emotion_counts.index] # Default to grey if not found
94
 
95
+ # Plot pie chart with total faces in the title
96
  st.write("Emotion Distribution (Pie Chart):")
97
  fig_pie, ax_pie = plt.subplots()
98
  ax_pie.pie(emotion_counts, labels=emotion_counts.index, autopct='%1.1f%%', startangle=140, colors=pie_colors)
99
  ax_pie.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
100
+ # Add total faces to the title
101
+ ax_pie.set_title(f"Total Faces Analyzed: {total_faces}")
102
  st.pyplot(fig_pie)
103
 
104
  # Use the same color map for the bar chart
105
  bar_colors = [color_map.get(emotion, '#999999') for emotion in emotion_counts.index] # Default to grey if not found
106
 
107
+ # Plot bar chart with total faces in the title
108
  st.write("Emotion Distribution (Bar Chart):")
109
  fig_bar, ax_bar = plt.subplots()
110
  emotion_counts.plot(kind='bar', color=bar_colors, ax=ax_bar)
111
  ax_bar.set_xlabel('Emotion')
112
  ax_bar.set_ylabel('Count')
113
+ # Add total faces to the title
114
+ ax_bar.set_title(f"Emotion Distribution - Total Faces Analyzed: {total_faces}")
115
  ax_bar.yaxis.set_major_locator(plt.MaxNLocator(integer=True)) # Ensure integer ticks on Y-axis
116
  st.pyplot(fig_bar)