reab5555 commited on
Commit
5f2afd5
·
verified ·
1 Parent(s): 8a1e5c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -5
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 # Increased to 27 to account for the new audio waveform plot
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
- 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
- face_samples_frequent = [Image.open(path) for path in face_samples_frequent] if face_samples_frequent is not None else []
 
 
 
 
 
 
 
 
 
 
 
 
 
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)