reab5555 commited on
Commit
981f936
·
verified ·
1 Parent(s): 13ccf55

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -32
app.py CHANGED
@@ -56,10 +56,11 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
56
  def on_button_click(video, threshold, fps):
57
  start_time = time.time()
58
 
59
- # Show execution time immediately
60
  yield {
61
  execution_time: gr.update(visible=True, value=0),
62
- results_tab: gr.update(visible=True)
 
63
  }
64
 
65
  results = process_and_show_completion(video, threshold, fps)
@@ -107,6 +108,36 @@ with gr.Blocks() as iface:
107
  execution_time = gr.Number(label="Execution Time (seconds)", visible=False)
108
 
109
  with gr.Tabs() as tabs:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  with gr.TabItem("Description"):
111
  with gr.Column():
112
  gr.Markdown("""
@@ -145,40 +176,11 @@ with gr.Blocks() as iface:
145
  This tool offers solutions for detecting behavioral anomalies in video content. However, users should be aware of its limitations and interpret results with caution.
146
  """)
147
 
148
- with gr.TabItem("Results", id="results_tab", visible=False) as results_tab:
149
- with gr.Tabs():
150
- with gr.TabItem("Facial Features"):
151
- video_display_facial = gr.Video(label="Input Video")
152
- results_text = gr.TextArea(label="Faces Breakdown", lines=5)
153
- mse_features_plot = gr.Plot(label="MSE: Facial Features")
154
- mse_features_hist = gr.Plot(label="MSE Distribution: Facial Features")
155
- mse_features_heatmap = gr.Plot(label="MSE Heatmap: Facial Features")
156
- anomaly_frames_features = gr.Gallery(label="Anomaly Frames (Facial Features)", columns=6, rows=2, height="auto")
157
- face_samples_most_frequent = gr.Gallery(label="Most Frequent Person Samples", columns=10, rows=2, height="auto")
158
-
159
- with gr.TabItem("Body Posture"):
160
- video_display_body = gr.Video(label="Input Video")
161
- mse_posture_plot = gr.Plot(label="MSE: Body Posture")
162
- mse_posture_hist = gr.Plot(label="MSE Distribution: Body Posture")
163
- mse_posture_heatmap = gr.Plot(label="MSE Heatmap: Body Posture")
164
- anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
165
-
166
- with gr.TabItem("Voice"):
167
- video_display_voice = gr.Video(label="Input Video")
168
- mse_voice_plot = gr.Plot(label="MSE: Voice")
169
- mse_voice_hist = gr.Plot(label="MSE Distribution: Voice")
170
- mse_voice_heatmap = gr.Plot(label="MSE Heatmap: Voice")
171
-
172
- with gr.TabItem("Combined"):
173
- heatmap_video = gr.Video(label="Video with Anomaly Heatmap")
174
- combined_mse_plot = gr.Plot(label="Combined MSE Plot")
175
- correlation_heatmap_plot = gr.Plot(label="Correlation Heatmap")
176
-
177
  process_btn.click(
178
  fn=on_button_click,
179
  inputs=[video_input, anomaly_threshold, fps_slider],
180
  outputs=[
181
- execution_time, results_tab,
182
  results_text, mse_features_plot, mse_posture_plot, mse_voice_plot,
183
  mse_features_hist, mse_posture_hist, mse_voice_hist,
184
  mse_features_heatmap, mse_posture_heatmap, mse_voice_heatmap,
 
56
  def on_button_click(video, threshold, fps):
57
  start_time = time.time()
58
 
59
+ # Show execution time immediately and make results tab visible
60
  yield {
61
  execution_time: gr.update(visible=True, value=0),
62
+ results_tab: gr.update(visible=True),
63
+ tabs: gr.update(selected="Results")
64
  }
65
 
66
  results = process_and_show_completion(video, threshold, fps)
 
108
  execution_time = gr.Number(label="Execution Time (seconds)", visible=False)
109
 
110
  with gr.Tabs() as tabs:
111
+ results_tab = gr.TabItem("Results")
112
+ with results_tab:
113
+ with gr.Tabs():
114
+ with gr.TabItem("Facial Features"):
115
+ video_display_facial = gr.Video(label="Input Video")
116
+ results_text = gr.TextArea(label="Faces Breakdown", lines=5)
117
+ mse_features_plot = gr.Plot(label="MSE: Facial Features")
118
+ mse_features_hist = gr.Plot(label="MSE Distribution: Facial Features")
119
+ mse_features_heatmap = gr.Plot(label="MSE Heatmap: Facial Features")
120
+ anomaly_frames_features = gr.Gallery(label="Anomaly Frames (Facial Features)", columns=6, rows=2, height="auto")
121
+ face_samples_most_frequent = gr.Gallery(label="Most Frequent Person Samples", columns=10, rows=2, height="auto")
122
+
123
+ with gr.TabItem("Body Posture"):
124
+ video_display_body = gr.Video(label="Input Video")
125
+ mse_posture_plot = gr.Plot(label="MSE: Body Posture")
126
+ mse_posture_hist = gr.Plot(label="MSE Distribution: Body Posture")
127
+ mse_posture_heatmap = gr.Plot(label="MSE Heatmap: Body Posture")
128
+ anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
129
+
130
+ with gr.TabItem("Voice"):
131
+ video_display_voice = gr.Video(label="Input Video")
132
+ mse_voice_plot = gr.Plot(label="MSE: Voice")
133
+ mse_voice_hist = gr.Plot(label="MSE Distribution: Voice")
134
+ mse_voice_heatmap = gr.Plot(label="MSE Heatmap: Voice")
135
+
136
+ with gr.TabItem("Combined"):
137
+ heatmap_video = gr.Video(label="Video with Anomaly Heatmap")
138
+ combined_mse_plot = gr.Plot(label="Combined MSE Plot")
139
+ correlation_heatmap_plot = gr.Plot(label="Correlation Heatmap")
140
+
141
  with gr.TabItem("Description"):
142
  with gr.Column():
143
  gr.Markdown("""
 
176
  This tool offers solutions for detecting behavioral anomalies in video content. However, users should be aware of its limitations and interpret results with caution.
177
  """)
178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  process_btn.click(
180
  fn=on_button_click,
181
  inputs=[video_input, anomaly_threshold, fps_slider],
182
  outputs=[
183
+ execution_time, results_tab, tabs,
184
  results_text, mse_features_plot, mse_posture_plot, mse_voice_plot,
185
  mse_features_hist, mse_posture_hist, mse_voice_hist,
186
  mse_features_heatmap, mse_posture_heatmap, mse_voice_heatmap,