Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch as pt
|
| 3 |
-
import
|
|
|
|
| 4 |
import cv2
|
| 5 |
import os
|
| 6 |
import numpy as np
|
|
@@ -63,10 +64,10 @@ def process_video_audio(video_path):
|
|
| 63 |
train_audio_wave = tf.reshape(tf.convert_to_tensor(train_audio_wave.numpy(), dtype=tf.float16), (1, 20, 13077))
|
| 64 |
train_audio_cnn = tf.convert_to_tensor(train_audio_cnn.numpy(), dtype=tf.float16)
|
| 65 |
|
| 66 |
-
return last_frame, train_visual, train_audio_wave, train_audio_cnn
|
| 67 |
|
| 68 |
def predict_emotion(video_path):
|
| 69 |
-
last_frame, train_visual, train_audio_wave, train_audio_cnn = process_video_audio(video_path)
|
| 70 |
|
| 71 |
model = load_model("model_vui_ve.keras")
|
| 72 |
|
|
@@ -77,13 +78,13 @@ def predict_emotion(video_path):
|
|
| 77 |
})
|
| 78 |
|
| 79 |
predicted_label = np.argmax(predictions)
|
| 80 |
-
return last_frame, predicted_label
|
| 81 |
|
| 82 |
def predict_emotion_gradio(video_path):
|
| 83 |
emotion_dict = {0: 'neutral', 1: 'calm', 2: 'happy', 3: 'sad', 4: 'angry', 5: 'fearful'}
|
| 84 |
-
last_frame, predicted_label = predict_emotion(video_path)
|
| 85 |
predicted_emotion = emotion_dict[predicted_label]
|
| 86 |
-
return last_frame, predicted_emotion
|
| 87 |
|
| 88 |
iface = gr.Interface(
|
| 89 |
fn=predict_emotion_gradio,
|
|
@@ -92,6 +93,7 @@ iface = gr.Interface(
|
|
| 92 |
],
|
| 93 |
outputs=[
|
| 94 |
gr.Image(label="Last Frame"),
|
|
|
|
| 95 |
gr.Textbox(label="Predicted Emotion")
|
| 96 |
],
|
| 97 |
title="Emotion Recognition from Video",
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch as pt
|
| 3 |
+
import
|
| 4 |
+
torchaudio
|
| 5 |
import cv2
|
| 6 |
import os
|
| 7 |
import numpy as np
|
|
|
|
| 64 |
train_audio_wave = tf.reshape(tf.convert_to_tensor(train_audio_wave.numpy(), dtype=tf.float16), (1, 20, 13077))
|
| 65 |
train_audio_cnn = tf.convert_to_tensor(train_audio_cnn.numpy(), dtype=tf.float16)
|
| 66 |
|
| 67 |
+
return last_frame, audio_path, train_visual, train_audio_wave, train_audio_cnn
|
| 68 |
|
| 69 |
def predict_emotion(video_path):
|
| 70 |
+
last_frame, audio_path, train_visual, train_audio_wave, train_audio_cnn = process_video_audio(video_path)
|
| 71 |
|
| 72 |
model = load_model("model_vui_ve.keras")
|
| 73 |
|
|
|
|
| 78 |
})
|
| 79 |
|
| 80 |
predicted_label = np.argmax(predictions)
|
| 81 |
+
return last_frame, audio_path, predicted_label
|
| 82 |
|
| 83 |
def predict_emotion_gradio(video_path):
|
| 84 |
emotion_dict = {0: 'neutral', 1: 'calm', 2: 'happy', 3: 'sad', 4: 'angry', 5: 'fearful'}
|
| 85 |
+
last_frame, audio_path, predicted_label = predict_emotion(video_path)
|
| 86 |
predicted_emotion = emotion_dict[predicted_label]
|
| 87 |
+
return last_frame, audio_path, predicted_emotion
|
| 88 |
|
| 89 |
iface = gr.Interface(
|
| 90 |
fn=predict_emotion_gradio,
|
|
|
|
| 93 |
],
|
| 94 |
outputs=[
|
| 95 |
gr.Image(label="Last Frame"),
|
| 96 |
+
gr.Audio(label = "Audio")
|
| 97 |
gr.Textbox(label="Predicted Emotion")
|
| 98 |
],
|
| 99 |
title="Emotion Recognition from Video",
|