Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,22 +15,22 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 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 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
|
| 30 |
-
anomaly_faces_embeddings_pil = [Image.fromarray(face) for face in anomaly_faces_embeddings]
|
| 31 |
-
anomaly_frames_posture_pil = [Image.fromarray(frame) for frame in anomaly_frames_posture_images]
|
| 32 |
|
| 33 |
-
face_samples_frequent = [Image.open(path) for path in face_samples_frequent]
|
| 34 |
|
| 35 |
output = [
|
| 36 |
exec_time, results_summary,
|
|
@@ -42,7 +42,7 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 42 |
face_samples_frequent,
|
| 43 |
aligned_faces_folder, frames_folder,
|
| 44 |
mse_embeddings, mse_posture,
|
| 45 |
-
|
| 46 |
]
|
| 47 |
|
| 48 |
return output
|
|
@@ -52,7 +52,7 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 52 |
print(error_message)
|
| 53 |
import traceback
|
| 54 |
traceback.print_exc()
|
| 55 |
-
return [error_message] + [None] *
|
| 56 |
|
| 57 |
with gr.Blocks() as iface:
|
| 58 |
gr.Markdown("""
|
|
@@ -91,7 +91,9 @@ with gr.Blocks() as iface:
|
|
| 91 |
mse_voice_plot = gr.Plot(label="MSE: Voice")
|
| 92 |
mse_voice_hist = gr.Plot(label="MSE Distribution: Voice")
|
| 93 |
mse_voice_heatmap = gr.Plot(label="MSE Heatmap: Voice")
|
| 94 |
-
|
|
|
|
|
|
|
| 95 |
|
| 96 |
df_store = gr.State()
|
| 97 |
mse_features_store = gr.State()
|
|
@@ -114,7 +116,7 @@ with gr.Blocks() as iface:
|
|
| 114 |
face_samples_most_frequent,
|
| 115 |
aligned_faces_folder_store, frames_folder_store,
|
| 116 |
mse_heatmap_embeddings_store, mse_heatmap_posture_store,
|
| 117 |
-
|
| 118 |
]
|
| 119 |
).then(
|
| 120 |
lambda: gr.Group(visible=True),
|
|
|
|
| 15 |
|
| 16 |
if isinstance(results[0], str) and results[0].startswith("Error"):
|
| 17 |
print(f"Error occurred: {results[0]}")
|
| 18 |
+
return [results[0]] + [None] * 18 # Increased by 1 for the new heatmap video
|
| 19 |
|
| 20 |
+
exec_time, results_summary, df, mse_embeddings, mse_posture, \
|
| 21 |
+
mse_plot_embeddings, mse_histogram_embeddings, \
|
| 22 |
+
mse_plot_posture, mse_histogram_posture, \
|
| 23 |
+
mse_heatmap_embeddings, mse_heatmap_posture, \
|
| 24 |
+
mse_voice, mse_plot_voice, mse_histogram_voice, mse_heatmap_voice, \
|
| 25 |
+
face_samples_frequent, \
|
| 26 |
+
anomaly_faces_embeddings, anomaly_frames_posture_images, \
|
| 27 |
+
aligned_faces_folder, frames_folder, \
|
| 28 |
+
heatmap_video_path = 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 = [
|
| 36 |
exec_time, results_summary,
|
|
|
|
| 42 |
face_samples_frequent,
|
| 43 |
aligned_faces_folder, frames_folder,
|
| 44 |
mse_embeddings, mse_posture,
|
| 45 |
+
heatmap_video_path
|
| 46 |
]
|
| 47 |
|
| 48 |
return output
|
|
|
|
| 52 |
print(error_message)
|
| 53 |
import traceback
|
| 54 |
traceback.print_exc()
|
| 55 |
+
return [error_message] + [None] * 18 # Increased by 1 for the new heatmap video
|
| 56 |
|
| 57 |
with gr.Blocks() as iface:
|
| 58 |
gr.Markdown("""
|
|
|
|
| 91 |
mse_voice_plot = gr.Plot(label="MSE: Voice")
|
| 92 |
mse_voice_hist = gr.Plot(label="MSE Distribution: Voice")
|
| 93 |
mse_voice_heatmap = gr.Plot(label="MSE Heatmap: Voice")
|
| 94 |
+
|
| 95 |
+
with gr.Tab("Video with Heatmap"):
|
| 96 |
+
heatmap_video = gr.Video(label="Video with Anomaly Heatmap")
|
| 97 |
|
| 98 |
df_store = gr.State()
|
| 99 |
mse_features_store = gr.State()
|
|
|
|
| 116 |
face_samples_most_frequent,
|
| 117 |
aligned_faces_folder_store, frames_folder_store,
|
| 118 |
mse_heatmap_embeddings_store, mse_heatmap_posture_store,
|
| 119 |
+
heatmap_video
|
| 120 |
]
|
| 121 |
).then(
|
| 122 |
lambda: gr.Group(visible=True),
|