You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Disclaimer: This codes require the input face-images that are aligned and cropped in the same way of the original OpenFace. *
I made a dirty code to use OpenFace in PyTorch.
I converted 'nn4.small2.v1.t7' to a .hdf5 file using 'torch-hdf5'.
Then I read layer informations from .hdf5 file, which can be displayed as follows:
Then I manually coded layers in PyTorch (see loadOpenFace.py) with some tentative layers code which may be supported by PyTorch officially laters (SpatialCrossMapLRN_temp.py, adopted from PyTorch's nn.legacy).
The final model is 'openface.pth' (which may need to be renamed to 'openface_nn4_small2_v1.pth'), which can be loaded by codes in loadOpenFace.py.
Please see main section of loadOpenFace.py for how-to-use.
Simply,
net = prepareOpenFace(useCuda=True, gpuDevice=0, useMultiGPU=False).eval()
feature = net(input_tensor) # input_tensor should be (batch_size, 3, 96, 96)
License
This is released under Apache 2.0 license.
About
PyTorch module to use OpenFace's nn4.small2.v1.t7 model