Spaces:
Runtime error
Runtime error
Update visualization.py
Browse files- visualization.py +2 -19
visualization.py
CHANGED
|
@@ -216,7 +216,7 @@ def plot_posture(df, posture_scores, color='blue', anomaly_threshold=3):
|
|
| 216 |
plt.close()
|
| 217 |
return fig
|
| 218 |
|
| 219 |
-
def create_video_with_heatmap(video_path, df, mse_embeddings, mse_posture, mse_voice, output_folder, desired_fps, largest_cluster
|
| 220 |
print(f"Creating heatmap video. Output folder: {output_folder}")
|
| 221 |
|
| 222 |
os.makedirs(output_folder, exist_ok=True)
|
|
@@ -302,25 +302,8 @@ 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 |
-
# Define a logger to track progress
|
| 306 |
-
class ProgressBarLogger(logging.Logger):
|
| 307 |
-
def __init__(self, name, progress_callback):
|
| 308 |
-
super().__init__(name)
|
| 309 |
-
self.progress_callback = progress_callback
|
| 310 |
-
|
| 311 |
-
def debug(self, msg, *args, **kwargs):
|
| 312 |
-
if 't=' in msg and self.progress_callback:
|
| 313 |
-
progress_percent = float(msg.split(' ')[-1].replace('%', '')) / 100
|
| 314 |
-
self.progress_callback(progress_percent, msg)
|
| 315 |
-
|
| 316 |
-
def __call__(self, msg, *args, **kwargs):
|
| 317 |
-
self.debug(msg)
|
| 318 |
-
|
| 319 |
-
logging.basicConfig(level=logging.DEBUG)
|
| 320 |
-
progress_logger = ProgressBarLogger('progress_logger', progress)
|
| 321 |
-
|
| 322 |
# Write the final video
|
| 323 |
-
final_clip.write_videofile(heatmap_video_path, codec='libx264', audio_codec='aac', fps=video.fps
|
| 324 |
|
| 325 |
# Close the video clips
|
| 326 |
video.close()
|
|
|
|
| 216 |
plt.close()
|
| 217 |
return fig
|
| 218 |
|
| 219 |
+
def create_video_with_heatmap(video_path, df, mse_embeddings, mse_posture, mse_voice, output_folder, desired_fps, largest_cluster):
|
| 220 |
print(f"Creating heatmap video. Output folder: {output_folder}")
|
| 221 |
|
| 222 |
os.makedirs(output_folder, exist_ok=True)
|
|
|
|
| 302 |
final_clip = VideoClip(combine_video_and_heatmap, duration=video.duration)
|
| 303 |
final_clip = final_clip.set_audio(video.audio)
|
| 304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
# Write the final video
|
| 306 |
+
final_clip.write_videofile(heatmap_video_path, codec='libx264', audio_codec='aac', fps=video.fps)
|
| 307 |
|
| 308 |
# Close the video clips
|
| 309 |
video.close()
|