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

Slow Classification #52

Closed
aaaaalucard opened this issue Nov 11, 2015 · 3 comments
Closed

Slow Classification #52

aaaaalucard opened this issue Nov 11, 2015 · 3 comments

Comments

@aaaaalucard
Copy link

@bamos Hey Brandon, nice project! Our team are really interested and currently we are developing a real time video analyzing tool.

One question i have is that when i try to use the classifier.py to make a prediction, it may take couple of seconds to get the result, and i noticed it is slower than the web demo.

Are those two classification methods different? Is there any way to speed up calling classifier.py, like small photos for example?

@bamos
Copy link
Collaborator

bamos commented Nov 11, 2015

Hi @aaaaalucard - thanks! classify.py and the web demo use the same classification methods. I have some timing code in the comparison demo that shows up with the -verbose option. You could add something similar to the classification demo to get a slightly better idea of the bottlenecks. Happy to merge these additions into the master branch if you make them.

My guess is that the web demo doesn't have to re-start when classifying, but every time the classification demo is started, it spends a few seconds loading a large model in a Lua/Torch subprocess. We're interested in moving the subprocess to a server that the Python scripts can communicate with in #4. We probably won't make this change for a few months and are happy for help if you're interested.

The performance differences could also be due to image sizes. And something like #50 might slightly improve the performance for everything.

I'm closing this issue and delegating the improvements to #4 and #50 for now.

-Brandon.

@bamos bamos closed this as completed Nov 11, 2015
@lucafeudi
Copy link

I did as Bamos advised and as he guessed the most of the time (at least on my machine) is due to libraries and Openface models:

./demos/classifier.py --verbose infer ./classifier.pkl image_to_classify.jpg > classifier_output.log

real 0m2.883s
user 0m3.104s
sys 0m0.624s

cat classifier_output.log
Argument parsing and import libraries took 0.496383905411 seconds.
Loading the dlib and OpenFace models took 1.60048508644 seconds.
Original size: (480, 640, 3)
Loading image to classify took 0.00619888305664 seconds.
Find face took 0.425406932831 seconds.
Align image took 0.253262996674 seconds.
Make prediction took 0.000334978103638 seconds.
Predict luca with 0.72 confidence.

How can make you merge the additions i made do classifier.py?

@bamos
Copy link
Collaborator

bamos commented Dec 13, 2015

Hi @lucafeudi - thanks! Can you send in a pull request?
See https://help.github.com/articles/using-pull-requests

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

3 participants