dpressel / rude-carnie

Age detection in Tensorflow
937 stars 342 forks source link

slow classifier #66

Open alirezak7 opened 6 years ago

alirezak7 commented 6 years ago

in guess.py this following line takes almost a second to predict the age or gender on a 1050Ti gpu:

batch_results = sess.run(softmax_output, feed_dict={images:image_batch.eval()})

I am feeding a batch of one image which includes a cropped face and it takes one second.

Any idea on how i can speed things up to create a realtime age/gender classifier that can work on camera streams?

dpressel commented 6 years ago

I have not seen a single image take that amount of time. How are you profiling?

alirezak7 commented 6 years ago

I am running guess.py and feeding it one image. I put time.time() before and after the line mentioned above (line 99 in guess.py) to measure the time. It takes almost a second executing that line. I have tried feeding batches and for a batch of 100 face images it took 5 seconds (50 ms per image). But for real time age/gender recognition i need to be able to process a frame with one or a few faces in less than 200 ms.

this is how i measured time : start = time.time() batch_results = sess.run(softmax_output, feed_dict={images:image_batch.eval()}) end = time.time() print("to run session : "+str((end-start)))

dpressel commented 6 years ago

You will definitely want to batch your images. Also you may want to look at some of the other tickets surrounding video processing. Several people seem to have modified guess.py to work on video. At some point I plan on adding a demo program for this, but havent had time yet.

Also you may be interested in this PR: https://github.com/dpressel/rude-carnie/pull/50