# The SVM baseline for SEMAINE
import shared_defs_DISFA
import data_preparation
import numpy

import mlp

pca_loc = "../pca_generation/generic_face_rigid"

(all_aus, train_recs, disfa_dir,
 hog_data_dir) = shared_defs_DISFA.shared_defs()
devel_recs = train_recs[14:-1]
train_recs = train_recs[0:14]

[train_samples, train_labels, valid_samples, valid_labels, _, PC, means, scaling] = \
    data_preparation.Prepare_HOG_AU_data_generic_DISFA_dynamic(train_recs, devel_recs, all_aus,
                                                         disfa_dir, hog_data_dir, pca_loc, geometry=True)

# binarise the labels
train_labels[train_labels > 1] = 1
valid_labels[valid_labels > 1] = 1

print train_samples.shape, valid_samples.shape, numpy.mean(train_labels,
                                                           axis=0), numpy.mean(
                                                               valid_labels,
                                                               axis=0)

import validation_helpers

train_fn = mlp.train_mlp_probe
test_fn = mlp.test_mlp_class
# The SVM baseline for BO4D
import shared_defs_DISFA
import data_preparation

(all_aus, users, DISFA_dir, hog_data_dir) = shared_defs_DISFA.shared_defs()

train_recs = users[0:int(len(users)/2)]
devel_recs = users[(int(len(users)/2)):]

pca_loc = "../pca_generation/generic_face_rigid"

f = open("./trained/DISFA_train_dynamic_lin_svm.txt", 'w')

for au in all_aus:
               
    hyperparams = {"C": [0.000001, 0.00001, 0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000], "validate_params": ["C"]}
    
    # load the training and testing data for the current fold
    [train_samples, train_labels, valid_samples, valid_labels, raw_valid, PC, means, scaling] = \
        data_preparation.Prepare_HOG_AU_data_generic_DISFA_dynamic(train_recs, devel_recs, [au],
                                                             DISFA_dir, hog_data_dir, pca_loc, geometry=True)
    train_labels[train_labels > 1] = 1
    valid_labels[valid_labels > 1] = 1

    import linear_SVM
    import validation_helpers
    
    train_fn = linear_SVM.train_SVM
    test_fn = linear_SVM.test_SVM

    # Cross-validate here                
# The SVM baseline for SEMAINE
import shared_defs_DISFA
import data_preparation
import numpy

import mlp

pca_loc = "../pca_generation/generic_face_rigid"

(all_aus, train_recs, disfa_dir, hog_data_dir) = shared_defs_DISFA.shared_defs()
devel_recs = train_recs[14:-1]
train_recs = train_recs[0:14]

[train_samples, train_labels, valid_samples, valid_labels, _, PC, means, scaling] = \
    data_preparation.Prepare_HOG_AU_data_generic_DISFA(train_recs, devel_recs, all_aus,
                                                         disfa_dir, hog_data_dir, pca_loc, geometry=True)

# binarise the labels
train_labels[train_labels > 1] = 1
valid_labels[valid_labels > 1] = 1

print train_samples.shape, valid_samples.shape, numpy.mean(train_labels, axis=0), numpy.mean(valid_labels, axis=0)


import validation_helpers

train_fn = mlp.train_mlp_probe
test_fn = mlp.test_mlp_class

hyperparams = {
    'batch_size': [100],
Esempio n. 4
0
# The SVM baseline for BO4D
import shared_defs_DISFA
import data_preparation

(all_aus, users, DISFA_dir, hog_data_dir) = shared_defs_DISFA.shared_defs()

train_recs = users[0:int(len(users) / 2)]
devel_recs = users[(int(len(users) / 2)):]

pca_loc = "../pca_generation/generic_face_rigid"

f = open("./trained/DISFA_train_dynamic_lin_svm.txt", 'w')

for au in all_aus:

    hyperparams = {
        "C": [0.000001, 0.00001, 0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000],
        "validate_params": ["C"]
    }

    # load the training and testing data for the current fold
    [train_samples, train_labels, valid_samples, valid_labels, raw_valid, PC, means, scaling] = \
        data_preparation.Prepare_HOG_AU_data_generic_DISFA_dynamic(train_recs, devel_recs, [au],
                                                             DISFA_dir, hog_data_dir, pca_loc, geometry=True)
    train_labels[train_labels > 1] = 1
    valid_labels[valid_labels > 1] = 1

    import linear_SVM
    import validation_helpers

    train_fn = linear_SVM.train_SVM
import shared_defs_DISFA
import data_preparation
import numpy

import mlp

(all_aus_bp4d, train_recs, devel_recs, BP4D_dir, hog_data_dir) = shared_defs_BP4D.shared_defs_intensity()

pca_loc = "../pca_generation/generic_face_rigid"


# load the training and testing data for the current fold
[train_samples_bp4d, train_labels_bp4d, valid_samples_bp4d, valid_labels_bp4d, raw_valid, PC, means, scaling] = \
    data_preparation.Prepare_HOG_AU_data_generic_BP4D_intensity(train_recs, devel_recs, all_aus_bp4d, BP4D_dir, hog_data_dir, pca_loc, geometry=True)

(all_aus_disfa, train_recs, disfa_dir, hog_data_dir) = shared_defs_DISFA.shared_defs()
devel_recs = train_recs[0:1]
[train_samples_disfa, train_labels_disfa, _, _, _, PC, means, scaling] = \
    data_preparation.Prepare_HOG_AU_data_generic_DISFA(train_recs, devel_recs, all_aus_disfa,
                                                         disfa_dir, hog_data_dir, pca_loc, geometry=True)

import validation_helpers

train_labels_bp4d = train_labels_bp4d / 5.0
valid_labels_bp4d = valid_labels_bp4d / 5.0

train_labels_disfa = train_labels_disfa / 5.0

# Train on all three
#  Do the fully joint models first (2, 12, 17)
aus_exp = [6, 12, 17]