reab5555 commited on
Commit
3e6c98a
·
verified ·
1 Parent(s): afe7a1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -53,8 +53,8 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
53
  traceback.print_exc()
54
  return [error_message] + [None] * 27
55
 
56
- def show_results(outputs):
57
- return [gr.Tab.update(visible=True) for _ in range(4)] + [gr.Tab.update(visible=False)], gr.Group(visible=True)
58
 
59
  def hide_description_show_results():
60
  return [gr.Tab.update(visible=False)] + [gr.Tab.update(visible=True) for _ in range(4)]
@@ -73,7 +73,8 @@ with gr.Blocks() as iface:
73
  execution_time = gr.Number(label="Execution Time (seconds)")
74
 
75
  with gr.Tabs() as all_tabs:
76
- with gr.Tab("Description", visible=True):
 
77
  gr.Markdown("""
78
  # Multimodal Behavioral Anomalies Detection
79
 
@@ -81,7 +82,8 @@ with gr.Blocks() as iface:
81
  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.
82
  """)
83
 
84
- with gr.Tab("Facial Features", visible=False):
 
85
  results_text = gr.TextArea(label="Faces Breakdown", lines=5)
86
  mse_features_plot = gr.Plot(label="MSE: Facial Features")
87
  mse_features_hist = gr.Plot(label="MSE Distribution: Facial Features")
@@ -89,18 +91,21 @@ with gr.Blocks() as iface:
89
  anomaly_frames_features = gr.Gallery(label="Anomaly Frames (Facial Features)", columns=6, rows=2, height="auto")
90
  face_samples_most_frequent = gr.Gallery(label="Most Frequent Person Samples", columns=10, rows=2, height="auto")
91
 
92
- with gr.Tab("Body Posture", visible=False):
 
93
  mse_posture_plot = gr.Plot(label="MSE: Body Posture")
94
  mse_posture_hist = gr.Plot(label="MSE Distribution: Body Posture")
95
  mse_posture_heatmap = gr.Plot(label="MSE Heatmap: Body Posture")
96
  anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
97
 
98
- with gr.Tab("Voice", visible=False):
 
99
  mse_voice_plot = gr.Plot(label="MSE: Voice")
100
  mse_voice_hist = gr.Plot(label="MSE Distribution: Voice")
101
  mse_voice_heatmap = gr.Plot(label="MSE Heatmap: Voice")
102
 
103
- with gr.Tab("Combined", visible=False):
 
104
  heatmap_video = gr.Video(label="Video with Anomaly Heatmap")
105
  combined_mse_plot = gr.Plot(label="Combined MSE Plot")
106
  correlation_heatmap_plot = gr.Plot(label="Correlation Heatmap")
@@ -118,7 +123,7 @@ with gr.Blocks() as iface:
118
  process_btn.click(
119
  hide_description_show_results,
120
  inputs=None,
121
- outputs=all_tabs.children
122
  ).then(
123
  process_and_show_completion,
124
  inputs=[video_input, anomaly_threshold, fps_slider],
@@ -137,7 +142,7 @@ with gr.Blocks() as iface:
137
  ).then(
138
  show_results,
139
  inputs=None,
140
- outputs=[all_tabs.children, execution_time_group]
141
  )
142
 
143
  if __name__ == "__main__":
 
53
  traceback.print_exc()
54
  return [error_message] + [None] * 27
55
 
56
+ def show_results():
57
+ return [gr.Tab.update(visible=True) for _ in range(4)] + [gr.Tab.update(visible=False)], gr.Group.update(visible=True)
58
 
59
  def hide_description_show_results():
60
  return [gr.Tab.update(visible=False)] + [gr.Tab.update(visible=True) for _ in range(4)]
 
73
  execution_time = gr.Number(label="Execution Time (seconds)")
74
 
75
  with gr.Tabs() as all_tabs:
76
+ description_tab = gr.Tab("Description")
77
+ with description_tab:
78
  gr.Markdown("""
79
  # Multimodal Behavioral Anomalies Detection
80
 
 
82
  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.
83
  """)
84
 
85
+ facial_features_tab = gr.Tab("Facial Features", visible=False)
86
+ with facial_features_tab:
87
  results_text = gr.TextArea(label="Faces Breakdown", lines=5)
88
  mse_features_plot = gr.Plot(label="MSE: Facial Features")
89
  mse_features_hist = gr.Plot(label="MSE Distribution: Facial Features")
 
91
  anomaly_frames_features = gr.Gallery(label="Anomaly Frames (Facial Features)", columns=6, rows=2, height="auto")
92
  face_samples_most_frequent = gr.Gallery(label="Most Frequent Person Samples", columns=10, rows=2, height="auto")
93
 
94
+ body_posture_tab = gr.Tab("Body Posture", visible=False)
95
+ with body_posture_tab:
96
  mse_posture_plot = gr.Plot(label="MSE: Body Posture")
97
  mse_posture_hist = gr.Plot(label="MSE Distribution: Body Posture")
98
  mse_posture_heatmap = gr.Plot(label="MSE Heatmap: Body Posture")
99
  anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
100
 
101
+ voice_tab = gr.Tab("Voice", visible=False)
102
+ with voice_tab:
103
  mse_voice_plot = gr.Plot(label="MSE: Voice")
104
  mse_voice_hist = gr.Plot(label="MSE Distribution: Voice")
105
  mse_voice_heatmap = gr.Plot(label="MSE Heatmap: Voice")
106
 
107
+ combined_tab = gr.Tab("Combined", visible=False)
108
+ with combined_tab:
109
  heatmap_video = gr.Video(label="Video with Anomaly Heatmap")
110
  combined_mse_plot = gr.Plot(label="Combined MSE Plot")
111
  correlation_heatmap_plot = gr.Plot(label="Correlation Heatmap")
 
123
  process_btn.click(
124
  hide_description_show_results,
125
  inputs=None,
126
+ outputs=[description_tab, facial_features_tab, body_posture_tab, voice_tab, combined_tab]
127
  ).then(
128
  process_and_show_completion,
129
  inputs=[video_input, anomaly_threshold, fps_slider],
 
142
  ).then(
143
  show_results,
144
  inputs=None,
145
+ outputs=[all_tabs, execution_time_group]
146
  )
147
 
148
  if __name__ == "__main__":