reab5555 commited on
Commit
aeb4947
·
verified ·
1 Parent(s): 1705770

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -16
app.py CHANGED
@@ -15,12 +15,13 @@ 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] * 18
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, \
@@ -33,14 +34,14 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
33
 
34
  output = [
35
  exec_time, results_summary,
36
- df, mse_embeddings, mse_posture,
37
- mse_plot_embeddings, mse_plot_posture,
38
- mse_histogram_embeddings, mse_histogram_posture,
39
- mse_heatmap_embeddings, mse_heatmap_posture,
40
  anomaly_faces_embeddings_pil, anomaly_frames_posture_pil,
41
  face_samples_frequent,
42
  aligned_faces_folder, frames_folder,
43
- mse_embeddings, mse_posture,
44
  heatmap_video_path
45
  ]
46
 
@@ -51,14 +52,14 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
51
  print(error_message)
52
  import traceback
53
  traceback.print_exc()
54
- return [error_message] + [None] * 18
55
 
56
  with gr.Blocks() as iface:
57
  gr.Markdown("""
58
  # Multimodal Behavioral Anomalies Detection
59
 
60
- This tool detects anomalies in facial expressions and body language over the timeline of a video.
61
- It extracts faces and postures from video frames, and analyzes them to identify anomalies using time series analysis and a variational autoencoder (VAE) approach.
62
  """)
63
 
64
  with gr.Row():
@@ -86,30 +87,37 @@ with gr.Blocks() as iface:
86
  mse_posture_heatmap = gr.Plot(label="MSE Heatmap: Body Posture")
87
  anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
88
 
 
 
 
 
 
89
  with gr.Tab("Video with Heatmap"):
90
  heatmap_video = gr.Video(label="Video with Anomaly Heatmap")
91
 
92
  df_store = gr.State()
93
  mse_features_store = gr.State()
94
  mse_posture_store = gr.State()
 
95
  aligned_faces_folder_store = gr.State()
96
  frames_folder_store = gr.State()
97
  mse_heatmap_embeddings_store = gr.State()
98
  mse_heatmap_posture_store = gr.State()
 
99
 
100
  process_btn.click(
101
  process_and_show_completion,
102
  inputs=[video_input, anomaly_threshold, fps_slider],
103
  outputs=[
104
  execution_time, results_text, df_store,
105
- mse_features_store, mse_posture_store,
106
- mse_features_plot, mse_posture_plot,
107
- mse_features_hist, mse_posture_hist,
108
- mse_features_heatmap, mse_posture_heatmap,
109
  anomaly_frames_features, anomaly_frames_posture,
110
  face_samples_most_frequent,
111
  aligned_faces_folder_store, frames_folder_store,
112
- mse_heatmap_embeddings_store, mse_heatmap_posture_store,
113
  heatmap_video
114
  ]
115
  ).then(
 
15
 
16
  if isinstance(results[0], str) and results[0].startswith("Error"):
17
  print(f"Error occurred: {results[0]}")
18
+ return [results[0]] + [None] * 23 # Increased number of None values
19
 
20
+ exec_time, results_summary, df, mse_embeddings, mse_posture, mse_voice, \
21
  mse_plot_embeddings, mse_histogram_embeddings, \
22
  mse_plot_posture, mse_histogram_posture, \
23
+ mse_plot_voice, mse_histogram_voice, \
24
+ mse_heatmap_embeddings, mse_heatmap_posture, mse_heatmap_voice, \
25
  face_samples_frequent, \
26
  anomaly_faces_embeddings, anomaly_frames_posture_images, \
27
  aligned_faces_folder, frames_folder, \
 
34
 
35
  output = [
36
  exec_time, results_summary,
37
+ df, mse_embeddings, mse_posture, mse_voice,
38
+ mse_plot_embeddings, mse_plot_posture, mse_plot_voice,
39
+ mse_histogram_embeddings, mse_histogram_posture, mse_histogram_voice,
40
+ mse_heatmap_embeddings, mse_heatmap_posture, mse_heatmap_voice,
41
  anomaly_faces_embeddings_pil, anomaly_frames_posture_pil,
42
  face_samples_frequent,
43
  aligned_faces_folder, frames_folder,
44
+ mse_embeddings, mse_posture, mse_voice,
45
  heatmap_video_path
46
  ]
47
 
 
52
  print(error_message)
53
  import traceback
54
  traceback.print_exc()
55
+ return [error_message] + [None] * 23 # Increased number of None values
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 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():
 
87
  mse_posture_heatmap = gr.Plot(label="MSE Heatmap: Body Posture")
88
  anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
89
 
90
+ with gr.Tab("Voice"):
91
+ mse_voice_plot = gr.Plot(label="MSE: Voice")
92
+ mse_voice_hist = gr.Plot(label="MSE Distribution: Voice")
93
+ mse_voice_heatmap = gr.Plot(label="MSE Heatmap: Voice")
94
+
95
  with gr.Tab("Video with Heatmap"):
96
  heatmap_video = gr.Video(label="Video with Anomaly Heatmap")
97
 
98
  df_store = gr.State()
99
  mse_features_store = gr.State()
100
  mse_posture_store = gr.State()
101
+ mse_voice_store = gr.State()
102
  aligned_faces_folder_store = gr.State()
103
  frames_folder_store = gr.State()
104
  mse_heatmap_embeddings_store = gr.State()
105
  mse_heatmap_posture_store = gr.State()
106
+ mse_heatmap_voice_store = gr.State()
107
 
108
  process_btn.click(
109
  process_and_show_completion,
110
  inputs=[video_input, anomaly_threshold, fps_slider],
111
  outputs=[
112
  execution_time, results_text, df_store,
113
+ mse_features_store, mse_posture_store, mse_voice_store,
114
+ mse_features_plot, mse_posture_plot, mse_voice_plot,
115
+ mse_features_hist, mse_posture_hist, mse_voice_hist,
116
+ mse_features_heatmap, mse_posture_heatmap, mse_voice_heatmap,
117
  anomaly_frames_features, anomaly_frames_posture,
118
  face_samples_most_frequent,
119
  aligned_faces_folder_store, frames_folder_store,
120
+ mse_heatmap_embeddings_store, mse_heatmap_posture_store, mse_heatmap_voice_store,
121
  heatmap_video
122
  ]
123
  ).then(