Spaces:
Runtime error
Runtime error
Update visualization.py
Browse files- visualization.py +19 -8
visualization.py
CHANGED
|
@@ -298,13 +298,24 @@ def create_video_with_heatmap(video_path, df, mse_embeddings, mse_posture, mse_v
|
|
| 298 |
cv2.putText(combined_frame, f"Time: {timecode}", (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
|
| 299 |
|
| 300 |
out.write(combined_frame)
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
|
|
|
|
|
|
| 304 |
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
|
| 309 |
-
|
| 310 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
cv2.putText(combined_frame, f"Time: {timecode}", (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)
|
| 299 |
|
| 300 |
out.write(combined_frame)
|
| 301 |
+
if progress is not None:
|
| 302 |
+
try:
|
| 303 |
+
progress((frame_count + 1) / total_frames, desc="Generating video with heatmap")
|
| 304 |
+
except Exception as e:
|
| 305 |
+
print(f"Error updating progress: {str(e)}")
|
| 306 |
|
| 307 |
+
except Exception as e:
|
| 308 |
+
print(f"Error in frame processing: {str(e)}")
|
| 309 |
+
import traceback
|
| 310 |
+
traceback.print_exc()
|
| 311 |
+
finally:
|
| 312 |
+
cap.release()
|
| 313 |
+
out.release()
|
| 314 |
+
plt.close(fig)
|
| 315 |
|
| 316 |
+
if os.path.exists(heatmap_video_path):
|
| 317 |
+
print(f"Heatmap video created at: {heatmap_video_path}")
|
| 318 |
+
return heatmap_video_path
|
| 319 |
+
else:
|
| 320 |
+
print(f"Failed to create heatmap video at: {heatmap_video_path}")
|
| 321 |
+
return None
|