Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,8 +22,7 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 22 |
mse_heatmap_embeddings, mse_heatmap_posture, \
|
| 23 |
face_samples_frequent, face_samples_other, \
|
| 24 |
anomaly_faces_embeddings, anomaly_frames_posture_images, \
|
| 25 |
-
aligned_faces_folder, frames_folder
|
| 26 |
-
anomaly_sentences_features, anomaly_sentences_posture = results
|
| 27 |
|
| 28 |
anomaly_faces_embeddings_pil = [Image.fromarray(face) for face in anomaly_faces_embeddings]
|
| 29 |
anomaly_frames_posture_pil = [Image.fromarray(frame) for frame in anomaly_frames_posture_images]
|
|
@@ -31,12 +30,6 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 31 |
face_samples_frequent = [Image.open(path) for path in face_samples_frequent]
|
| 32 |
face_samples_other = [Image.open(path) for path in face_samples_other]
|
| 33 |
|
| 34 |
-
anomaly_sentences_features, anomaly_sentences_posture = results[-2:]
|
| 35 |
-
|
| 36 |
-
# Format anomaly sentences output
|
| 37 |
-
sentences_features_output = format_anomaly_sentences(anomaly_sentences_features, "Facial Features")
|
| 38 |
-
sentences_posture_output = format_anomaly_sentences(anomaly_sentences_posture, "Body Posture")
|
| 39 |
-
|
| 40 |
output = [
|
| 41 |
exec_time, results_summary,
|
| 42 |
df, mse_embeddings, mse_posture,
|
|
@@ -47,7 +40,6 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 47 |
face_samples_frequent, face_samples_other,
|
| 48 |
aligned_faces_folder, frames_folder,
|
| 49 |
mse_embeddings, mse_posture,
|
| 50 |
-
sentences_features_output, sentences_posture_output
|
| 51 |
]
|
| 52 |
|
| 53 |
return output
|
|
@@ -57,7 +49,7 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 57 |
print(error_message)
|
| 58 |
import traceback
|
| 59 |
traceback.print_exc()
|
| 60 |
-
return [error_message] + [None] *
|
| 61 |
|
| 62 |
with gr.Blocks() as iface:
|
| 63 |
gr.Markdown("""
|
|
@@ -94,18 +86,6 @@ with gr.Blocks() as iface:
|
|
| 94 |
mse_posture_heatmap = gr.Plot(label="MSE Heatmap: Body Posture")
|
| 95 |
anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
|
| 96 |
|
| 97 |
-
with gr.Tab("Sentences"):
|
| 98 |
-
with gr.Row():
|
| 99 |
-
anomaly_sentences_features_output = gr.Textbox(label="Sentences before Facial Feature Anomalies",
|
| 100 |
-
lines=10)
|
| 101 |
-
anomaly_frames_features = gr.Gallery(label="Anomaly Frames (Facial Features)", columns=6, rows=2,
|
| 102 |
-
height="auto")
|
| 103 |
-
|
| 104 |
-
with gr.Row():
|
| 105 |
-
anomaly_sentences_posture_output = gr.Textbox(label="Sentences before Body Posture Anomalies", lines=10)
|
| 106 |
-
anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2,
|
| 107 |
-
height="auto")
|
| 108 |
-
|
| 109 |
with gr.Tab("Face Samples"):
|
| 110 |
face_samples_most_frequent = gr.Gallery(label="Most Frequent Person Samples (Target)", columns=6, rows=2, height="auto")
|
| 111 |
face_samples_others = gr.Gallery(label="Other Persons Samples", columns=6, rows=1, height="auto")
|
|
@@ -139,8 +119,7 @@ with gr.Blocks() as iface:
|
|
| 139 |
anomaly_frames_features, anomaly_frames_posture,
|
| 140 |
face_samples_most_frequent, face_samples_others,
|
| 141 |
aligned_faces_folder_store, frames_folder_store,
|
| 142 |
-
mse_heatmap_embeddings_store, mse_heatmap_posture_store
|
| 143 |
-
anomaly_sentences_features_output, anomaly_sentences_posture_output
|
| 144 |
]
|
| 145 |
).then(
|
| 146 |
lambda: gr.Group(visible=True),
|
|
|
|
| 22 |
mse_heatmap_embeddings, mse_heatmap_posture, \
|
| 23 |
face_samples_frequent, face_samples_other, \
|
| 24 |
anomaly_faces_embeddings, anomaly_frames_posture_images, \
|
| 25 |
+
aligned_faces_folder, frames_folder = results
|
|
|
|
| 26 |
|
| 27 |
anomaly_faces_embeddings_pil = [Image.fromarray(face) for face in anomaly_faces_embeddings]
|
| 28 |
anomaly_frames_posture_pil = [Image.fromarray(frame) for frame in anomaly_frames_posture_images]
|
|
|
|
| 30 |
face_samples_frequent = [Image.open(path) for path in face_samples_frequent]
|
| 31 |
face_samples_other = [Image.open(path) for path in face_samples_other]
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
output = [
|
| 34 |
exec_time, results_summary,
|
| 35 |
df, mse_embeddings, mse_posture,
|
|
|
|
| 40 |
face_samples_frequent, face_samples_other,
|
| 41 |
aligned_faces_folder, frames_folder,
|
| 42 |
mse_embeddings, mse_posture,
|
|
|
|
| 43 |
]
|
| 44 |
|
| 45 |
return output
|
|
|
|
| 49 |
print(error_message)
|
| 50 |
import traceback
|
| 51 |
traceback.print_exc()
|
| 52 |
+
return [error_message] + [None] * 18
|
| 53 |
|
| 54 |
with gr.Blocks() as iface:
|
| 55 |
gr.Markdown("""
|
|
|
|
| 86 |
mse_posture_heatmap = gr.Plot(label="MSE Heatmap: Body Posture")
|
| 87 |
anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
with gr.Tab("Face Samples"):
|
| 90 |
face_samples_most_frequent = gr.Gallery(label="Most Frequent Person Samples (Target)", columns=6, rows=2, height="auto")
|
| 91 |
face_samples_others = gr.Gallery(label="Other Persons Samples", columns=6, rows=1, height="auto")
|
|
|
|
| 119 |
anomaly_frames_features, anomaly_frames_posture,
|
| 120 |
face_samples_most_frequent, face_samples_others,
|
| 121 |
aligned_faces_folder_store, frames_folder_store,
|
| 122 |
+
mse_heatmap_embeddings_store, mse_heatmap_posture_store
|
|
|
|
| 123 |
]
|
| 124 |
).then(
|
| 125 |
lambda: gr.Group(visible=True),
|