-
Notifications
You must be signed in to change notification settings - Fork 4
/
model_builder.py
31 lines (21 loc) · 1.11 KB
/
model_builder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from utils import load_data
from my_CNN_model import *
import cv2
# Load training set
X_train, y_train = load_data()
# NOTE: Please check the load_data() method in utils.py to see how the data is preprocessed (normalizations and stuff)
# Setting the CNN architecture
my_model = get_my_CNN_model_architecture()
# Compiling the CNN model with an appropriate optimizer and loss and metrics
compile_my_CNN_model(my_model, optimizer = 'adam', loss = 'mean_squared_error', metrics = ['accuracy'])
# Training the model
hist = train_my_CNN_model(my_model, X_train, y_train)
# train_my_CNN_model returns a History object. History.history attribute is a record of training loss values and metrics
# values at successive epochs, as well as validation loss values and validation metrics values (if applicable).
# Saving the model
save_my_CNN_model(my_model, 'my_model')
'''
# You can skip all the steps above (from 'Setting the CNN architecture') after running the script for the first time.
# Just load the recent model using load_my_CNN_model and use it to predict keypoints on any face data
my_model = load_my_CNN_model('my_model')
'''