Discussion:
Finding dimentions of faces on an image
(too old to reply)
Fimi
2013-03-19 04:19:07 UTC
Permalink
Hello,
I've got non linear multiclass classification for support vector machines to work and it does predict the correct face and non face images. It has been a very steep learning curve for me because this is the first time I do this type of work.
I would like to see if you can guide me on a good direction on how I would go about finding the area of the face is. My goal is to draw a square around the area of a face so that I can visually show where it has found it.
I have spent many hours (and days in this project) on the website of scikit-learn page trying to find out things. When I do a prediction, the only thing i get back is a list of predicted labels. I also looked into the values and functions that are present in the object when performing the SVC.fit(X,y) and SCV.predict(..) but could not figure out how to do this.
I would appreciate any help. Thank you.
Here's some code snippet that i currently have:
parameters = {'kernel':('linear','rbf'), 'C':[1,2,3,4,5, 10]}
svr = SVC(verbose=True)
clf = GridSearchCV(svr, parameters)
clf.fit(data, y_train)
print "Best Estimator",clf.best_estimator_

y_predict = clf.predict(test_data)
#plot one of the images that was predicted
#draw squares to indicate location of faces
Gilles Louppe
2013-03-19 07:49:27 UTC
Permalink
Hi,

Short answer: you cant.

Longer answer: If you use as training samples the whole images (with faces
somewhere in there), then your model is learning to discriminate between
your 2 categories, from the whole images, with **no** information about
where the faces are actually located. As such, it is not learning to detect
faces. It is learning to discriminate between images that contain faces
(somewhere) and images that do not. What I mean to say is that it may as
well learn to detect "non-faces" elements (background stuff) than to detect
faces. Therefore, it may predict than an image is a "face" because it
contains no "non-faces" elements. It is also very like to exploit artifacts
to "learn" to discriminate between your categories (e.g., say that all
images with faces contain a blue sky, then a new image may be labeled to be
a face because it contains a blue sky, not because it contains a face).

If you want to build a proper face detector, than you should train your
model directly on the regions of interest containing the faces. Once your
model is trained, then to detect faces in new image, you can scan the whole
image with a sliding window of the size of training rectangles and apply
your detector on each one of these.

Hope this helps,

Gilles
Post by Fimi
Hello,
**
I've got non linear multiclass classification for support vector machines
to work and it does predict the correct face and non face images. It has
been a very steep learning curve for me because this is the first time I do
this type of work.
**
I would like to see if you can guide me on a good direction on how I would
go about finding the area of the face is. My goal is to draw a square
around the area of a face so that I can visually show where it has found it.
**
I have spent many hours (and days in this project) on the website of
scikit-learn page trying to find out things. When I do a prediction, the
only thing i get back is a list of predicted labels. I also looked into the
values and functions that are present in the object when performing the
SVC.fit(X,y) and SCV.predict(..) but could not figure out how to do this.
**
I would appreciate any help. Thank you.
**
parameters = {'kernel':('linear','rbf'), 'C':[1,2,3,4,5, 10]}
svr = SVC(verbose=True)
clf = GridSearchCV(svr, parameters)
clf.fit(data, y_train)
print "Best Estimator",clf.best_estimator_
y_predict = clf.predict(test_data)
#plot one of the images that was predicted
#draw squares to indicate location of faces
**
**
**
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
Brian Holt
2013-03-19 08:03:26 UTC
Permalink
As Gilles says, the scanning windows approach is pretty common for object
(and face) detection. Have you looked at the Viola Jones paper? It's the
standard for face detection and now that we have adaboost classifiers you
should be able to knock up an example quite quickly. Scikit Image might be
quite useful for you as well, efficient versions of the integral image
calculations are already implemented.

Brian
Post by Gilles Louppe
Hi,
Short answer: you cant.
Longer answer: If you use as training samples the whole images (with faces
somewhere in there), then your model is learning to discriminate between
your 2 categories, from the whole images, with **no** information about
where the faces are actually located. As such, it is not learning to detect
faces. It is learning to discriminate between images that contain faces
(somewhere) and images that do not. What I mean to say is that it may as
well learn to detect "non-faces" elements (background stuff) than to detect
faces. Therefore, it may predict than an image is a "face" because it
contains no "non-faces" elements. It is also very like to exploit artifacts
to "learn" to discriminate between your categories (e.g., say that all
images with faces contain a blue sky, then a new image may be labeled to be
a face because it contains a blue sky, not because it contains a face).
If you want to build a proper face detector, than you should train your
model directly on the regions of interest containing the faces. Once your
model is trained, then to detect faces in new image, you can scan the whole
image with a sliding window of the size of training rectangles and apply
your detector on each one of these.
Hope this helps,
Gilles
Post by Fimi
Hello,
**
I've got non linear multiclass classification for support vector
machines to work and it does predict the correct face and non face images.
It has been a very steep learning curve for me because this is the first
time I do this type of work.
**
I would like to see if you can guide me on a good direction on how I
would go about finding the area of the face is. My goal is to draw a square
around the area of a face so that I can visually show where it has found it.
**
I have spent many hours (and days in this project) on the website of
scikit-learn page trying to find out things. When I do a prediction, the
only thing i get back is a list of predicted labels. I also looked into the
values and functions that are present in the object when performing the
SVC.fit(X,y) and SCV.predict(..) but could not figure out how to do this.
**
I would appreciate any help. Thank you.
**
parameters = {'kernel':('linear','rbf'), 'C':[1,2,3,4,5, 10]}
svr = SVC(verbose=True)
clf = GridSearchCV(svr, parameters)
clf.fit(data, y_train)
print "Best Estimator",clf.best_estimator_
y_predict = clf.predict(test_data)
#plot one of the images that was predicted
#draw squares to indicate location of faces
**
**
**
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
Fimi
2013-03-19 12:55:14 UTC
Permalink
Hi Brian,
 
I will look into this paper in more detail. Thank you for your reply.
 
If I have to use opencv or other wrappers like it that hide SVM behind its interface I will not use it. The purpose of this small project is to learn Support Vector Machines.
 
 
Fimi


________________________________
From: Brian Holt <***@gmail.com>
To: scikit-learn-***@lists.sourceforge.net
Sent: Tuesday, March 19, 2013 4:03:26 AM
Subject: Re: [Scikit-learn-general] Finding dimentions of faces on an image

As Gilles says, the scanning windows approach is pretty common for object (and face) detection. Have you looked at the Viola Jones paper? It's the standard for face detection and now that we have adaboost classifiers you should be able to knock up an example quite quickly. Scikit Image might be quite useful for you as well, efficient versions of the integral image calculations are already implemented.
Brian
On Mar 19, 2013 7:50 AM, "Gilles Louppe" <***@gmail.com> wrote:
Hi,
Post by Gilles Louppe
Short answer: you cant.
Longer answer: If you use as training samples the whole images (with faces somewhere in there), then your model is learning to discriminate between your 2 categories, from the whole images, with **no** information about where the faces are actually located. As such, it is not learning to detect faces. It is learning to discriminate between images that contain faces (somewhere) and images that do not. What I mean to say is that it may as well learn to detect "non-faces" elements (background stuff) than to detect faces. Therefore, it may predict than an image is a "face" because it contains no "non-faces" elements. It is also very like to exploit artifacts to "learn" to discriminate between your categories (e.g., say that all images with faces contain a blue sky, then a new image may be labeled to be a face because it contains a blue sky, not because it contains a face).
If you want to build a proper face detector, than you should train your model directly on the regions of interest containing the faces. Once your model is trained, then to detect faces in new image, you can scan the whole image with a sliding window of the size of training rectangles and apply your detector on each one of these. 
Hope this helps,
Gilles
Hello,
Post by Fimi
I've got non linear multiclass classification for support vector machines to work and it does predict the correct face and non face images. It has been a very steep learning curve for me because this is the first time I do this type of work.
I would like to see if you can guide me on a good direction on how I would go about finding the area of the face is. My goal is to draw a square around the area of a face so that I can visually show where it has found it.
I have spent many hours (and days in this project) on the website of scikit-learn page trying to find out things. When I do a prediction, the only thing i get back is a list of predicted labels. I also looked into the values and functions that are present in the object when performing the SVC.fit(X,y) and SCV.predict(..) but could not figure out how to do this.
I would appreciate any help. Thank you.
parameters = {'kernel':('linear','rbf'), 'C':[1,2,3,4,5, 10]}
svr = SVC(verbose=True)
clf = GridSearchCV(svr, parameters)
clf.fit(data, y_train)
print "Best Estimator",clf.best_estimator_
y_predict = clf.predict(test_data)
#plot one of the images that was predicted
#draw squares to indicate location of faces
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
Andreas Mueller
2013-03-19 13:06:54 UTC
Permalink
Post by Fimi
Hi Brian,
I will look into this paper in more detail. Thank you for your reply.
If I have to use opencv or other wrappers like it that hide SVM behind
its interface I will not use it. The purpose of this small project is
to learn Support Vector Machines.
Support vector machines are not really the most commonly used method for
face detection, but it should be possible to do it.
You just need to extract bounding boxes as Brian said.

Cheers,
Andy

Fimi
2013-03-19 12:47:54 UTC
Permalink
Hi Gilles,
 
Thank you very much for your answer.
 
I did really spend a lot more time on this then I had to. This is because the topic is very interesting to me and I really went at it. I found out the hard way that I could not use the whole image, it was bringing up other noisy items into the training set and as you said its detection was messy. So what I did was I first used image feature extraction just after I loaded my images and I was able to confirm that faces (its shape) were visible and so were some other items. Then I thought maybe just cropping the face picture might train the model more correctly so I did that. So in summary, for pre processing I do, black and white, use cropped images  that only have faces and finally do feature extraction using scikit-image. Finally I trained my model, after each of these changes I kept getting better results.
 
I don't know what and how to use the training rectangles. I did some searching on the web and I could not find what you were referring to.
 
Thank you,
Fimi


________________________________
From: Gilles Louppe <***@gmail.com>
To: Fimi <***@yahoo.com>; "scikit-learn-***@lists.sourceforge.net" <scikit-learn-***@lists.sourceforge.net>
Sent: Tuesday, March 19, 2013 3:49:27 AM
Subject: Re: [Scikit-learn-general] Finding dimentions of faces on an image

Hi,

Short answer: you cant.

Longer answer: If you use as training samples the whole images (with faces somewhere in there), then your model is learning to discriminate between your 2 categories, from the whole images, with **no** information about where the faces are actually located. As such, it is not learning to detect faces. It is learning to discriminate between images that contain faces (somewhere) and images that do not. What I mean to say is that it may as well learn to detect "non-faces" elements (background stuff) than to detect faces. Therefore, it may predict than an image is a "face" because it contains no "non-faces" elements. It is also very like to exploit artifacts to "learn" to discriminate between your categories (e.g., say that all images with faces contain a blue sky, then a new image may be labeled to be a face because it contains a blue sky, not because it contains a face).

If you want to build a proper face detector, than you should train your model directly on the regions of interest containing the faces. Once your model is trained, then to detect faces in new image, you can scan the whole image with a sliding window of the size of training rectangles and apply your detector on each one of these. 

Hope this helps,

Gilles
On 19 March 2013 05:19, Fimi <***@yahoo.com> wrote:
Hello,
Post by Fimi
I've got non linear multiclass classification for support vector machines to work and it does predict the correct face and non face images. It has been a very steep learning curve for me because this is the first time I do this type of work.
I would like to see if you can guide me on a good direction on how I would go about finding the area of the face is. My goal is to draw a square around the area of a face so that I can visually show where it has found it.
I have spent many hours (and days in this project) on the website of scikit-learn page trying to find out things. When I do a prediction, the only thing i get back is a list of predicted labels. I also looked into the values and functions that are present in the object when performing the SVC.fit(X,y) and SCV.predict(..) but could not figure out how to do this.
I would appreciate any help. Thank you.
parameters = {'kernel':('linear','rbf'), 'C':[1,2,3,4,5, 10]}
svr = SVC(verbose=True)
clf = GridSearchCV(svr, parameters)
clf.fit(data, y_train)
print "Best Estimator",clf.best_estimator_
y_predict = clf.predict(test_data)
#plot one of the images that was predicted
#draw squares to indicate location of faces
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
Andreas Mueller
2013-03-19 08:54:08 UTC
Permalink
Hi Fimi.
Is there a reason you are not using the Viola-Jones implemented in OpenCV?
I should be available in SimpleCV, too, if you want a nice Python interface.

Cheers,
Andy
Post by Fimi
Hello,
I've got non linear multiclass classification for support vector
machines to work and it does predict the correct face and non face
images. It has been a very steep learning curve for me because this is
the first time I do this type of work.
I would like to see if you can guide me on a good direction on how I
would go about finding the area of the face is. My goal is to draw a
square around the area of a face so that I can visually show where it
has found it.
I have spent many hours (and days in this project) on the website of
scikit-learn page trying to find out things. When I do a prediction,
the only thing i get back is a list of predicted labels. I also looked
into the values and functions that are present in the object when
performing the SVC.fit(X,y) and SCV.predict(..) but could not figure
out how to do this.
I would appreciate any help. Thank you.
parameters = {'kernel':('linear','rbf'), 'C':[1,2,3,4,5, 10]}
svr = SVC(verbose=True)
clf = GridSearchCV(svr, parameters)
clf.fit(data, y_train)
print "Best Estimator",clf.best_estimator_
y_predict = clf.predict(test_data)
#plot one of the images that was predicted
#draw squares to indicate location of faces
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Scikit-learn-general mailing list
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
Loading...