Antonio commited on
Commit
c5e4c7d
·
1 Parent(s): e1cc37c

Added error display

Browse files
Files changed (1) hide show
  1. app.py +24 -16
app.py CHANGED
@@ -210,27 +210,35 @@ def predict(video_file, video_model_name, audio_model_name, framework_name):
210
 
211
  delete_directory_path = "./temp/"
212
 
213
- video_path, audio_path = separate_video_audio(video_file)
 
 
 
214
 
215
- video_prediction = predict_video(video_path, video_model, image_processor)
216
-
217
- highest_video_emotion = max(video_prediction, key=video_prediction.get)
218
 
219
- audio_prediction = preprocess_and_predict_audio(audio_path, audio_model, audio_processor)
220
-
221
- highest_audio_emotion = max(audio_prediction, key=audio_prediction.get)
 
 
 
222
 
223
- framework_function = decision_frameworks[framework_name]
224
- consensus_label = framework_function(video_prediction, audio_prediction)
 
 
 
 
225
 
226
- delete_files_in_directory(delete_directory_path)
 
 
 
 
227
 
228
- result = f"""
229
- <h2>Predictions</h2>
230
- <p><strong>Video Label:</strong> {highest_video_emotion}</p>
231
- <p><strong>Audio Label:</strong> {highest_audio_emotion}</p>
232
- <p><strong>Consensus Label:</strong> {consensus_label}</p>
233
- """
234
  return result
235
 
236
  inputs = [
 
210
 
211
  delete_directory_path = "./temp/"
212
 
213
+ try:
214
+ video_path, audio_path = separate_video_audio(video_file)
215
+
216
+ video_prediction = predict_video(video_path, video_model, image_processor)
217
 
218
+ highest_video_emotion = max(video_prediction, key=video_prediction.get)
219
+
220
+ audio_prediction = preprocess_and_predict_audio(audio_path, audio_model, audio_processor)
221
 
222
+ highest_audio_emotion = max(audio_prediction, key=audio_prediction.get)
223
+
224
+ framework_function = decision_frameworks[framework_name]
225
+ consensus_label = framework_function(video_prediction, audio_prediction)
226
+
227
+ delete_files_in_directory(delete_directory_path)
228
 
229
+ result = f"""
230
+ <h2>Predictions</h2>
231
+ <p><strong>Video Label:</strong> {highest_video_emotion}</p>
232
+ <p><strong>Audio Label:</strong> {highest_audio_emotion}</p>
233
+ <p><strong>Consensus Label:</strong> {consensus_label}</p>
234
+ """
235
 
236
+ except ValueError as e:
237
+ result = f"""
238
+ <h2>Error</h2>
239
+ <p>{str(e)}</p>
240
+ """
241
 
 
 
 
 
 
 
242
  return result
243
 
244
  inputs = [