reab5555 commited on
Commit
80b48eb
·
verified ·
1 Parent(s): 54b13e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -382,6 +382,19 @@ def process_video(video_path, num_anomalies, num_components, desired_fps, batch_
382
  progress(0.8, "Saving person data")
383
  df, largest_cluster = save_person_data_to_csv(embeddings_by_frame, emotions_by_frame, clusters, desired_fps, original_fps, temp_dir, num_components)
384
 
 
 
 
 
 
 
 
 
 
 
 
 
 
385
  progress(0.95, "Generating plots")
386
  try:
387
  anomaly_plot_all = plot_anomaly_scores(df, anomaly_scores_all, top_indices_all, "All Features")
@@ -393,18 +406,6 @@ def process_video(video_path, num_anomalies, num_components, desired_fps, batch_
393
  ]
394
  except Exception as e:
395
  return f"Error generating plots: {str(e)}", None, None, None, None, None, None
396
-
397
- progress(0.95, "Generating plots")
398
- try:
399
- anomaly_plot_all = plot_anomaly_scores(df, anomaly_scores_all, top_indices_all, "All Features")
400
- anomaly_plot_comp = plot_anomaly_scores(df, anomaly_scores_comp, top_indices_comp, "Components Only")
401
- emotion_plots = [
402
- plot_emotion(df, 'fear', num_anomalies, 'lightblue'),
403
- plot_emotion(df, 'sad', num_anomalies, 'lightgreen'),
404
- plot_emotion(df, 'angry', num_anomalies, 'salmon')
405
- ]
406
- except Exception as e:
407
- return f"Error generating plots: {str(e)}", None, None, None, None, None, None
408
 
409
  # Get a random face sample
410
  face_sample = get_random_face_sample(organized_faces_folder, largest_cluster, output_folder)
 
382
  progress(0.8, "Saving person data")
383
  df, largest_cluster = save_person_data_to_csv(embeddings_by_frame, emotions_by_frame, clusters, desired_fps, original_fps, temp_dir, num_components)
384
 
385
+ progress(0.9, "Performing anomaly detection")
386
+ feature_columns = [col for col in df.columns if col not in ['Frame', 'Timecode', 'Time (Minutes)', 'Embedding_Index']]
387
+ X = df[feature_columns].values
388
+ print(f"Shape of input data: {X.shape}")
389
+ print(f"Feature columns: {feature_columns}")
390
+ try:
391
+ anomalies_all, anomaly_scores_all, top_indices_all, anomalies_comp, anomaly_scores_comp, top_indices_comp, _ = lstm_anomaly_detection(X, feature_columns, num_anomalies=num_anomalies, batch_size=batch_size)
392
+ except Exception as e:
393
+ print(f"Error details: {str(e)}")
394
+ print(f"X shape: {X.shape}")
395
+ print(f"X dtype: {X.dtype}")
396
+ return f"Error in anomaly detection: {str(e)}", None, None, None, None, None, None
397
+
398
  progress(0.95, "Generating plots")
399
  try:
400
  anomaly_plot_all = plot_anomaly_scores(df, anomaly_scores_all, top_indices_all, "All Features")
 
406
  ]
407
  except Exception as e:
408
  return f"Error generating plots: {str(e)}", None, None, None, None, None, None
 
 
 
 
 
 
 
 
 
 
 
 
409
 
410
  # Get a random face sample
411
  face_sample = get_random_face_sample(organized_faces_folder, largest_cluster, output_folder)