The SVM uses eye aspect ratio (ear) in consecutive video frames to predict eye blink.
Eyeblink8 is used to train.
Get training data ready
Be sure training data is prepared in eyeblink8
and run:
python3 preprocess.py
Then train svm:
from utils import *
from utils_frame_based import *
from train import *
# uses 7 frames to predict
X, y = build_svm_data('./train/training_set.pkl', 7)
norm_X = transform_svm_data(X)
# adjust on your need
params = {
'kernel': ['rbf'],
'C': [10],
'gamma': ['scale'],
'max_iter': [5000],
'class_weight': [None],
}
svm = train(norm_X, y, params)
save_model(svm, 'svm_7.pkl')
Largely modified from Mustafa A. Hakkoz's kaggle: