Important: before running this notebook, copy the pre-trained weight CSV files from the Keras-OpenFace project to the local weights
directory.
from model import create_model
from utils import load_weights
Instantiate the nn4.small2 model of the OpenFace project as Keras model.
nn4_small2 = create_model()
Load the pre-trained model weights from CSV files.
nn4_small2_weights = load_weights()
Update the Keras model with the loaded weights and save the weights in binary format.
for name, w in nn4_small2_weights.items():
if nn4_small2.get_layer(name) != None:
nn4_small2.get_layer(name).set_weights(w)
nn4_small2.save_weights('weights/nn4.small2.v1.h5')