Update visualization.py
Browse files- 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 |
-
#
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
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)
|