felix.wf commited on
Commit
d2feb05
·
1 Parent(s): 2c8cdb7

add new model

Browse files
Files changed (1) hide show
  1. app.py +19 -8
app.py CHANGED
@@ -10,7 +10,7 @@ import numpy as np
10
 
11
  pipe_yolos = pipeline("object-detection", model="hustvl/yolos-tiny")
12
  pipe_emotions = pipeline("image-classification", model="dima806/facial_emotions_image_detection")
13
-
14
 
15
 
16
  st.title("Online Teaching Effect Monitor")
@@ -69,33 +69,44 @@ if file_name is not None:
69
  ax.axis('off')
70
 
71
  # 识别每个人的表情
72
- output_list = []
 
73
 
74
  for idx, face in enumerate(persons_image_list):
75
  print(f"processing {idx}")
76
  output = pipe_emotions(face)
77
- output_list.append(output[0])
 
 
78
 
79
- print(output_list)
80
- st.text(output_list)
 
 
81
 
82
 
83
  # 统计各种标签的数量
84
  label_counts = {}
85
- for item in output_list:
86
  label = item['label']
87
  if label in label_counts:
88
  label_counts[label] += 1
89
  else:
90
  label_counts[label] = 1
91
-
 
 
 
 
 
 
92
  # 绘制饼状图
93
  labels = list(label_counts.keys())
94
  sizes = list(label_counts.values())
95
 
96
  pie_fig, ax = plt.subplots()
97
  ax.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=140)
98
- ax.set_title('Distribution of Labels')
99
  ax.axis('equal') # 确保饼状图为圆形
100
  # plt.show()
101
  # Use Streamlit columns to display the images and pie chart side by side
 
10
 
11
  pipe_yolos = pipeline("object-detection", model="hustvl/yolos-tiny")
12
  pipe_emotions = pipeline("image-classification", model="dima806/facial_emotions_image_detection")
13
+ pipe_emotions_refined = pipeline("image-classification", model="felixwf/fine_tuned_face_emotion_model")
14
 
15
 
16
  st.title("Online Teaching Effect Monitor")
 
69
  ax.axis('off')
70
 
71
  # 识别每个人的表情
72
+ output_list_emotions = []
73
+ output_list_emotions_refined = []
74
 
75
  for idx, face in enumerate(persons_image_list):
76
  print(f"processing {idx}")
77
  output = pipe_emotions(face)
78
+ output_list_emotions.append(output[0])
79
+ output = pipe_emotions_refined(face)
80
+ output_list_emotions_refined.append(output[0])
81
 
82
+ print(output_list_emotions)
83
+ st.text(output_list_emotions)
84
+ print(output_list_emotions_refined)
85
+ st.text(output_list_emotions_refined)
86
 
87
 
88
  # 统计各种标签的数量
89
  label_counts = {}
90
+ for item in output_list_emotions:
91
  label = item['label']
92
  if label in label_counts:
93
  label_counts[label] += 1
94
  else:
95
  label_counts[label] = 1
96
+ for item in output_list_emotions_refined:
97
+ label = item['label']
98
+ if label in label_counts:
99
+ label_counts[label] += 1
100
+ else:
101
+ label_counts[label] = 1
102
+
103
  # 绘制饼状图
104
  labels = list(label_counts.keys())
105
  sizes = list(label_counts.values())
106
 
107
  pie_fig, ax = plt.subplots()
108
  ax.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=140)
109
+ ax.set_title('Distribution of Emotions')
110
  ax.axis('equal') # 确保饼状图为圆形
111
  # plt.show()
112
  # Use Streamlit columns to display the images and pie chart side by side