Update app.py
Browse files
app.py
CHANGED
@@ -12,11 +12,11 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
12 |
print("Starting video processing...")
|
13 |
results = process_video(video_input_path, anomaly_threshold_input, fps, progress=progress)
|
14 |
print("Video processing completed.")
|
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, mse_voice, \
|
21 |
mse_plot_embeddings, mse_plot_posture, mse_plot_voice, \
|
22 |
mse_histogram_embeddings, mse_histogram_posture, mse_histogram_voice, \
|
@@ -24,13 +24,12 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
24 |
face_samples_frequent, \
|
25 |
anomaly_faces_embeddings, anomaly_frames_posture_images, \
|
26 |
aligned_faces_folder, frames_folder, \
|
27 |
-
stacked_heatmap = results
|
28 |
-
|
29 |
anomaly_faces_embeddings_pil = [Image.fromarray(face) for face in anomaly_faces_embeddings] if anomaly_faces_embeddings is not None else []
|
30 |
anomaly_frames_posture_pil = [Image.fromarray(frame) for frame in anomaly_frames_posture_images] if anomaly_frames_posture_images is not None else []
|
31 |
-
|
32 |
face_samples_frequent = [Image.open(path) for path in face_samples_frequent] if face_samples_frequent is not None else []
|
33 |
-
|
34 |
output = [
|
35 |
exec_time, results_summary,
|
36 |
df, mse_embeddings, mse_posture, mse_voice,
|
@@ -41,17 +40,17 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
41 |
face_samples_frequent,
|
42 |
aligned_faces_folder, frames_folder,
|
43 |
mse_embeddings, mse_posture, mse_voice,
|
44 |
-
stacked_heatmap
|
|
|
45 |
]
|
46 |
-
|
47 |
return output
|
48 |
-
|
49 |
except Exception as e:
|
50 |
error_message = f"An error occurred: {str(e)}"
|
51 |
print(error_message)
|
52 |
import traceback
|
53 |
traceback.print_exc()
|
54 |
-
return [error_message] + [None] *
|
55 |
|
56 |
def show_results(outputs):
|
57 |
return gr.Group(visible=True)
|
@@ -93,6 +92,7 @@ with gr.Blocks() as iface:
|
|
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")
|
@@ -219,7 +219,7 @@ with gr.Blocks() as iface:
|
|
219 |
face_samples_most_frequent,
|
220 |
aligned_faces_folder_store, frames_folder_store,
|
221 |
mse_heatmap_embeddings_store, mse_heatmap_posture_store, mse_heatmap_voice_store,
|
222 |
-
stacked_heatmap_plot
|
223 |
]
|
224 |
).then(
|
225 |
show_results,
|
|
|
12 |
print("Starting video processing...")
|
13 |
results = process_video(video_input_path, anomaly_threshold_input, fps, progress=progress)
|
14 |
print("Video processing completed.")
|
15 |
+
|
16 |
if isinstance(results[0], str) and results[0].startswith("Error"):
|
17 |
print(f"Error occurred: {results[0]}")
|
18 |
+
return [results[0]] + [None] * 27 # Increased to 27 to account for the new audio waveform plot
|
19 |
+
|
20 |
exec_time, results_summary, df, mse_embeddings, mse_posture, mse_voice, \
|
21 |
mse_plot_embeddings, mse_plot_posture, mse_plot_voice, \
|
22 |
mse_histogram_embeddings, mse_histogram_posture, mse_histogram_voice, \
|
|
|
24 |
face_samples_frequent, \
|
25 |
anomaly_faces_embeddings, anomaly_frames_posture_images, \
|
26 |
aligned_faces_folder, frames_folder, \
|
27 |
+
stacked_heatmap, audio_waveform_plot = results
|
28 |
+
|
29 |
anomaly_faces_embeddings_pil = [Image.fromarray(face) for face in anomaly_faces_embeddings] if anomaly_faces_embeddings is not None else []
|
30 |
anomaly_frames_posture_pil = [Image.fromarray(frame) for frame in anomaly_frames_posture_images] if anomaly_frames_posture_images is not None else []
|
|
|
31 |
face_samples_frequent = [Image.open(path) for path in face_samples_frequent] if face_samples_frequent is not None else []
|
32 |
+
|
33 |
output = [
|
34 |
exec_time, results_summary,
|
35 |
df, mse_embeddings, mse_posture, mse_voice,
|
|
|
40 |
face_samples_frequent,
|
41 |
aligned_faces_folder, frames_folder,
|
42 |
mse_embeddings, mse_posture, mse_voice,
|
43 |
+
stacked_heatmap,
|
44 |
+
audio_waveform_plot
|
45 |
]
|
|
|
46 |
return output
|
47 |
+
|
48 |
except Exception as e:
|
49 |
error_message = f"An error occurred: {str(e)}"
|
50 |
print(error_message)
|
51 |
import traceback
|
52 |
traceback.print_exc()
|
53 |
+
return [error_message] + [None] * 26
|
54 |
|
55 |
def show_results(outputs):
|
56 |
return gr.Group(visible=True)
|
|
|
92 |
anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
|
93 |
|
94 |
with gr.TabItem("Voice"):
|
95 |
+
audio_waveform_plot = gr.Plot(label="Audio Waveform")
|
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")
|
|
|
219 |
face_samples_most_frequent,
|
220 |
aligned_faces_folder_store, frames_folder_store,
|
221 |
mse_heatmap_embeddings_store, mse_heatmap_posture_store, mse_heatmap_voice_store,
|
222 |
+
audio_waveform_plot, stacked_heatmap_plot
|
223 |
]
|
224 |
).then(
|
225 |
show_results,
|