conceptional question of face detection / classifiers / models [closed]

asked 2018-06-13 12:53:25 -0600

holger gravatar image

updated 2018-06-13 12:57:17 -0600

Hello,

Well my question is a generic one but want to put it into open cv terms. I have a classifier which is able to detect faces.

If i want to detect a specific face(identity) - how would i do it(generally spoken)? Would i really need to train a custom model for that specific face? (i doubt it as i dont have enought data for it) Or would i take an existing model and fine tune it? (my current assumption- never got it working) Or would i use other ways like for example template matching / tracking?

I am a bit lost here. Any keywords / concepts / hints is highly welcome. No code is needed.

Greetings + Thx again, Holger

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by holger
close date 2018-06-14 03:03:44.603509

Comments

OK - from what i am reading on the internet - you would really need to train a model which will classify the various indentities(you need a lot of data - like always)

When you have such a model - you can use transfer learning to train for one specific identity. Ugh i will try out and see if this makes sense at all.

Alternativly you could train from scratch with that specific identity - but this would take too long to do it on the fly imho.

holger gravatar imageholger ( 2018-06-13 13:47:41 -0600 )edit

I am interested in exchanging knowlege. I am familar with tensorflow / keras / darknet yolo and have a basic understanding on how cnn works i think. So just let me know - i am still in the learning phase and we could do something together

holger gravatar imageholger ( 2018-06-13 14:14:15 -0600 )edit

actually, opencv's dnn based face recognition does exactly that.

you load a pretrained model (openface), pipe you images through it, and apply your favourite classifier at the end.

and indeed, finetuning (or transfer learning) is great for anyone, who cannot do this from scratch (lacking data or computing resources), so, taking an existing model, freezing the 1st layers, and only retrain the last few on your specific data is a very common thing. here's a quite simple example

berak gravatar imageberak ( 2018-06-14 02:18:57 -0600 )edit
1

@holger, you need to look on "siamese networks" and "triplet loss" topics. The problem is to train a model which produces a vector of values called embedding for a specific face. Then we need to chose a distance function and make distance between embeddings of similar faces to be less than distance between embeddings of different faces. In example, OpenFace mentioned by @berak produces unit vectors of 128 floating point values and dot(E1, E2) = cos(E1^E2) is our difference between faces in range [-1, 1]. source: https://docs.opencv.org/master/d5/d86...

dkurt gravatar imagedkurt ( 2018-06-14 02:44:50 -0600 )edit

Hello berak, Thx again for your time, your(and stevens) comments were always a great help!

You wrote " freezing the 1st layers", for me that means i dont want to fine tune the edge detection. My understanding is that this happens on the first layer(s) - so no backward propagation is wanted here. Did i got this right (i did not do that when trying my fine tuning - maybe thats why i was always failing)?

So what i am understanding from your comment is that fine tuning / transfer learning is the way to go for this kind of problem? That would help me a lot - only have to think how to get this working (not an opencv problem) for my dnn and probably do some picture augmentation(something like the opencv_createsamples tool does) with opencv to get more data.

Have a great day!

holger gravatar imageholger ( 2018-06-14 02:56:42 -0600 )edit

Thx dkurt - siamese networks sounds like it would fit exactly my problem. I will definitivly do some reading on this. I can understand only like 10-30% of the math / algorithmic background- but getting slowly better. I want to join the club =P

Great that opencv already do similar things, and i can take that as inspiration or even reuse the code base - will take me some time. I guess thats it for now - closing the question as answered!

holger gravatar imageholger ( 2018-06-14 03:02:49 -0600 )edit

Ahh maybe one last thing the concepts you described will work not only for faces - right?

holger gravatar imageholger ( 2018-06-14 03:40:12 -0600 )edit

@holger, that's right.

dkurt gravatar imagedkurt ( 2018-06-14 03:43:48 -0600 )edit
1

Thank you - that's great news! P.S Good luck for Russia in the WM (i am no soccer fan)

holger gravatar imageholger ( 2018-06-14 03:54:10 -0600 )edit