felix.wf commited on
Commit
9db8a5d
·
1 Parent(s): 1ef319c

add actions pie fig

Browse files
Files changed (1) hide show
  1. app.py +25 -16
app.py CHANGED
@@ -90,29 +90,39 @@ if file_name is not None:
90
 
91
 
92
  # 统计各种标签的数量
93
- label_counts = {}
 
94
  for item in output_list_emotions:
95
  label = item['label']
96
- if label in label_counts:
97
- label_counts[label] += 1
98
  else:
99
- label_counts[label] = 1
 
100
  for item in output_list_emotions_refined:
101
  label = item['label']
102
- if label in label_counts:
103
- label_counts[label] += 1
104
  else:
105
- label_counts[label] = 1
106
 
107
  # 绘制饼状图
108
- labels = list(label_counts.keys())
109
- sizes = list(label_counts.values())
110
 
111
- pie_fig, pie_ax = plt.subplots()
112
- pie_ax.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=140)
113
- pie_ax.set_title('Distribution of Emotions')
114
- pie_ax.axis('equal') # 确保饼状图为圆形
115
 
 
 
 
 
 
 
 
 
116
 
117
  labels_refined = [item['label'] for item in output_list_emotions_refined]
118
  label_counts_refined = {label: labels_refined.count(label) for label in set(labels_refined)}
@@ -137,10 +147,9 @@ if file_name is not None:
137
 
138
  st.pyplot(fig) # Display the stitched person images
139
 
140
- st.pyplot(pie_fig) # Display the pie chart
141
-
142
  st.pyplot(bar_fig) # Display the bar chart
143
-
144
  st.pyplot(bar_fig_emotions) # Display the bar chart
145
 
146
  elif file_name.type.startswith('video'):
 
90
 
91
 
92
  # 统计各种标签的数量
93
+ label_counts_emotions = {}
94
+ label_counts_actions = {}
95
  for item in output_list_emotions:
96
  label = item['label']
97
+ if label in label_counts_emotions:
98
+ label_counts_emotions[label] += 1
99
  else:
100
+ label_counts_emotions[label] = 1
101
+
102
  for item in output_list_emotions_refined:
103
  label = item['label']
104
+ if label in label_counts_actions:
105
+ label_counts_actions[label] += 1
106
  else:
107
+ label_counts_actions[label] = 1
108
 
109
  # 绘制饼状图
110
+ labels_emotions = list(label_counts_emotions.keys())
111
+ sizes_emotions = list(label_counts_emotions.values())
112
 
113
+ pie_fig_emotions, pie_ax_emotions = plt.subplots()
114
+ pie_ax_emotions.pie(sizes_emotions, labels=labels_emotions, autopct='%1.1f%%', startangle=140)
115
+ pie_ax_emotions.set_title('Distribution of Emotions')
116
+ pie_ax_emotions.axis('equal') # 确保饼状图为圆形
117
 
118
+ labels_actions = list(label_counts_actions.keys())
119
+ sizes_actions = list(label_counts_actions.values())
120
+
121
+ pie_fig_actions, pie_ax_actions = plt.subplots()
122
+ pie_ax_actions.pie(sizes_actions, labels=labels_actions, autopct='%1.1f%%', startangle=140)
123
+ pie_ax_actions.set_title('Distribution of Actions')
124
+ pie_ax_actions.axis('equal') # 确保饼状图为圆形
125
+
126
 
127
  labels_refined = [item['label'] for item in output_list_emotions_refined]
128
  label_counts_refined = {label: labels_refined.count(label) for label in set(labels_refined)}
 
147
 
148
  st.pyplot(fig) # Display the stitched person images
149
 
150
+ st.pyplot(pie_fig_emotions) # Display the pie chart
151
+ st.pyplot(pie_fig_actions) # Display the pie chart
152
  st.pyplot(bar_fig) # Display the bar chart
 
153
  st.pyplot(bar_fig_emotions) # Display the bar chart
154
 
155
  elif file_name.type.startswith('video'):