Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,11 +13,11 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 13 |
print("Starting video processing...")
|
| 14 |
results = process_video(video_input_path, anomaly_threshold_input, fps, progress=progress)
|
| 15 |
print("Video processing completed.")
|
| 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 |
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, \
|
|
@@ -26,24 +26,12 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 26 |
anomaly_faces_embeddings, anomaly_frames_posture_images, \
|
| 27 |
aligned_faces_folder, frames_folder, \
|
| 28 |
stacked_heatmap, audio_waveform_plot = results
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
print(f"Warning: Expected image data, got string: {image_data[:100]}...") # Print first 100 chars
|
| 36 |
-
return None
|
| 37 |
-
else:
|
| 38 |
-
print(f"Warning: Unexpected data type for image: {type(image_data)}")
|
| 39 |
-
return None
|
| 40 |
-
|
| 41 |
-
anomaly_faces_embeddings_pil = [safe_image_conversion(face) for face in anomaly_faces_embeddings] if isinstance(anomaly_faces_embeddings, list) else []
|
| 42 |
-
anomaly_frames_posture_pil = [safe_image_conversion(frame) for frame in anomaly_frames_posture_images] if isinstance(anomaly_frames_posture_images, list) else []
|
| 43 |
-
|
| 44 |
-
# For face_samples_frequent, we're expecting paths, so we'll keep it as is
|
| 45 |
-
face_samples_frequent = [Image.open(path) for path in face_samples_frequent] if isinstance(face_samples_frequent, list) else []
|
| 46 |
-
|
| 47 |
output = [
|
| 48 |
exec_time, results_summary,
|
| 49 |
df, mse_embeddings, mse_posture, mse_voice,
|
|
@@ -54,11 +42,11 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
| 54 |
face_samples_frequent,
|
| 55 |
aligned_faces_folder, frames_folder,
|
| 56 |
mse_embeddings, mse_posture, mse_voice,
|
| 57 |
-
stacked_heatmap,
|
| 58 |
-
audio_waveform_plot
|
| 59 |
]
|
|
|
|
| 60 |
return output
|
| 61 |
-
|
| 62 |
except Exception as e:
|
| 63 |
error_message = f"An error occurred: {str(e)}"
|
| 64 |
print(error_message)
|
|
|
|
| 13 |
print("Starting video processing...")
|
| 14 |
results = process_video(video_input_path, anomaly_threshold_input, fps, progress=progress)
|
| 15 |
print("Video processing completed.")
|
| 16 |
+
|
| 17 |
if isinstance(results[0], str) and results[0].startswith("Error"):
|
| 18 |
print(f"Error occurred: {results[0]}")
|
| 19 |
+
return [results[0]] + [None] * 26
|
| 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, \
|
|
|
|
| 26 |
anomaly_faces_embeddings, anomaly_frames_posture_images, \
|
| 27 |
aligned_faces_folder, frames_folder, \
|
| 28 |
stacked_heatmap, audio_waveform_plot = 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,
|
| 37 |
df, mse_embeddings, mse_posture, mse_voice,
|
|
|
|
| 42 |
face_samples_frequent,
|
| 43 |
aligned_faces_folder, frames_folder,
|
| 44 |
mse_embeddings, mse_posture, mse_voice,
|
| 45 |
+
stacked_heatmap, audio_waveform_plot
|
|
|
|
| 46 |
]
|
| 47 |
+
|
| 48 |
return output
|
| 49 |
+
|
| 50 |
except Exception as e:
|
| 51 |
error_message = f"An error occurred: {str(e)}"
|
| 52 |
print(error_message)
|