reab5555 commited on
Commit
5972d43
·
verified ·
1 Parent(s): e0599e6

Update visualization.py

Browse files
Files changed (1) hide show
  1. visualization.py +11 -8
visualization.py CHANGED
@@ -264,14 +264,17 @@ def create_video_with_heatmap(video_path, df, mse_embeddings, mse_posture, mse_v
264
  width, height = video.w, video.h
265
  total_frames = int(video.duration * video.fps)
266
 
267
- # Ensure all MSE arrays have the same length as total_frames
268
- mse_embeddings = np.interp(np.linspace(0, len(mse_embeddings) - 1, total_frames),
269
- np.arange(len(mse_embeddings)), mse_embeddings)
270
- mse_posture = np.interp(np.linspace(0, len(mse_posture) - 1, total_frames),
271
- np.arange(len(mse_posture)), mse_posture)
272
- mse_voice = np.interp(np.linspace(0, len(mse_voice) - 1, total_frames),
273
- np.arange(len(mse_voice)), mse_voice)
274
-
 
 
 
275
  def combine_video_and_heatmap(t):
276
  video_frame = video.get_frame(t)
277
  heatmap_frame = create_heatmap(t, mse_embeddings, mse_posture, mse_voice, video.fps, total_frames, width)
 
264
  width, height = video.w, video.h
265
  total_frames = int(video.duration * video.fps)
266
 
267
+ # Fill missing MSE values with 0
268
+ def pad_with_zeros(mse_array, total_frames):
269
+ if len(mse_array) < total_frames:
270
+ return np.pad(mse_array, (0, total_frames - len(mse_array)), 'constant', constant_values=0)
271
+ else:
272
+ return mse_array[:total_frames]
273
+
274
+ mse_embeddings = pad_with_zeros(mse_embeddings, total_frames)
275
+ mse_posture = pad_with_zeros(mse_posture, total_frames)
276
+ mse_voice = pad_with_zeros(mse_voice, total_frames)
277
+
278
  def combine_video_and_heatmap(t):
279
  video_frame = video.get_frame(t)
280
  heatmap_frame = create_heatmap(t, mse_embeddings, mse_posture, mse_voice, video.fps, total_frames, width)