Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,24 +16,20 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 16 |
|
| 17 |
if isinstance(results[0], str) and results[0].startswith("Error"):
|
| 18 |
print(f"Error occurred: {results[0]}")
|
| 19 |
-
return [results[0]] + [None] *
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
stacked_heatmap
|
| 30 |
-
) = results
|
| 31 |
|
| 32 |
-
# Convert numpy arrays to PIL Images
|
| 33 |
anomaly_faces_embeddings_pil = [Image.fromarray(face) for face in anomaly_faces_embeddings] if anomaly_faces_embeddings is not None else []
|
| 34 |
anomaly_frames_posture_pil = [Image.fromarray(frame) for frame in anomaly_frames_posture_images] if anomaly_frames_posture_images is not None else []
|
| 35 |
|
| 36 |
-
# Load face samples
|
| 37 |
face_samples_frequent = [Image.open(path) for path in face_samples_frequent] if face_samples_frequent is not None else []
|
| 38 |
|
| 39 |
output = [
|
|
@@ -46,7 +42,8 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 46 |
face_samples_frequent,
|
| 47 |
aligned_faces_folder, frames_folder,
|
| 48 |
mse_embeddings, mse_posture, mse_voice,
|
| 49 |
-
stacked_heatmap
|
|
|
|
| 50 |
]
|
| 51 |
|
| 52 |
return output
|
|
@@ -56,7 +53,7 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 56 |
print(error_message)
|
| 57 |
import traceback
|
| 58 |
traceback.print_exc()
|
| 59 |
-
return [error_message] + [None] *
|
| 60 |
|
| 61 |
def show_results(outputs):
|
| 62 |
return gr.Group(visible=True)
|
|
@@ -98,7 +95,6 @@ with gr.Blocks() as iface:
|
|
| 98 |
anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
|
| 99 |
|
| 100 |
with gr.TabItem("Voice"):
|
| 101 |
-
audio_waveform_plot = gr.Plot(label="Audio Waveform")
|
| 102 |
mse_voice_plot = gr.Plot(label="MSE: Voice")
|
| 103 |
mse_voice_hist = gr.Plot(label="MSE Distribution: Voice")
|
| 104 |
mse_voice_heatmap = gr.Plot(label="MSE Heatmap: Voice")
|
|
@@ -225,7 +221,7 @@ with gr.Blocks() as iface:
|
|
| 225 |
face_samples_most_frequent,
|
| 226 |
aligned_faces_folder_store, frames_folder_store,
|
| 227 |
mse_heatmap_embeddings_store, mse_heatmap_posture_store, mse_heatmap_voice_store,
|
| 228 |
-
|
| 229 |
]
|
| 230 |
).then(
|
| 231 |
show_results,
|
|
|
|
| 16 |
|
| 17 |
if isinstance(results[0], str) and results[0].startswith("Error"):
|
| 18 |
print(f"Error occurred: {results[0]}")
|
| 19 |
+
return [results[0]] + [None] * 25
|
| 20 |
|
| 21 |
+
exec_time, results_summary, df, mse_embeddings, mse_posture, mse_voice, \
|
| 22 |
+
mse_plot_embeddings, mse_plot_posture, mse_plot_voice, \
|
| 23 |
+
mse_histogram_embeddings, mse_histogram_posture, mse_histogram_voice, \
|
| 24 |
+
mse_heatmap_embeddings, mse_heatmap_posture, mse_heatmap_voice, \
|
| 25 |
+
face_samples_frequent, \
|
| 26 |
+
anomaly_faces_embeddings, anomaly_frames_posture_images, \
|
| 27 |
+
aligned_faces_folder, frames_folder, \
|
| 28 |
+
stacked_heatmap = results
|
|
|
|
|
|
|
| 29 |
|
|
|
|
| 30 |
anomaly_faces_embeddings_pil = [Image.fromarray(face) for face in anomaly_faces_embeddings] if anomaly_faces_embeddings is not None else []
|
| 31 |
anomaly_frames_posture_pil = [Image.fromarray(frame) for frame in anomaly_frames_posture_images] if anomaly_frames_posture_images is not None else []
|
| 32 |
|
|
|
|
| 33 |
face_samples_frequent = [Image.open(path) for path in face_samples_frequent] if face_samples_frequent is not None else []
|
| 34 |
|
| 35 |
output = [
|
|
|
|
| 42 |
face_samples_frequent,
|
| 43 |
aligned_faces_folder, frames_folder,
|
| 44 |
mse_embeddings, mse_posture, mse_voice,
|
| 45 |
+
stacked_heatmap
|
| 46 |
+
|
| 47 |
]
|
| 48 |
|
| 49 |
return output
|
|
|
|
| 53 |
print(error_message)
|
| 54 |
import traceback
|
| 55 |
traceback.print_exc()
|
| 56 |
+
return [error_message] + [None] * 25
|
| 57 |
|
| 58 |
def show_results(outputs):
|
| 59 |
return gr.Group(visible=True)
|
|
|
|
| 95 |
anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
|
| 96 |
|
| 97 |
with gr.TabItem("Voice"):
|
|
|
|
| 98 |
mse_voice_plot = gr.Plot(label="MSE: Voice")
|
| 99 |
mse_voice_hist = gr.Plot(label="MSE Distribution: Voice")
|
| 100 |
mse_voice_heatmap = gr.Plot(label="MSE Heatmap: Voice")
|
|
|
|
| 221 |
face_samples_most_frequent,
|
| 222 |
aligned_faces_folder_store, frames_folder_store,
|
| 223 |
mse_heatmap_embeddings_store, mse_heatmap_posture_store, mse_heatmap_voice_store,
|
| 224 |
+
stacked_heatmap_plot
|
| 225 |
]
|
| 226 |
).then(
|
| 227 |
show_results,
|