Code Monkey home page Code Monkey logo

pyvggface's Introduction

PyVGGFace

A VGG-Face CNN descriptor implemented in PyTorch.

The VGG-Face CNN descriptors are computed using [1] authors' CNN implementation, based on the VGG-Very-Deep-16 CNN architecture (see [1]), and are evaluated on the Labeled Faces in the Wild [2] and the YouTube Faces [3] datasets. The provided models can be used for non-commercial research purposes under Creative Commons Attribution License.

Step 0: Setup and activate a virtual environment (Python 3.3+), as follows:

$ python3 -m venv venv
$ source venv/bin/activate
$ pip install --upgrade pip
$ pip install -r requirements.txt
$ source venv/bin/activate

Step 1: Convert the original pre-trained LuaTorch weights into PyTorch VGGFace weights and save them at models/vggface.pth by running the following script:

$ python3 convert_weights.py 

After this step, models directory should be as follows:

models/
├── vggface.pth
├── vgg_face_torch
│   └── VGG_FACE.t7
└── vgg_face_torch.tar.gz

Step 2: Run demo script:

$ python3 demo.py 

By default, image data/rm.png is used (use a different image using --img=<image_file>) -- the output should be as follows:

Predicted id: Rooney_Mara (probability: 0.984787964730149)

Rooney Mara

Get VGGFace sub-model

Use the following script for getting a sub-model of VGGFace, e.g., only the convolutional sub-network, and/or rename its layers:

$ python3 get_submodel.py -h
usage: Get (sub)model of VGGFace model [-h] [--model MODEL] [--output OUTPUT]

optional arguments:
  -h, --help       show this help message and exit
  --model MODEL    input VGGFace model file
  --output OUTPUT  output VGGFace (sub)model file

References

[1] Parkhi, Omkar M., Andrea Vedaldi, and Andrew Zisserman. "Deep face recognition." BMVC. Vol. 1. No. 3. 2015.

[2] G. B. Huang, M. Ramesh, T. Berg, E. Learned-Miller Labeled faces in the wild: A database for studying face recognition in unconstrained environments. Technical Report 07-49, University of Massachusetts, Amherst, 2007.

[3] L. Wolf, T. Hassner, I. Maoz "Face Recognition in Unconstrained Videos with Matched Background Similarity." Computer Vision and Pattern Recognition (CVPR), 2011.

pyvggface's People

Contributors

chi0tzp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pyvggface's Issues

There is a error: [unhashable type: 'numpy.ndarray'] when convet weights

Hi, thank you for your work. I meet some mistakes when convert weights:

Traceback (most recent call last):
File "E:/BaoXiu/EX8/PyVGGFace-master/convert_weights.py", line 67, in
model=vggface_model)
File "E:/BaoXiu/EX8/PyVGGFace-master/convert_weights.py", line 32, in convert
torch_model = torchfile.load(torch_weights_file)
File "C:\ProgramData\Anaconda3\envs\temp\lib\site-packages\torchfile.py", line 424, in load
return reader.read_obj()
File "C:\ProgramData\Anaconda3\envs\temp\lib\site-packages\torchfile.py", line 370, in read_obj
obj._obj = self.read_obj()
File "C:\ProgramData\Anaconda3\envs\temp\lib\site-packages\torchfile.py", line 387, in read_obj
obj[k] = v
TypeError: unhashable type: 'numpy.ndarray'

And my envs is:

numpy (1.14.3)
Pillow (5.2.0)
pip (9.0.1)
torch (1.1.0)
torchfile (0.1.0)
torchvision (0.3.0)

Could you give me some help?

Pretrained model

Hello, I download the pretrained file vgg_face_torch.tar.gz (Torch), and follow your step1 but I got the error "unhashable type: 'numpy.ndarray'", could you help me with this error, or may you share your converted .pth model? Thanks a lot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.