reab5555 commited on
Commit
95703f6
·
verified ·
1 Parent(s): 5de1bb7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -9
app.py CHANGED
@@ -56,9 +56,12 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
56
  def show_results(outputs):
57
  return gr.Tabs(visible=True), gr.Group(visible=True)
58
 
 
 
 
59
  with gr.Blocks() as iface:
60
  with gr.Row():
61
- video_input = gr.Video(label="Input Video")
62
 
63
  anomaly_threshold = gr.Slider(minimum=1, maximum=5, step=0.1, value=3, label="Anomaly Detection Threshold (Standard deviation)")
64
  fps_slider = gr.Slider(minimum=5, maximum=20, step=1, value=10, label="Frames Per Second (FPS)")
@@ -69,8 +72,8 @@ with gr.Blocks() as iface:
69
  with execution_time_group:
70
  execution_time = gr.Number(label="Execution Time (seconds)")
71
 
72
- with gr.Tabs(visible=True) as results_tabs:
73
- with gr.TabItem("Description"):
74
  gr.Markdown("""
75
  # Multimodal Behavioral Anomalies Detection
76
 
@@ -78,7 +81,7 @@ with gr.Blocks() as iface:
78
  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.
79
  """)
80
 
81
- with gr.TabItem("Facial Features"):
82
  results_text = gr.TextArea(label="Faces Breakdown", lines=5)
83
  mse_features_plot = gr.Plot(label="MSE: Facial Features")
84
  mse_features_hist = gr.Plot(label="MSE Distribution: Facial Features")
@@ -86,19 +89,19 @@ with gr.Blocks() as iface:
86
  anomaly_frames_features = gr.Gallery(label="Anomaly Frames (Facial Features)", columns=6, rows=2, height="auto")
87
  face_samples_most_frequent = gr.Gallery(label="Most Frequent Person Samples", columns=10, rows=2, height="auto")
88
 
89
- with gr.TabItem("Body Posture"):
90
  mse_posture_plot = gr.Plot(label="MSE: Body Posture")
91
  mse_posture_hist = gr.Plot(label="MSE Distribution: Body Posture")
92
  mse_posture_heatmap = gr.Plot(label="MSE Heatmap: Body Posture")
93
  anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
94
 
95
- with gr.TabItem("Voice"):
96
  mse_voice_plot = gr.Plot(label="MSE: Voice")
97
  mse_voice_hist = gr.Plot(label="MSE Distribution: Voice")
98
  mse_voice_heatmap = gr.Plot(label="MSE Heatmap: Voice")
99
 
100
- with gr.TabItem("Combined"):
101
- heatmap_video = gr.Video(label="Video with Anomaly Heatmap", visible=False)
102
  combined_mse_plot = gr.Plot(label="Combined MSE Plot")
103
  correlation_heatmap_plot = gr.Plot(label="Correlation Heatmap")
104
 
@@ -113,6 +116,10 @@ with gr.Blocks() as iface:
113
  mse_heatmap_voice_store = gr.State()
114
 
115
  process_btn.click(
 
 
 
 
116
  process_and_show_completion,
117
  inputs=[video_input, anomaly_threshold, fps_slider],
118
  outputs=[
@@ -130,7 +137,7 @@ with gr.Blocks() as iface:
130
  ).then(
131
  show_results,
132
  inputs=None,
133
- outputs=[results_tabs, execution_time_group]
134
  )
135
 
136
  if __name__ == "__main__":
 
56
  def show_results(outputs):
57
  return gr.Tabs(visible=True), gr.Group(visible=True)
58
 
59
+ def hide_description_show_results():
60
+ return gr.Tabs(visible=True), gr.Tab(visible=False)
61
+
62
  with gr.Blocks() as iface:
63
  with gr.Row():
64
+ video_input = gr.Video(label="Input Video", visible=False)
65
 
66
  anomaly_threshold = gr.Slider(minimum=1, maximum=5, step=0.1, value=3, label="Anomaly Detection Threshold (Standard deviation)")
67
  fps_slider = gr.Slider(minimum=5, maximum=20, step=1, value=10, label="Frames Per Second (FPS)")
 
72
  with execution_time_group:
73
  execution_time = gr.Number(label="Execution Time (seconds)")
74
 
75
+ with gr.Tabs() as all_tabs:
76
+ with gr.Tab("Description", elem_id="description_tab"):
77
  gr.Markdown("""
78
  # Multimodal Behavioral Anomalies Detection
79
 
 
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
  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")
107
 
 
116
  mse_heatmap_voice_store = gr.State()
117
 
118
  process_btn.click(
119
+ hide_description_show_results,
120
+ inputs=None,
121
+ outputs=[all_tabs, all_tabs.select("Description")]
122
+ ).then(
123
  process_and_show_completion,
124
  inputs=[video_input, anomaly_threshold, fps_slider],
125
  outputs=[
 
137
  ).then(
138
  show_results,
139
  inputs=None,
140
+ outputs=[all_tabs, execution_time_group]
141
  )
142
 
143
  if __name__ == "__main__":