Use Openface to train your own first model _ computer vision

Source: Internet
Author: User
Tags lua

Today, I realized openface trained my first face recognition model, which was helpful to me in the implementation of this blog http://www.vccoo.com/v/2ed520


The process and results of the implementation are as follows:

Premise: My machine has been configured Openface+dlib, so I don't have to worry too much about the environment. An error occurred during the implementation of the environment:/home/zpj/torch/install/bin/luajit:/home/zpj/torch/install/share/lua/5.1/trepl/init.lua:384: Module ' Csvigo ' not found:no luarocks module found for Csvigo

After the inspection found that a missing Csvigo module, since the problem is found, installation on the line, and then proceed to the following steps

root@zpj-hp-xw4550-workstation:~/openface/training-images# luarocks Install Csvigo


OK, it's done.


It's a problem, it's training.



2,

First step

Create a folder named./training-images/in the Openface file

mkdir training-images

Second Step

Create a subfolder for each person you want to identify. For example: I found four groups of training pictures, each group of pictures about 15, in fact, a little less. A group of my pengjunzhu/, a group of my girlfriend's xinqi/, the other two groups are Sun Honglei hongleisun/and Huang Lei leihuang/, this is in the "Men's help" cut the picture. Put these four groups of pictures in four folders.


Third Step

Then put these training folders into the Openface/tarin-images. The format of the picture doesn't matter. Make sure that only one face appears on each image. You do not need to crop the area around the face. Openface will cut itself.

Fourth Step

Run this openface script from the root directory of this openface.

First, pose detection and calibration:

./util/align-dlib.py./training-images/align outereyesandnose./aligned-images/--size 96

This creates a new./aligned-images/subfolder with a cropped and aligned version of each test image.

Second, the representations are generated from the aligned Image:

./batch-represent/main.lua-outdir./generated-embeddings/-data./aligned-images/

After running, this./aligned-images/subfolder contains an embedded CSV file with each image.

Third, train your own facial detection model:

./demos/classifier.py train./generated-embeddings/

This will result in a new file name named./generated-embeddings/classifier.pkl. This file has a SVM model that you will use to identify the new face.

By this, you should have a facial recognizer available.


Fifth step: facial recognition.


Get a new picture of an unknown face. Pass it like this to the classifier script:

./demos/classifier.py Infer./generated-embeddings/classifier.pkl your_test_image.jpg

We're going to get a forecast that looks like this:

= = =/test-images/will-ferrel-1.jpg = =

Predict Will-ferrell with 0.73 confidence.

Note: I used my own photos to test the results, the best results reached 89%, the worst result of 66% this is because my training pictures are relatively few.

Start here until you get used to this./demos/classifier.py Python scripts do whatever you want.


Important NOTE:

If you get a bad result, try adding more photos (especially photos of different poses) to each person in step three.

This script always gives a prediction, even if it's a face that it doesn't know. In real-world applications, you'll see reliability scores and throw out low reliability predictions because they're probably wrong.
I've basically implemented a classifier here, but I still have two points that I'm not quite sure about, but I really want to know,

1. Add I want to add a group of training data, then I can be in the existing training model based on training, rather than in the new training model.

I know there must be, but I don't know what to do.

2, how to call the camera, so I can pass through the camera through the pictures to test, and do not need to be so manually identified.


This is one of the two technologies that I do not know at the moment, but I particularly want to know.

2016.08.21 Night



The model was tested again today. This model does not recognize a cat's face. Ha ha...

The error thrown is exception:unable to find a face:train-test/haha.jpeg

Can you identify a stranger's face?

This result is very surprising to me, I copy has been Andy Lau's photos, take to test, unexpectedly found he and Sun Honglei confidence is 90%, I suddenly on the force. You know, I took Sun Honglei's own photos. The highest confidence level is only 89%. It must have been a problem there. Not enough training. My next step is to find a few more sets of training. See how it works.

On this issue today in the group consulted, the possible reason is the pretreatment did not handle well, perhaps is the problem of cutting, cutting and positioning problems.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.