Update visualization.py
Browse files- visualization.py +6 -9
visualization.py
CHANGED
@@ -222,7 +222,7 @@ def create_video_with_heatmap(video_path, df, mse_embeddings, mse_posture, outpu
|
|
222 |
|
223 |
# Create custom colormap
|
224 |
cmap = mcolors.LinearSegmentedColormap.from_list("custom",
|
225 |
-
[(
|
226 |
|
227 |
# Ensure heatmap data covers all frames
|
228 |
mse_embeddings = np.interp(np.linspace(0, len(mse_embeddings) - 1, total_frames),
|
@@ -235,22 +235,19 @@ def create_video_with_heatmap(video_path, df, mse_embeddings, mse_posture, outpu
|
|
235 |
mse_posture_norm = (mse_posture - np.min(mse_posture)) / (np.max(mse_posture) - np.min(mse_posture))
|
236 |
|
237 |
# Combine MSEs
|
238 |
-
combined_mse = np.zeros((2, total_frames))
|
239 |
-
combined_mse[0] = mse_embeddings_norm
|
240 |
-
combined_mse[1] = mse_posture_norm
|
241 |
|
242 |
fig, ax = plt.subplots(figsize=(width/100, 2))
|
243 |
-
im = ax.imshow(combined_mse, aspect='auto',
|
244 |
ax.set_yticks([0.5, 1.5])
|
245 |
ax.set_yticklabels(['Facial', 'Posture'])
|
246 |
ax.set_xticks([])
|
247 |
-
cbar = plt.colorbar(im, ax=ax, orientation='horizontal', pad=0.1, aspect=20, shrink=0.5)
|
248 |
-
cbar.set_ticks([0, 0.5, 1])
|
249 |
-
cbar.set_ticklabels(['Low MSE', 'Medium MSE', 'High MSE'])
|
250 |
plt.tight_layout()
|
251 |
|
252 |
line = None
|
253 |
-
frame_interval =
|
254 |
|
255 |
for frame_count in range(0, total_frames, frame_interval):
|
256 |
cap.set(cv2.CAP_PROP_POS_FRAMES, frame_count)
|
|
|
222 |
|
223 |
# Create custom colormap
|
224 |
cmap = mcolors.LinearSegmentedColormap.from_list("custom",
|
225 |
+
[(1, 1, 1), (0, 0, 1), (0.5, 0, 0.5)], N=256)
|
226 |
|
227 |
# Ensure heatmap data covers all frames
|
228 |
mse_embeddings = np.interp(np.linspace(0, len(mse_embeddings) - 1, total_frames),
|
|
|
235 |
mse_posture_norm = (mse_posture - np.min(mse_posture)) / (np.max(mse_posture) - np.min(mse_posture))
|
236 |
|
237 |
# Combine MSEs
|
238 |
+
combined_mse = np.zeros((2, total_frames, 3))
|
239 |
+
combined_mse[0] = np.array([1 - mse_embeddings_norm, 1 - mse_embeddings_norm, mse_embeddings_norm]).T # RGB for facial
|
240 |
+
combined_mse[1] = np.array([1 - mse_posture_norm, mse_posture_norm, 1 - mse_posture_norm]).T # RGB for posture
|
241 |
|
242 |
fig, ax = plt.subplots(figsize=(width/100, 2))
|
243 |
+
im = ax.imshow(combined_mse, aspect='auto', extent=[0, total_frames, 0, 2])
|
244 |
ax.set_yticks([0.5, 1.5])
|
245 |
ax.set_yticklabels(['Facial', 'Posture'])
|
246 |
ax.set_xticks([])
|
|
|
|
|
|
|
247 |
plt.tight_layout()
|
248 |
|
249 |
line = None
|
250 |
+
frame_interval = int(original_fps / desired_fps)
|
251 |
|
252 |
for frame_count in range(0, total_frames, frame_interval):
|
253 |
cap.set(cv2.CAP_PROP_POS_FRAMES, frame_count)
|