Update video_processing.py
Browse files- video_processing.py +17 -31
video_processing.py
CHANGED
@@ -167,41 +167,27 @@ def process_video(video_path, anomaly_threshold, desired_fps, progress=None):
|
|
167 |
video.export(audio_path, format="wav")
|
168 |
|
169 |
# Process audio
|
170 |
-
most_frequent_voice, voice_features, voice_clusters = process_audio(audio_path)
|
171 |
|
172 |
if len(voice_features) < 2:
|
173 |
print("Not enough voice segments for processing. Skipping voice analysis.")
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
mse_plot_embeddings, anomaly_frames_embeddings = plot_mse(df, mse_embeddings, "Facial Features",
|
184 |
-
color=GRAPH_COLORS['facial_embeddings'],
|
185 |
-
anomaly_threshold=anomaly_threshold)
|
186 |
-
mse_histogram_embeddings = plot_mse_histogram(mse_embeddings, "MSE Distribution: Facial Features",
|
187 |
-
anomaly_threshold, color=GRAPH_COLORS['facial_embeddings'])
|
188 |
-
mse_heatmap_embeddings = plot_mse_heatmap(mse_embeddings, "Facial Features MSE Heatmap", df)
|
189 |
-
|
190 |
-
# Generate plots for body posture
|
191 |
-
mse_plot_posture, anomaly_frames_posture = plot_mse(df, mse_posture, "Body Posture",
|
192 |
-
color=GRAPH_COLORS['body_posture'],
|
193 |
-
anomaly_threshold=anomaly_threshold)
|
194 |
-
mse_histogram_posture = plot_mse_histogram(mse_posture, "MSE Distribution: Body Posture",
|
195 |
-
anomaly_threshold, color=GRAPH_COLORS['body_posture'])
|
196 |
-
mse_heatmap_posture = plot_mse_heatmap(mse_posture, "Body Posture MSE Heatmap", df)
|
197 |
-
|
198 |
-
# Generate plots for voice
|
199 |
-
mse_plot_voice, anomaly_segments_voice = plot_mse(df, mse_voice, "Voice",
|
200 |
-
color='green',
|
201 |
-
anomaly_threshold=anomaly_threshold)
|
202 |
-
mse_histogram_voice = plot_mse_histogram(mse_voice, "MSE Distribution: Voice",
|
203 |
-
anomaly_threshold, color='green')
|
204 |
-
mse_heatmap_voice = plot_mse_heatmap(mse_voice, "Voice MSE Heatmap", df)
|
205 |
|
206 |
except Exception as e:
|
207 |
print(f"Error details: {str(e)}")
|
|
|
167 |
video.export(audio_path, format="wav")
|
168 |
|
169 |
# Process audio
|
170 |
+
most_frequent_voice, voice_features, voice_clusters = process_audio(audio_path, desired_fps, video_duration)
|
171 |
|
172 |
if len(voice_features) < 2:
|
173 |
print("Not enough voice segments for processing. Skipping voice analysis.")
|
174 |
+
mse_voice = None
|
175 |
+
mse_plot_voice = None
|
176 |
+
mse_histogram_voice = None
|
177 |
+
mse_heatmap_voice = None
|
178 |
+
anomaly_segments_voice = None
|
179 |
+
else:
|
180 |
+
# Perform anomaly detection on voice
|
181 |
+
X_voice = np.array(most_frequent_voice)
|
182 |
+
mse_voice = anomaly_detection(X_voice, X_voice)
|
183 |
|
184 |
+
# Generate plots for voice
|
185 |
+
mse_plot_voice, anomaly_segments_voice = plot_mse(df, mse_voice, "Voice",
|
186 |
+
color='green',
|
187 |
+
anomaly_threshold=anomaly_threshold)
|
188 |
+
mse_histogram_voice = plot_mse_histogram(mse_voice, "MSE Distribution: Voice",
|
189 |
+
anomaly_threshold, color='green')
|
190 |
+
mse_heatmap_voice = plot_mse_heatmap(mse_voice, "Voice MSE Heatmap", df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
|
192 |
except Exception as e:
|
193 |
print(f"Error details: {str(e)}")
|