Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,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] * 27
|
19 |
|
20 |
exec_time, results_summary, df, mse_embeddings, mse_posture, mse_voice, \
|
21 |
mse_plot_embeddings, mse_plot_posture, mse_plot_voice, \
|
@@ -26,9 +26,22 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
|
|
26 |
aligned_faces_folder, frames_folder, \
|
27 |
stacked_heatmap, audio_waveform_plot = results
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
output = [
|
34 |
exec_time, results_summary,
|
@@ -50,7 +63,7 @@ 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] * 26
|
54 |
|
55 |
def show_results(outputs):
|
56 |
return 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] * 27
|
19 |
|
20 |
exec_time, results_summary, df, mse_embeddings, mse_posture, mse_voice, \
|
21 |
mse_plot_embeddings, mse_plot_posture, mse_plot_voice, \
|
|
|
26 |
aligned_faces_folder, frames_folder, \
|
27 |
stacked_heatmap, audio_waveform_plot = results
|
28 |
|
29 |
+
# Handle potential string values for image data
|
30 |
+
def safe_image_conversion(image_data):
|
31 |
+
if isinstance(image_data, np.ndarray):
|
32 |
+
return Image.fromarray(image_data)
|
33 |
+
elif isinstance(image_data, str):
|
34 |
+
print(f"Warning: Expected image data, got string: {image_data[:100]}...") # Print first 100 chars
|
35 |
+
return None
|
36 |
+
else:
|
37 |
+
print(f"Warning: Unexpected data type for image: {type(image_data)}")
|
38 |
+
return None
|
39 |
+
|
40 |
+
anomaly_faces_embeddings_pil = [safe_image_conversion(face) for face in anomaly_faces_embeddings] if isinstance(anomaly_faces_embeddings, list) else []
|
41 |
+
anomaly_frames_posture_pil = [safe_image_conversion(frame) for frame in anomaly_frames_posture_images] if isinstance(anomaly_frames_posture_images, list) else []
|
42 |
+
|
43 |
+
# For face_samples_frequent, we're expecting paths, so we'll keep it as is
|
44 |
+
face_samples_frequent = [Image.open(path) for path in face_samples_frequent] if isinstance(face_samples_frequent, list) else []
|
45 |
|
46 |
output = [
|
47 |
exec_time, results_summary,
|
|
|
63 |
print(error_message)
|
64 |
import traceback
|
65 |
traceback.print_exc()
|
66 |
+
return [error_message] + [None] * 26
|
67 |
|
68 |
def show_results(outputs):
|
69 |
return gr.Group(visible=True)
|