reab5555 commited on
Commit
d76a2e5
·
verified ·
1 Parent(s): 96ad5cb

Update visualization.py

Browse files
Files changed (1) hide show
  1. visualization.py +27 -0
visualization.py CHANGED
@@ -127,6 +127,33 @@ def plot_mse(df, mse_values, title, color='navy', time_threshold=3, anomaly_thre
127
  plt.close()
128
  return fig, anomaly_frames
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  def plot_mse_histogram(mse_values, title, anomaly_threshold, color='blue'):
131
  plt.figure(figsize=(16, 3), dpi=300)
132
  fig, ax = plt.subplots(figsize=(16, 3))
 
127
  plt.close()
128
  return fig, anomaly_frames
129
 
130
+ def plot_combined_mse(df, mse_embeddings, mse_posture, mse_voice, title):
131
+ plt.figure(figsize=(16, 8), dpi=300)
132
+ fig, ax = plt.subplots(figsize=(16, 8))
133
+
134
+ if 'Seconds' not in df.columns:
135
+ df['Seconds'] = df['Timecode'].apply(
136
+ lambda x: sum(float(t) * 60 ** i for i, t in enumerate(reversed(x.split(':')))))
137
+
138
+ # Normalize MSE values to the same scale
139
+ mse_embeddings = (mse_embeddings - np.min(mse_embeddings)) / (np.max(mse_embeddings) - np.min(mse_embeddings))
140
+ mse_posture = (mse_posture - np.min(mse_posture)) / (np.max(mse_posture) - np.min(mse_posture))
141
+ mse_voice = (mse_voice - np.min(mse_voice)) / (np.max(mse_voice) - np.min(mse_voice))
142
+
143
+ ax.plot(df['Seconds'], mse_embeddings, color='navy', label='Facial Features')
144
+ ax.plot(df['Seconds'], mse_posture, color='purple', label='Body Posture')
145
+ ax.plot(df['Seconds'], mse_voice, color='green', label='Voice')
146
+
147
+ ax.set_xlabel('Timecode')
148
+ ax.set_ylabel('Normalized Mean Squared Error')
149
+ ax.set_title(title)
150
+
151
+ ax.grid(True, linestyle='--', alpha=0.7)
152
+ ax.legend()
153
+ plt.tight_layout()
154
+ plt.close()
155
+ return fig
156
+
157
  def plot_mse_histogram(mse_values, title, anomaly_threshold, color='blue'):
158
  plt.figure(figsize=(16, 3), dpi=300)
159
  fig, ax = plt.subplots(figsize=(16, 3))