# OpenFacePytorch
**Repository Path**: jianchengss/OpenFacePytorch
## Basic Information
- **Project Name**: OpenFacePytorch
- **Description**: from: https://github.com/thnkim/OpenFacePytorch.git
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2018-06-07
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# OpenFace for Pytorch
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:
```
nn.Sequential {
[input -> (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) -> output]
(1): nn.SpatialConvolutionMM(3 -> 64, 7x7, 2,2, 3,3)
(2): nn.SpatialBatchNormalization (4D) (64)
(3): nn.ReLU
(4): nn.SpatialMaxPooling(3x3, 2,2, 1,1)
(5): nn.SpatialCrossMapLRN
...
```
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)
```