Spaces:
Runtime error
Runtime error
Update visualization.py
Browse files- visualization.py +15 -2
visualization.py
CHANGED
|
@@ -15,6 +15,7 @@ from anomaly_detection import determine_anomalies
|
|
| 15 |
from scipy import interpolate
|
| 16 |
import gradio as gr
|
| 17 |
import os
|
|
|
|
| 18 |
|
| 19 |
def plot_mse(df, mse_values, title, color='navy', time_threshold=3, anomaly_threshold=4):
|
| 20 |
plt.figure(figsize=(16, 8), dpi=300)
|
|
@@ -302,8 +303,20 @@ def create_video_with_heatmap(video_path, df, mse_embeddings, mse_posture, mse_v
|
|
| 302 |
final_clip = VideoClip(combine_video_and_heatmap, duration=video.duration)
|
| 303 |
final_clip = final_clip.set_audio(video.audio)
|
| 304 |
|
| 305 |
-
#
|
| 306 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
|
| 308 |
# Close the video clips
|
| 309 |
video.close()
|
|
|
|
| 15 |
from scipy import interpolate
|
| 16 |
import gradio as gr
|
| 17 |
import os
|
| 18 |
+
import logging
|
| 19 |
|
| 20 |
def plot_mse(df, mse_values, title, color='navy', time_threshold=3, anomaly_threshold=4):
|
| 21 |
plt.figure(figsize=(16, 8), dpi=300)
|
|
|
|
| 303 |
final_clip = VideoClip(combine_video_and_heatmap, duration=video.duration)
|
| 304 |
final_clip = final_clip.set_audio(video.audio)
|
| 305 |
|
| 306 |
+
# Define a logger to track progress
|
| 307 |
+
class ProgressBarLogger(logging.Logger):
|
| 308 |
+
def __init__(self, name, progress_callback):
|
| 309 |
+
super().__init__(name)
|
| 310 |
+
self.progress_callback = progress_callback
|
| 311 |
+
|
| 312 |
+
def debug(self, msg, *args, **kwargs):
|
| 313 |
+
if self.progress_callback:
|
| 314 |
+
self.progress_callback(float(msg.split('%')[0]) / 100, msg)
|
| 315 |
+
|
| 316 |
+
progress_logger = ProgressBarLogger('progress_logger', progress)
|
| 317 |
+
|
| 318 |
+
# Write the final video
|
| 319 |
+
final_clip.write_videofile(heatmap_video_path, codec='libx264', audio_codec='aac', fps=video.fps, logger=progress_logger)
|
| 320 |
|
| 321 |
# Close the video clips
|
| 322 |
video.close()
|