Example #1
0
def get_network(lr=theano.shared(np.cast['float32'](0.1)), load=False):
    E = CNN.EmotionClassifier(epochs=500, learning_rate=lr)
    if load:
        E.load_network_state()
    return E
Example #2
0
from imageLoader import imageload
from network import CNN
from time import sleep
import os
import dlib
import json
import sys

# Load the Classifier Network
network = CNN.EmotionClassifier()
network.load_network_state("0.15_lr.npz")
# get our face detector
face_detector = dlib.get_frontal_face_detector()
emotions = [
    "Contentness", "Happiness", "Sadness", "Surprise", "Fear", "Anger",
    "Disgust", "Contempt"
]


def search_in_files(dir_="/in/"):
    for root, name, files in os.walk(os.getcwd() + dir_):
        files = sorted([
            file
            for file in files if file.endswith(".png") or file.endswith(".jpg")
        ],
                       key=lambda x: x[:-4])
        fnames = len(files) * [os.getcwd() + dir_]
        for j, f in enumerate(files):
            fnames[j] += f
        return fnames
    return []
Example #3
0
from network import CNN
import os
import lasagne
import numpy as np
from lasagne import layers
from lasagne.updates import nesterov_momentum
from nolearn.lasagne import NeuralNet

approx_epoch_dur_seconds = 0.9
training_time_hours = 10
training_amt = (60 * 60 * training_time_hours) / approx_epoch_dur_seconds
E = CNN.EmotionClassifier(data_directory="../../Emotion Files/",
                          face_data="FaceData/landmarks.dat",
                          epochs=training_amt,
                          show_image=True)
X, Y = E.load_training_set()
E.train(X, Y, training_amt - 1)
E.save_network_state()