Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about the model training process #1

Closed
mdqyy opened this issue Sep 3, 2013 · 20 comments
Closed

about the model training process #1

mdqyy opened this issue Sep 3, 2013 · 20 comments

Comments

@mdqyy
Copy link

mdqyy commented Sep 3, 2013

Could please share the model training code?

@auduno
Copy link
Owner

auduno commented Sep 3, 2013

I plan to do that as soon as I get time to clean it up, hopefully within the coming weeks.

@mdqyy
Copy link
Author

mdqyy commented Sep 4, 2013

Very appreciate.

@haroldSanchezb
Copy link

i have a question, is possible tracking more than one face in screen?

@auduno
Copy link
Owner

auduno commented Nov 27, 2013

Hi Harold,
not out of the box. Theoretically it might be possible to track two faces by creating two instances of clmtrackr, and initializing them on separate bounding boxes on different parts of the screen. But you would have to fiddle with the code to get this to work properly. In practice, I think the biggest problem would be that it would run very slow, since running one instance of clmtrackr is already pretty heavy on most computers.

@haroldSanchezb
Copy link

Hello, it is possible to detect such a gesture, changing tracking parameters? and rather follow up on the gesture of a face instead of the face as such and so, if there are multiple faces, having only capture the gesture in particular, or am I wrong.

@auduno
Copy link
Owner

auduno commented Nov 28, 2013

Hi, I'm not sure what you mean by gesture, could you clarify?

@djabif
Copy link

djabif commented Nov 28, 2013

Hi, great project ! I don't know if @haroldSanchezb means the same, but what I'm trying to do is to detect changes on the face, for example if I ask the user to smile or to move the eyelashes, I want to know if they are doing so. I thought that the easiest way would be comparing the position of the eyelashes or of the mouth before and after asking them to do the gesture. What do you suggest for tracking this ?

@haroldSanchezb
Copy link

Hello @djabif , if I want to do the same, but the system doesn't detect gestures,for allow doing that, I'm doing is drawing the parameters of gestures and when the person do a gesture, make a comparison, and say which had more percentage of confidence between gestures

@auduno
Copy link
Owner

auduno commented Nov 28, 2013

If you're interested in detecting specific movements of the face, like close/open mouth, smile, etc., the easiest way is probably to get the parameters of the fitted facial model, via getCurrentParameters(). This will return an array of 24 values, which determines the pose of the face model. The first four parameters are just scale, rotation and coordinates, so you can ignore these, but the remaining parameters describes the pose. You can play with these pose parameters in an example I put up here:

http://auduno.github.io/clmtrackr/examples/modelviewer_pca.html

So for detecting a smile, you could for instance detect whether component 4 or 7 (note that this will be parameter 8 and 13 in the parameter-array) are larger than some thresholds. I've put together a demo of emotion detection using clmtrackr that I've been meaning to put out, I'll see if I can publish it this weekend.

@djabif
Copy link

djabif commented Nov 28, 2013

Thank you very much for the answer ! If you can publish that example it would be awsome !!

@haroldSanchezb
Copy link

hi! @auduno thanks! Today I started to play with the positions of the points, and that more or less calculated and when someone opened his mouth lol, but what you say would be better!

@haroldSanchezb
Copy link

hi! @auduno how are you ?, I wanted to ask the example you were going to post, when would be possible: P

@auduno
Copy link
Owner

auduno commented Dec 2, 2013

Sorry, I haven't really had time to put it out, and I can't really promise anything in the coming days, since I have three exams this week.. :( I don't think I get time until next weekend to look at it.

@auduno
Copy link
Owner

auduno commented Dec 8, 2013

I've put out the example of emotion detection with clmtrackr here now:
http://auduno.github.io/clmtrackr/examples/clm_emotiondetection.html
This is a bit more than simple thresholds on some of the parameters, it's a logistic regression model on all of the parameters, but the general idea is the same as what I described. I'm going to release the code for training models as well soon!

@djabif
Copy link

djabif commented Dec 10, 2013

Thanks for the example !!! 👍

@ErenPhayte
Copy link

Hi,

I am really new to this tracking thing and also want to create an app to detect when a mouth is open, closed, or makes an "O" face (hehehe)... to put it in another way, I want to track a person chewing gum.

I was using getCurrentPosition but I had difficulty seeing any change between point 44 and 50 (corners of mouth). I read above to use getCurrentParameters, and then saw you did something with emotion which maybe the best approach, although I have no clue what those coefficients are (are they x,y and z positions?) or what bias does, let alone what the difference is between each model (svm 20 vs svm 10, etc) ...

Is there any documentation around this to understand what exactly is happening, and what these data matrix are exactly and how to generate new ones or tweak them?

I think if I have a much better understanding of how this works, I could create an emotionModel with points that would be used to detect these mouth states I need.

Hope this makes sense.

@auduno
Copy link
Owner

auduno commented Dec 13, 2013

Hi, there's not any documentation to this way of detecting emotions, yet. I plan to write some articles on it during the holidays and put out code for creating models.

The coefficients and "bias" in the emotionmodel.js file are trained parameters for a logistic regression model. It would be possible to train such a model yourself, however, you'd have to have access to annotated, classified faces, which might be a problem. I've collected some annotations myself, and plan to make those public soon, but most facial images that are available have some kind of copyright, which makes it hard to make public for these kind of open-source projects.

I think the best bet is to take a look at this modelviewer:
http://auduno.github.io/clmtrackr/examples/modelviewer_pca.html
If you're interested only in detecting open mouth, for instance, parameter 7 in getParameters() is a pretty good indicator of whether the mouth is open (Note that this is component 3 in the modelviewer, since the first four parameters are just scale, rotation and location parameters). So you could create an "open mouth" detector by checking whether parameter 7 is lower than some threshold, -5 for instance. Hope this is helpful!

@ErenPhayte
Copy link

Thanks this is great. Will try it out and see what I can do :)
On Dec 13, 2013 11:40 PM, "Audun Mathias Øygard" notifications@github.com
wrote:

Hi, there's not any documentation to this way of detecting emotions, yet.
I plan to write some articles on it during the holidays and put out code
for creating models.

The coefficients and "bias" in the emotionmodel.js file are trained
parameters for a logistic regression model. It would be possible to train
such a model yourself, however, you'd have to have access to annotated,
classified faces, which might be a problem. I've collected some annotations
myself, and plan to make those public soon, but most facial images that are
available have some kind of copyright, which makes it hard to make public
for these kind of open-source projects.

I think the best bet is to take a look at this modelviewer:
http://auduno.github.io/clmtrackr/examples/modelviewer_pca.html
If you're interested only in detecting open mouth, for instance, parameter
7 in getParameters() is a pretty good indicator of whether the mouth is
open (Note that this is component 3 in the modelviewer, since the first
four parameters are just scale, rotation and location parameters). So you
could create an "open mouth" detector by checking whether parameter 7 is
lower than some threshold, -5 for instance. Hope this is helpful!


Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-30545868
.

@auduno
Copy link
Owner

auduno commented Jan 13, 2014

The model training code is now available, with some documentation, at https://github.com/auduno/clmtools

@auduno auduno closed this as completed Jan 13, 2014
@hyzhak
Copy link

hyzhak commented Jul 11, 2016

@auduno I'm trying to increase number of emotions. Thus would like to know how many images are enough for single emotion from you experience? And do you have any recommendation about choosing right image samples? Thanks!

auduno pushed a commit that referenced this issue Jul 5, 2017
commit a2d0209e09f1a24cd1e1796d87672e5bf2ff1860
Merge: 4dcb8ef 86f46a3
Author: Audun Mathias Øygard <amoygard@gmail.com>
Date:   Sat May 13 09:45:56 2017 +0200

    Merge parts of branch 'dev' of https://github.com/jsio-private/clmtrackr into jsio-private-dev

    Conflicts:
    	Gruntfile.js
    	clmtrackr.js
    	clmtrackr.min.js
    	docs/param_model/dat.gui.min.js
    	examples/clm_image.html
    	examples/clm_video.html
    	examples/example.html
    	examples/ext_js/mosse.js
    	examples/face_deformation_video.html
    	examples/face_mask.html
    	examples/js/libs/Stats.js
    	examples/js/libs/entire_face_filter.js
    	examples/js/libs/frontalface.js
    	examples/js/libs/jquery.imgareaselect.pack.js
    	examples/js/libs/jquery.min.js
    	examples/js/libs/left_eye_filter.js
    	examples/js/libs/mosse.js
    	examples/js/libs/nose_filter.js
    	examples/js/libs/numeric-1.2.6.js
    	examples/js/libs/numeric-1.2.6.min.js
    	examples/js/libs/right_eye_filter.js
    	examples/js/libs/utils.js
    	js/clm.js
    	js/face_deformer.js
    	js/svmfilter_webgl.js
    	js/utils/mosse.js
    	package.json

commit 86f46a3
Author: Ivan Reshetnikov <keenn2007@gmail.com>
Date:   Wed Oct 19 02:24:55 2016 +0200

    fixed compatibility issues with jsdom environment

commit 0fedb8b
Author: yofreke <sparkyjoe94@aim.com>
Date:   Fri Sep 23 16:18:06 2016 -0700

    use jsio-webpack for building

commit 1ea34f2
Merge: 82921c6 05ac5b9
Author: Joe Brown <sparkyjoe94@aim.com>
Date:   Thu Sep 22 14:45:31 2016 -0700

    Merge pull request #2 from jsio-private/threejs-deformer

    Threejs deformer

commit 05ac5b9
Author: yofreke <sparkyjoe94@aim.com>
Date:   Thu Sep 22 11:58:46 2016 -0700

    creepy HSV blend mask shader

commit 17bdc93
Author: yofreke <sparkyjoe94@aim.com>
Date:   Wed Sep 21 19:48:37 2016 -0700

    use ShaderMaterial for mask

commit e01a501
Author: yofreke <sparkyjoe94@aim.com>
Date:   Wed Sep 21 17:22:11 2016 -0700

    functional three face masking

commit 97bc5e6
Author: yofreke <sparkyjoe94@aim.com>
Date:   Wed Sep 21 16:52:07 2016 -0700

    better performance

commit 75e03cd
Author: yofreke <sparkyjoe94@aim.com>
Date:   Wed Sep 21 16:33:57 2016 -0700

    add typings to tracking

commit 9f043f7
Author: yofreke <sparkyjoe94@aim.com>
Date:   Wed Sep 21 16:32:15 2016 -0700

    threejs mesh mask working

commit 3ac9092
Author: yofreke <sparkyjoe94@aim.com>
Date:   Wed Sep 21 12:50:07 2016 -0700

    make IDeformer an abstract class with basic implementation

commit 94bc65f
Author: yofreke <sparkyjoe94@aim.com>
Date:   Wed Sep 21 11:38:39 2016 -0700

    add TS support for twgl deformer

commit 82921c6
Author: yofreke <sparkyjoe94@aim.com>
Date:   Tue Sep 20 13:23:04 2016 -0700

    reduce array churn. favor shift over splice for removing first element

commit 5a99353
Author: yofreke <sparkyjoe94@aim.com>
Date:   Tue Sep 20 12:28:33 2016 -0700

    dont append svmfilter_webgl canvas to dom

commit b3efceb
Author: yofreke <sparkyjoe94@aim.com>
Date:   Tue Sep 20 12:22:05 2016 -0700

    lint svmfilter_webgl

commit b3d6214
Author: Ivan Reshetnikov <keenn2007@gmail.com>
Date:   Tue Sep 20 20:44:13 2016 +0200

    fixed bad import

commit b462239
Author: Ivan Reshetnikov <keenn2007@gmail.com>
Date:   Thu Sep 15 09:58:18 2016 +0200

    size reduction

commit 861c86b
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 19 16:47:00 2016 -0700

    move webgl-utils.js in to js/utils/webgl

commit 562cc11
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 19 16:15:37 2016 -0700

    add generateModelJsons to npm scripts

commit 852fc5a
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 19 16:08:08 2016 -0700

    svmfilter_webgl uses glsl-template loader

commit fa54b59
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 19 15:07:15 2016 -0700

    use glsl-template-loader

commit f2ae43e
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 19 12:56:41 2016 -0700

    fix _calcTracking std dev math error (and cleanup)

commit 6f05bfe
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 19 11:40:14 2016 -0700

    pick c116b7e

commit c5f8e27
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 19 11:37:15 2016 -0700

    add stubs for examples from auduno/gh-pages

commit 7dee40f
Author: yofreke <sparkyjoe94@aim.com>
Date:   Fri Sep 16 18:05:03 2016 -0700

    minify images. fix missing mask textures on gh-pages

commit 9d23258
Author: yofreke <sparkyjoe94@aim.com>
Date:   Fri Sep 16 17:46:49 2016 -0700

    fix publicPath for deployed examples

commit 8df859d
Merge: c37985e a4cae2d
Author: Joe Brown <sparkyjoe94@aim.com>
Date:   Fri Sep 16 17:43:08 2016 -0700

    Merge pull request #1 from jsio-private/react-examples

    Reactify examples

commit a4cae2d
Author: yofreke <sparkyjoe94@aim.com>
Date:   Fri Sep 16 17:42:29 2016 -0700

    add publish functionality

commit 01b2864
Author: yofreke <sparkyjoe94@aim.com>
Date:   Fri Sep 16 17:41:41 2016 -0700

    favor webm videos

commit 5d5a074
Author: yofreke <sparkyjoe94@aim.com>
Date:   Fri Sep 16 17:40:40 2016 -0700

    re-encode examples/media/franck.ogv.  Add webm alternates for videos

commit a7566c4
Author: yofreke <sparkyjoe94@aim.com>
Date:   Fri Sep 16 15:38:23 2016 -0700

    implement examples componentWillUnmount

commit d688837
Author: yofreke <sparkyjoe94@aim.com>
Date:   Fri Sep 16 14:48:05 2016 -0700

    abstracted VideoExample

commit 497276b
Author: yofreke <sparkyjoe94@aim.com>
Date:   Fri Sep 16 13:00:41 2016 -0700

    remove old example files

commit 8b6583a
Author: yofreke <sparkyjoe94@aim.com>
Date:   Fri Sep 16 12:58:33 2016 -0700

    ported face_mask.html

commit c948d3b
Author: yofreke <sparkyjoe94@aim.com>
Date:   Thu Sep 15 17:49:22 2016 -0700

    ported face_deformation_video example

commit d1605c0
Author: yofreke <sparkyjoe94@aim.com>
Date:   Thu Sep 15 15:28:01 2016 -0700

    react clm_video.html

commit 298a9ea
Author: yofreke <sparkyjoe94@aim.com>
Date:   Thu Sep 15 14:41:54 2016 -0700

    add manual selection to clm image example

commit 62945f0
Author: yofreke <sparkyjoe94@aim.com>
Date:   Thu Sep 15 13:43:57 2016 -0700

    better abstractions for VideoContainer. implemented basic clm image example (no manual selection yet)

commit f1d2ee9
Author: yofreke <sparkyjoe94@aim.com>
Date:   Thu Sep 15 11:19:44 2016 -0700

    initial react example code

commit c37985e
Author: yofreke <sparkyjoe94@aim.com>
Date:   Wed Sep 14 20:13:55 2016 -0700

    more deformer cleanup

commit 376f1a5
Author: yofreke <sparkyjoe94@aim.com>
Date:   Wed Sep 14 19:14:15 2016 -0700

    clean up deformer some

commit 5efd95f
Author: yofreke <sparkyjoe94@aim.com>
Date:   Wed Sep 14 18:43:10 2016 -0700

    move twgl deformer in to clm

commit 24e4052
Author: yofreke <sparkyjoe94@aim.com>
Date:   Wed Sep 14 12:27:35 2016 -0700

    linting

commit f832136
Author: yofreke <sparkyjoe94@aim.com>
Date:   Wed Sep 14 11:49:30 2016 -0700

    faster findFace worker postMessage

    Use transferList to send imageData ArrayBuffer, which transfers ownership
    instead of serializing / deserialzing

commit ba19e81
Author: yofreke <sparkyjoe94@aim.com>
Date:   Wed Sep 14 11:23:17 2016 -0700

    single JsfeatFace instance per tracker

commit e5ab47d
Author: yofreke <sparkyjoe94@aim.com>
Date:   Tue Sep 13 18:33:58 2016 -0700

    fix getUserMedia: Illegal invocation

commit 3cb409f
Author: yofreke <sparkyjoe94@aim.com>
Date:   Tue Sep 13 17:32:36 2016 -0700

    JsfeatFace extends EventEmitter

commit e4c9af3
Author: yofreke <sparkyjoe94@aim.com>
Date:   Tue Sep 13 16:51:40 2016 -0700

    refactor some of: utils, jsfeat, Tracker

commit 9a9831e
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 12 18:42:29 2016 -0700

    fix track throwing errors (MosseFilter was returning NaN)

commit 6928dcc
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 12 17:03:57 2016 -0700

    Tracker extends EventEmitter

commit f87ddc7
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 12 14:31:36 2016 -0700

    fix models json

commit cd36b71
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 12 13:45:45 2016 -0700

    add build to postinstall, production build goes to `dist/clmtrackr.js` instead of min

commit d6c7ec9
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 12 13:09:58 2016 -0700

    minor restructure

commit f885f47
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 12 12:53:50 2016 -0700

    initial es6 translation

commit 45f5f43
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 12 10:55:40 2016 -0700

    fix web worker

    - add worker-loader, use inline option
    - format jsfeat_detect.worker.js to match worker-loader expectations
    - use correct jsfeat version (package.json was using a version that is too new)
    - ignore intermediate `dist/*.worker.js` in gitignore

commit 0901691
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 12 10:36:52 2016 -0700

    move built files to `dist/`

commit 2bcfb0a
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 12 10:07:53 2016 -0700

    use webpack for build

commit 90b79c1
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 12 10:00:37 2016 -0700

    fix broken json

commit 37e56b3
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 12 09:33:14 2016 -0700

    hand-pick: #83

commit fcb8d39
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 12 09:09:47 2016 -0700

    delete trailing whitespace

commit c06b4f0
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 12 08:57:05 2016 -0700

    run build

commit bf1e3e6
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 12 08:55:53 2016 -0700

    hand-pick: #53

commit 2b3f324
Author: yofreke <sparkyjoe94@aim.com>
Date:   Mon Sep 12 08:54:41 2016 -0700

    hand-pick: #45

commit f291076
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sun Jan 24 00:53:08 2016 -0500

    remove grunt, etc from dependencies

commit bedc242
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sun Jan 24 00:43:06 2016 -0500

    rebuilt files

commit 05dcf41
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sun Jan 24 00:23:18 2016 -0500

    Added documentation for browserify example

commit 9f69208
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sun Jan 24 00:06:15 2016 -0500

    Update main field in package.json to point to built version

commit f867652
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sun Jan 24 00:05:14 2016 -0500

    Renamed src back to js to keep closer to original repo name

commit f716c67
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sat Jan 23 23:56:56 2016 -0500

    A bit of cleanup

commit 149766e
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sat Jan 23 23:28:03 2016 -0500

    Fixed minification step of build

commit 15079b1
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sat Jan 23 23:24:44 2016 -0500

    Got build working correctly

commit c1d215c
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sat Jan 23 23:04:53 2016 -0500

    wip, but got browserify example working

commit 5024a6c
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sat Jan 23 21:35:34 2016 -0500

    Updated build to include npm versions

commit 53276ef
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sat Jan 23 21:22:33 2016 -0500

    Updated to use built version of clmtracker

commit b257955
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sat Jan 23 15:50:01 2016 -0500

    switched numeric.js over to npm dependency

commit 8e077cd
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sat Jan 23 15:42:53 2016 -0500

    Updated remaining examples to use npm jsfeat

commit e68ad32
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sat Jan 23 15:36:40 2016 -0500

    Had to update jsfeat_detect to work with npm version of jsfeat

commit 7b3a52b
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sat Jan 23 15:08:23 2016 -0500

    Dat as npm dependency

commit 1a9947a
Author: Andy Dayton <amdayton@gmail.com>
Date:   Sat Jan 23 14:50:13 2016 -0500

    Installed blog.js and filesaver.js as npm dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants