Update visualization.py
Browse files- visualization.py +9 -6
visualization.py
CHANGED
@@ -264,13 +264,16 @@ 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 =
|
269 |
-
|
270 |
-
|
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)
|
|
|
264 |
width, height = video.w, video.h
|
265 |
total_frames = int(video.duration * video.fps)
|
266 |
|
267 |
+
def fill_with_zeros_and_values(mse_array, total_frames):
|
268 |
+
result = np.zeros(total_frames)
|
269 |
+
indices = np.linspace(0, total_frames - 1, len(mse_array)).astype(int)
|
270 |
+
result[indices] = mse_array
|
271 |
+
return result
|
272 |
+
|
273 |
# Ensure all MSE arrays have the same length as total_frames
|
274 |
+
mse_embeddings = fill_with_zeros_and_values(mse_embeddings, total_frames)
|
275 |
+
mse_posture = fill_with_zeros_and_values(mse_posture, total_frames)
|
276 |
+
mse_voice = fill_with_zeros_and_values(mse_voice, total_frames)
|
|
|
|
|
|
|
277 |
|
278 |
def combine_video_and_heatmap(t):
|
279 |
video_frame = video.get_frame(t)
|