Antonio
commited on
Commit
·
4779bd2
1
Parent(s):
f50e742
Cleaned output labels
Browse files
app.py
CHANGED
@@ -199,25 +199,24 @@ def predict(video_file, video_model_name, audio_model_name, framework_name):
|
|
199 |
|
200 |
delete_directory_path = "./temp/"
|
201 |
|
202 |
-
# Separate video and audio
|
203 |
video_path, audio_path = separate_video_audio(video_file.name)
|
204 |
|
205 |
-
# Predict video
|
206 |
video_prediction = predict_video(video_path, video_model, image_processor)
|
|
|
|
|
207 |
|
208 |
-
# Predict audio
|
209 |
audio_prediction = preprocess_and_predict_audio(audio_path, audio_model, audio_processor)
|
|
|
|
|
210 |
|
211 |
-
# Use selected decision framework
|
212 |
framework_function = decision_frameworks[framework_name]
|
213 |
consensus_label = framework_function(video_prediction, audio_prediction)
|
214 |
|
215 |
-
# Clean up the temporary files
|
216 |
delete_files_in_directory(delete_directory_path)
|
217 |
|
218 |
return {
|
219 |
-
"Video
|
220 |
-
"Audio
|
221 |
"Consensus Label": consensus_label
|
222 |
}
|
223 |
|
|
|
199 |
|
200 |
delete_directory_path = "./temp/"
|
201 |
|
|
|
202 |
video_path, audio_path = separate_video_audio(video_file.name)
|
203 |
|
|
|
204 |
video_prediction = predict_video(video_path, video_model, image_processor)
|
205 |
+
|
206 |
+
highest_video_emotion = max(video_prediction, key=video_prediction.get)
|
207 |
|
|
|
208 |
audio_prediction = preprocess_and_predict_audio(audio_path, audio_model, audio_processor)
|
209 |
+
|
210 |
+
highest_audio_emotion = max(audio_prediction, key=audio_prediction.get)
|
211 |
|
|
|
212 |
framework_function = decision_frameworks[framework_name]
|
213 |
consensus_label = framework_function(video_prediction, audio_prediction)
|
214 |
|
|
|
215 |
delete_files_in_directory(delete_directory_path)
|
216 |
|
217 |
return {
|
218 |
+
"Video Label": highest_video_emotion,
|
219 |
+
"Audio Label": highest_audio_emotion,
|
220 |
"Consensus Label": consensus_label
|
221 |
}
|
222 |
|