Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,50 @@ matplotlib.rcParams['figure.dpi'] = 300
|
|
| 8 |
matplotlib.rcParams['savefig.dpi'] = 300
|
| 9 |
|
| 10 |
def process_and_show_completion(video_input_path, anomaly_threshold_input, fps, progress=gr.Progress()):
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
def show_results(outputs):
|
| 14 |
return [gr.Tab.update(visible=True) for _ in range(4)] + [gr.Tab.update(visible=False)], gr.Group(visible=True)
|
|
|
|
| 8 |
matplotlib.rcParams['savefig.dpi'] = 300
|
| 9 |
|
| 10 |
def process_and_show_completion(video_input_path, anomaly_threshold_input, fps, progress=gr.Progress()):
|
| 11 |
+
try:
|
| 12 |
+
print("Starting video processing...")
|
| 13 |
+
results = process_video(video_input_path, anomaly_threshold_input, fps, progress=progress)
|
| 14 |
+
print("Video processing completed.")
|
| 15 |
+
|
| 16 |
+
if isinstance(results[0], str) and results[0].startswith("Error"):
|
| 17 |
+
print(f"Error occurred: {results[0]}")
|
| 18 |
+
return [results[0]] + [None] * 27
|
| 19 |
+
|
| 20 |
+
exec_time, results_summary, df, mse_embeddings, mse_posture, mse_voice, \
|
| 21 |
+
mse_plot_embeddings, mse_plot_posture, mse_plot_voice, \
|
| 22 |
+
mse_histogram_embeddings, mse_histogram_posture, mse_histogram_voice, \
|
| 23 |
+
mse_heatmap_embeddings, mse_heatmap_posture, mse_heatmap_voice, \
|
| 24 |
+
face_samples_frequent, \
|
| 25 |
+
anomaly_faces_embeddings, anomaly_frames_posture_images, \
|
| 26 |
+
aligned_faces_folder, frames_folder, \
|
| 27 |
+
heatmap_video_path, combined_mse_plot, correlation_heatmap = results
|
| 28 |
+
|
| 29 |
+
anomaly_faces_embeddings_pil = [Image.fromarray(face) for face in anomaly_faces_embeddings] if anomaly_faces_embeddings is not None else []
|
| 30 |
+
anomaly_frames_posture_pil = [Image.fromarray(frame) for frame in anomaly_frames_posture_images] if anomaly_frames_posture_images is not None else []
|
| 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,
|
| 37 |
+
mse_plot_embeddings, mse_plot_posture, mse_plot_voice,
|
| 38 |
+
mse_histogram_embeddings, mse_histogram_posture, mse_histogram_voice,
|
| 39 |
+
mse_heatmap_embeddings, mse_heatmap_posture, mse_heatmap_voice,
|
| 40 |
+
anomaly_faces_embeddings_pil, anomaly_frames_posture_pil,
|
| 41 |
+
face_samples_frequent,
|
| 42 |
+
aligned_faces_folder, frames_folder,
|
| 43 |
+
mse_embeddings, mse_posture, mse_voice,
|
| 44 |
+
heatmap_video_path, combined_mse_plot, correlation_heatmap
|
| 45 |
+
]
|
| 46 |
+
|
| 47 |
+
return output
|
| 48 |
+
|
| 49 |
+
except Exception as e:
|
| 50 |
+
error_message = f"An error occurred: {str(e)}"
|
| 51 |
+
print(error_message)
|
| 52 |
+
import traceback
|
| 53 |
+
traceback.print_exc()
|
| 54 |
+
return [error_message] + [None] * 27
|
| 55 |
|
| 56 |
def show_results(outputs):
|
| 57 |
return [gr.Tab.update(visible=True) for _ in range(4)] + [gr.Tab.update(visible=False)], gr.Group(visible=True)
|