This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
import os | |
import keras | |
from keras.models import load_model | |
dicts = ['empty', 'neutral', 'calm', 'happy', 'sad', 'angry', 'fear', 'disgust', 'surprise', 'neutral', 'calm', 'happy', 'sad', 'angry', 'fear', 'disgust', 'surprise'] | |
# To capture video from a webcam |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model = Sequential() | |
model.add(Convolution2D(filters=16, kernel_size=(7, 7), padding='same', input_shape=(256,256,3))) | |
model.add(BatchNormalization()) | |
model.add(Convolution2D(filters=16, kernel_size=(7, 7), padding='same')) | |
model.add(BatchNormalization()) | |
model.add(Activation('relu')) | |
model.add(AveragePooling2D(pool_size=(2, 2), padding='same')) | |
model.add(Dropout(0.5)) | |
model.add(Convolution2D(filters=32, kernel_size=(5, 5), padding='same')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dim = (384, 216) | |
dim_final = (224, 224) | |
frameRate = 30 # Every nth frame is saved. | |
# Detect the face in image using HAAR cascade, crop it, resize it, and finally save it. | |
for actor in glob.glob(VIDEO_FOLDER): | |
for videoFile in glob.glob(actor + '/*'): | |
print(videoFile) | |
emotion = label.get_emotion(videoFile[-24:]) | |
cap = cv2.VideoCapture(videoFile) # capturing the video from the given path | |
while(cap.isOpened()): |