Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,6 @@ import time
|
|
| 3 |
from video_processing import process_video
|
| 4 |
from PIL import Image
|
| 5 |
import matplotlib
|
| 6 |
-
|
| 7 |
matplotlib.rcParams['figure.dpi'] = 500
|
| 8 |
matplotlib.rcParams['savefig.dpi'] = 500
|
| 9 |
|
|
@@ -15,7 +14,7 @@ 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 |
exec_time, results_summary, df, mse_embeddings, mse_posture, \
|
| 21 |
mse_plot_embeddings, mse_histogram_embeddings, \
|
|
@@ -30,7 +29,7 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 30 |
|
| 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 |
output = [
|
| 35 |
exec_time, results_summary,
|
| 36 |
df, mse_embeddings, mse_posture,
|
|
@@ -40,7 +39,7 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 40 |
anomaly_faces_embeddings_pil, anomaly_frames_posture_pil,
|
| 41 |
face_samples_frequent, face_samples_other,
|
| 42 |
aligned_faces_folder, frames_folder,
|
| 43 |
-
mse_embeddings, mse_posture
|
| 44 |
]
|
| 45 |
|
| 46 |
return output
|
|
@@ -50,14 +49,17 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 50 |
print(error_message)
|
| 51 |
import traceback
|
| 52 |
traceback.print_exc()
|
| 53 |
-
return [error_message] + [None] *
|
| 54 |
|
| 55 |
with gr.Blocks() as iface:
|
| 56 |
gr.Markdown("""
|
| 57 |
-
#
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
It
|
|
|
|
|
|
|
|
|
|
| 61 |
""")
|
| 62 |
|
| 63 |
with gr.Row():
|
|
@@ -84,11 +86,6 @@ with gr.Blocks() as iface:
|
|
| 84 |
mse_posture_heatmap = gr.Plot(label="MSE Heatmap: Body Posture")
|
| 85 |
anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
|
| 86 |
|
| 87 |
-
with gr.Tab("Combined"):
|
| 88 |
-
with gr.Row():
|
| 89 |
-
kde_plot = gr.Plot(label="KDE Plot: Facial Features vs Body Posture MSE")
|
| 90 |
-
joint_plot = gr.Plot(label="Joint Plot: Facial Features vs Body Posture MSE")
|
| 91 |
-
|
| 92 |
with gr.Tab("Face Samples"):
|
| 93 |
face_samples_most_frequent = gr.Gallery(label="Most Frequent Person Samples (Target)", columns=6, rows=2, height="auto")
|
| 94 |
face_samples_others = gr.Gallery(label="Other Persons Samples", columns=6, rows=1, height="auto")
|
|
|
|
| 3 |
from video_processing import process_video
|
| 4 |
from PIL import Image
|
| 5 |
import matplotlib
|
|
|
|
| 6 |
matplotlib.rcParams['figure.dpi'] = 500
|
| 7 |
matplotlib.rcParams['savefig.dpi'] = 500
|
| 8 |
|
|
|
|
| 14 |
|
| 15 |
if isinstance(results[0], str) and results[0].startswith("Error"):
|
| 16 |
print(f"Error occurred: {results[0]}")
|
| 17 |
+
return [results[0]] + [None] * 18
|
| 18 |
|
| 19 |
exec_time, results_summary, df, mse_embeddings, mse_posture, \
|
| 20 |
mse_plot_embeddings, mse_histogram_embeddings, \
|
|
|
|
| 29 |
|
| 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,
|
|
|
|
| 39 |
anomaly_faces_embeddings_pil, anomaly_frames_posture_pil,
|
| 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("""
|
| 56 |
+
# Facial Expression and Body Language Anomaly Detection
|
| 57 |
+
|
| 58 |
+
This application analyzes videos to detect anomalies in facial features and body language.
|
| 59 |
+
It processes the video frames to extract facial embeddings and body posture,
|
| 60 |
+
then uses machine learning techniques to identify unusual patterns or deviations from the norm.
|
| 61 |
+
|
| 62 |
+
For more information, visit: [https://github.com/reab5555/Facial-Expression-Anomaly-Detection](https://github.com/reab5555/Facial-Expression-Anomaly-Detection)
|
| 63 |
""")
|
| 64 |
|
| 65 |
with gr.Row():
|
|
|
|
| 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")
|