Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,15 +15,17 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 15 |
|
| 16 |
if isinstance(results[0], str) and results[0].startswith("Error"):
|
| 17 |
print(f"Error occurred: {results[0]}")
|
| 18 |
-
return [results[0]] + [None] *
|
| 19 |
-
|
| 20 |
-
exec_time, results_summary, df, mse_embeddings, mse_posture,
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
| 27 |
|
| 28 |
anomaly_faces_embeddings_pil = [Image.fromarray(face) for face in anomaly_faces_embeddings]
|
| 29 |
anomaly_frames_posture_pil = [Image.fromarray(frame) for frame in anomaly_frames_posture_images]
|
|
@@ -40,6 +42,7 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 40 |
face_samples_frequent,
|
| 41 |
aligned_faces_folder, frames_folder,
|
| 42 |
mse_embeddings, mse_posture,
|
|
|
|
| 43 |
]
|
| 44 |
|
| 45 |
return output
|
|
@@ -49,14 +52,14 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 49 |
print(error_message)
|
| 50 |
import traceback
|
| 51 |
traceback.print_exc()
|
| 52 |
-
return [error_message] + [None] *
|
| 53 |
|
| 54 |
with gr.Blocks() as iface:
|
| 55 |
gr.Markdown("""
|
| 56 |
# Multimodal Behavioral Anomalies Detection
|
| 57 |
|
| 58 |
-
|
| 59 |
-
It extracts faces
|
| 60 |
""")
|
| 61 |
|
| 62 |
with gr.Row():
|
|
@@ -76,8 +79,7 @@ with gr.Blocks() as iface:
|
|
| 76 |
mse_features_hist = gr.Plot(label="MSE Distribution: Facial Features")
|
| 77 |
mse_features_heatmap = gr.Plot(label="MSE Heatmap: Facial Features")
|
| 78 |
anomaly_frames_features = gr.Gallery(label="Anomaly Frames (Facial Features)", columns=6, rows=2, height="auto")
|
| 79 |
-
face_samples_most_frequent = gr.Gallery(label="
|
| 80 |
-
#face_samples_others = gr.Gallery(label="Other Samples", columns=6, rows=1, height="auto")
|
| 81 |
|
| 82 |
with gr.Tab("Body Posture"):
|
| 83 |
mse_posture_plot = gr.Plot(label="MSE: Body Posture")
|
|
@@ -91,7 +93,6 @@ with gr.Blocks() as iface:
|
|
| 91 |
mse_voice_heatmap = gr.Plot(label="MSE Heatmap: Voice")
|
| 92 |
anomaly_segments_voice = gr.Audio(label="Anomaly Voice Segments", type="filepath")
|
| 93 |
|
| 94 |
-
|
| 95 |
df_store = gr.State()
|
| 96 |
mse_features_store = gr.State()
|
| 97 |
mse_posture_store = gr.State()
|
|
@@ -109,11 +110,11 @@ with gr.Blocks() as iface:
|
|
| 109 |
mse_features_plot, mse_posture_plot,
|
| 110 |
mse_features_hist, mse_posture_hist,
|
| 111 |
mse_features_heatmap, mse_posture_heatmap,
|
| 112 |
-
mse_voice_plot, mse_voice_hist, mse_voice_heatmap, anomaly_segments_voice,
|
| 113 |
anomaly_frames_features, anomaly_frames_posture,
|
| 114 |
face_samples_most_frequent,
|
| 115 |
aligned_faces_folder_store, frames_folder_store,
|
| 116 |
-
mse_heatmap_embeddings_store, mse_heatmap_posture_store
|
|
|
|
| 117 |
]
|
| 118 |
).then(
|
| 119 |
lambda: gr.Group(visible=True),
|
|
|
|
| 15 |
|
| 16 |
if isinstance(results[0], str) and results[0].startswith("Error"):
|
| 17 |
print(f"Error occurred: {results[0]}")
|
| 18 |
+
return [results[0]] + [None] * 21 # Adjust this number based on your total outputs
|
| 19 |
+
|
| 20 |
+
(exec_time, results_summary, df, mse_embeddings, mse_posture,
|
| 21 |
+
mse_plot_embeddings, mse_histogram_embeddings,
|
| 22 |
+
mse_plot_posture, mse_histogram_posture,
|
| 23 |
+
mse_heatmap_embeddings, mse_heatmap_posture,
|
| 24 |
+
face_samples_frequent,
|
| 25 |
+
anomaly_faces_embeddings, anomaly_frames_posture_images,
|
| 26 |
+
aligned_faces_folder, frames_folder,
|
| 27 |
+
mse_voice, mse_plot_voice, mse_histogram_voice, mse_heatmap_voice,
|
| 28 |
+
anomaly_segments_voice) = results
|
| 29 |
|
| 30 |
anomaly_faces_embeddings_pil = [Image.fromarray(face) for face in anomaly_faces_embeddings]
|
| 31 |
anomaly_frames_posture_pil = [Image.fromarray(frame) for frame in anomaly_frames_posture_images]
|
|
|
|
| 42 |
face_samples_frequent,
|
| 43 |
aligned_faces_folder, frames_folder,
|
| 44 |
mse_embeddings, mse_posture,
|
| 45 |
+
mse_plot_voice, mse_histogram_voice, mse_heatmap_voice, anomaly_segments_voice
|
| 46 |
]
|
| 47 |
|
| 48 |
return output
|
|
|
|
| 52 |
print(error_message)
|
| 53 |
import traceback
|
| 54 |
traceback.print_exc()
|
| 55 |
+
return [error_message] + [None] * 21 # Adjust this number based on your total outputs
|
| 56 |
|
| 57 |
with gr.Blocks() as iface:
|
| 58 |
gr.Markdown("""
|
| 59 |
# Multimodal Behavioral Anomalies Detection
|
| 60 |
|
| 61 |
+
This tool detects anomalies in facial expressions, body language, and voice over the timeline of a video.
|
| 62 |
+
It extracts faces, postures, and voice features from video frames, and analyzes them to identify anomalies using time series analysis and a variational autoencoder (VAE) approach.
|
| 63 |
""")
|
| 64 |
|
| 65 |
with gr.Row():
|
|
|
|
| 79 |
mse_features_hist = gr.Plot(label="MSE Distribution: Facial Features")
|
| 80 |
mse_features_heatmap = gr.Plot(label="MSE Heatmap: Facial Features")
|
| 81 |
anomaly_frames_features = gr.Gallery(label="Anomaly Frames (Facial Features)", columns=6, rows=2, height="auto")
|
| 82 |
+
face_samples_most_frequent = gr.Gallery(label="Most Frequent Person Samples", columns=10, rows=2, height="auto")
|
|
|
|
| 83 |
|
| 84 |
with gr.Tab("Body Posture"):
|
| 85 |
mse_posture_plot = gr.Plot(label="MSE: Body Posture")
|
|
|
|
| 93 |
mse_voice_heatmap = gr.Plot(label="MSE Heatmap: Voice")
|
| 94 |
anomaly_segments_voice = gr.Audio(label="Anomaly Voice Segments", type="filepath")
|
| 95 |
|
|
|
|
| 96 |
df_store = gr.State()
|
| 97 |
mse_features_store = gr.State()
|
| 98 |
mse_posture_store = gr.State()
|
|
|
|
| 110 |
mse_features_plot, mse_posture_plot,
|
| 111 |
mse_features_hist, mse_posture_hist,
|
| 112 |
mse_features_heatmap, mse_posture_heatmap,
|
|
|
|
| 113 |
anomaly_frames_features, anomaly_frames_posture,
|
| 114 |
face_samples_most_frequent,
|
| 115 |
aligned_faces_folder_store, frames_folder_store,
|
| 116 |
+
mse_heatmap_embeddings_store, mse_heatmap_posture_store,
|
| 117 |
+
mse_voice_plot, mse_voice_hist, mse_voice_heatmap, anomaly_segments_voice
|
| 118 |
]
|
| 119 |
).then(
|
| 120 |
lambda: gr.Group(visible=True),
|