reab5555 commited on
Commit
6308e28
·
verified ·
1 Parent(s): abc304c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -4
app.py CHANGED
@@ -1,8 +1,10 @@
1
  import gradio as gr
2
  import time
3
  from video_processing import process_video
 
4
  from PIL import Image
5
  import matplotlib
 
6
  matplotlib.rcParams['figure.dpi'] = 500
7
  matplotlib.rcParams['savefig.dpi'] = 500
8
 
@@ -14,7 +16,7 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
14
 
15
  if isinstance(results[0], str) and results[0].startswith("Error"):
16
  print(f"Error occurred: {results[0]}")
17
- return [results[0]] + [None] * 18
18
 
19
  exec_time, results_summary, df, mse_embeddings, mse_posture, \
20
  mse_plot_embeddings, mse_histogram_embeddings, \
@@ -29,7 +31,10 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
29
 
30
  face_samples_frequent = [Image.open(path) for path in face_samples_frequent]
31
  face_samples_other = [Image.open(path) for path in face_samples_other]
32
-
 
 
 
33
  output = [
34
  exec_time, results_summary,
35
  df, mse_embeddings, mse_posture,
@@ -40,6 +45,7 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
40
  face_samples_frequent, face_samples_other,
41
  aligned_faces_folder, frames_folder,
42
  mse_embeddings, mse_posture,
 
43
  ]
44
 
45
  return output
@@ -49,7 +55,7 @@ def process_and_show_completion(video_input_path, anomaly_threshold_input, fps,
49
  print(error_message)
50
  import traceback
51
  traceback.print_exc()
52
- return [error_message] + [None] * 18
53
 
54
  with gr.Blocks() as iface:
55
  gr.Markdown("""
@@ -83,6 +89,11 @@ with gr.Blocks() as iface:
83
  mse_posture_heatmap = gr.Plot(label="MSE Heatmap: Body Posture")
84
  anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
85
 
 
 
 
 
 
86
  with gr.Tab("Face Samples"):
87
  face_samples_most_frequent = gr.Gallery(label="Most Frequent Person Samples (Target)", columns=6, rows=2, height="auto")
88
  face_samples_others = gr.Gallery(label="Other Persons Samples", columns=6, rows=1, height="auto")
@@ -107,7 +118,8 @@ with gr.Blocks() as iface:
107
  anomaly_frames_features, anomaly_frames_posture,
108
  face_samples_most_frequent, face_samples_others,
109
  aligned_faces_folder_store, frames_folder_store,
110
- mse_heatmap_embeddings_store, mse_heatmap_posture_store
 
111
  ]
112
  ).then(
113
  lambda: gr.Group(visible=True),
 
1
  import gradio as gr
2
  import time
3
  from video_processing import process_video
4
+ from visualization import create_kdeplot, create_jointplot
5
  from PIL import Image
6
  import matplotlib
7
+
8
  matplotlib.rcParams['figure.dpi'] = 500
9
  matplotlib.rcParams['savefig.dpi'] = 500
10
 
 
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
20
 
21
  exec_time, results_summary, df, mse_embeddings, mse_posture, \
22
  mse_plot_embeddings, mse_histogram_embeddings, \
 
31
 
32
  face_samples_frequent = [Image.open(path) for path in face_samples_frequent]
33
  face_samples_other = [Image.open(path) for path in face_samples_other]
34
+
35
+ kde_plot = create_kdeplot(df, mse_embeddings, mse_posture)
36
+ joint_plot = create_jointplot(df, mse_embeddings, mse_posture)
37
+
38
  output = [
39
  exec_time, results_summary,
40
  df, mse_embeddings, mse_posture,
 
45
  face_samples_frequent, face_samples_other,
46
  aligned_faces_folder, frames_folder,
47
  mse_embeddings, mse_posture,
48
+ kde_plot, joint_plot
49
  ]
50
 
51
  return output
 
55
  print(error_message)
56
  import traceback
57
  traceback.print_exc()
58
+ return [error_message] + [None] * 20
59
 
60
  with gr.Blocks() as iface:
61
  gr.Markdown("""
 
89
  mse_posture_heatmap = gr.Plot(label="MSE Heatmap: Body Posture")
90
  anomaly_frames_posture = gr.Gallery(label="Anomaly Frames (Body Posture)", columns=6, rows=2, height="auto")
91
 
92
+ with gr.Tab("Combined"):
93
+ with gr.Row():
94
+ kde_plot = gr.Plot(label="KDE Plot: Facial Features vs Body Posture MSE")
95
+ joint_plot = gr.Plot(label="Joint Plot: Facial Features vs Body Posture MSE")
96
+
97
  with gr.Tab("Face Samples"):
98
  face_samples_most_frequent = gr.Gallery(label="Most Frequent Person Samples (Target)", columns=6, rows=2, height="auto")
99
  face_samples_others = gr.Gallery(label="Other Persons Samples", columns=6, rows=1, height="auto")
 
118
  anomaly_frames_features, anomaly_frames_posture,
119
  face_samples_most_frequent, face_samples_others,
120
  aligned_faces_folder_store, frames_folder_store,
121
+ mse_heatmap_embeddings_store, mse_heatmap_posture_store,
122
+ kde_plot, joint_plot
123
  ]
124
  ).then(
125
  lambda: gr.Group(visible=True),