Update app.py
Browse files
app.py
CHANGED
@@ -31,6 +31,12 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
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,7 +47,8 @@ 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 |
-
heatmap_video_path
|
|
|
45 |
]
|
46 |
|
47 |
return output
|
@@ -51,7 +58,7 @@ 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] *
|
55 |
|
56 |
def show_results(outputs):
|
57 |
return gr.Group(visible=True)
|
@@ -97,6 +104,8 @@ with gr.Blocks() as iface:
|
|
97 |
|
98 |
with gr.TabItem("Video with Heatmap"):
|
99 |
heatmap_video = gr.Video(label="Video with Anomaly Heatmap")
|
|
|
|
|
100 |
|
101 |
df_store = gr.State()
|
102 |
mse_features_store = gr.State()
|
@@ -107,7 +116,7 @@ with gr.Blocks() as iface:
|
|
107 |
mse_heatmap_embeddings_store = gr.State()
|
108 |
mse_heatmap_posture_store = gr.State()
|
109 |
mse_heatmap_voice_store = gr.State()
|
110 |
-
|
111 |
process_btn.click(
|
112 |
process_and_show_completion,
|
113 |
inputs=[video_input, anomaly_threshold, fps_slider],
|
@@ -121,7 +130,7 @@ with gr.Blocks() as iface:
|
|
121 |
face_samples_most_frequent,
|
122 |
aligned_faces_folder_store, frames_folder_store,
|
123 |
mse_heatmap_embeddings_store, mse_heatmap_posture_store, mse_heatmap_voice_store,
|
124 |
-
heatmap_video
|
125 |
]
|
126 |
).then(
|
127 |
show_results,
|
|
|
31 |
|
32 |
face_samples_frequent = [Image.open(path) for path in face_samples_frequent] if face_samples_frequent is not None else []
|
33 |
|
34 |
+
# Generate the correlation heatmap
|
35 |
+
correlation_heatmap = plot_correlation_heatmap(mse_embeddings, mse_posture, mse_voice)
|
36 |
+
|
37 |
+
# Generate the 3D scatter plot
|
38 |
+
scatter_plot_3d = plot_3d_scatter(mse_embeddings, mse_posture, mse_voice)
|
39 |
+
|
40 |
output = [
|
41 |
exec_time, results_summary,
|
42 |
df, mse_embeddings, mse_posture, mse_voice,
|
|
|
47 |
face_samples_frequent,
|
48 |
aligned_faces_folder, frames_folder,
|
49 |
mse_embeddings, mse_posture, mse_voice,
|
50 |
+
heatmap_video_path,
|
51 |
+
correlation_heatmap, scatter_plot_3d
|
52 |
]
|
53 |
|
54 |
return output
|
|
|
58 |
print(error_message)
|
59 |
import traceback
|
60 |
traceback.print_exc()
|
61 |
+
return [error_message] + [None] * 25
|
62 |
|
63 |
def show_results(outputs):
|
64 |
return gr.Group(visible=True)
|
|
|
104 |
|
105 |
with gr.TabItem("Video with Heatmap"):
|
106 |
heatmap_video = gr.Video(label="Video with Anomaly Heatmap")
|
107 |
+
correlation_heatmap_plot = gr.Plot(label="Correlation Heatmap")
|
108 |
+
scatter_plot_3d_plot = gr.Plot(label="3D Scatter Plot of MSEs")
|
109 |
|
110 |
df_store = gr.State()
|
111 |
mse_features_store = gr.State()
|
|
|
116 |
mse_heatmap_embeddings_store = gr.State()
|
117 |
mse_heatmap_posture_store = gr.State()
|
118 |
mse_heatmap_voice_store = gr.State()
|
119 |
+
|
120 |
process_btn.click(
|
121 |
process_and_show_completion,
|
122 |
inputs=[video_input, anomaly_threshold, fps_slider],
|
|
|
130 |
face_samples_most_frequent,
|
131 |
aligned_faces_folder_store, frames_folder_store,
|
132 |
mse_heatmap_embeddings_store, mse_heatmap_posture_store, mse_heatmap_voice_store,
|
133 |
+
heatmap_video, correlation_heatmap_plot, scatter_plot_3d_plot # Add these plots to the outputs
|
134 |
]
|
135 |
).then(
|
136 |
show_results,
|