py-feat icon indicating copy to clipboard operation
py-feat copied to clipboard

GPU not really utilized well

Open ichitaka opened this issue 3 years ago • 7 comments

So I've run a few tests, as I've noticed that PyFeat is quite slow in comparison to something like OpenFace2. Turns out, while the CPU is always utilized, the GPU is not. This seems to be, because the data is loaded 1-by-1 through OpenCV instead of using a proper GPU library for lists of images. I think it makes sense, if a list of images is given to a Detector for detect_image, to load and predict the images batch wise through torch.DataLoaders. Bildschirmfoto 2021-08-10 um 21 49 17 Bildschirmfoto 2021-08-10 um 21 49 35

ichitaka avatar Aug 10 '21 19:08 ichitaka

Hello @ichitaka ! Sorry for the late reply, but that's definitely an excellent suggestion! Basically, we used frame-by-frame reading because at that time we don't know if you could load videos with the Pytorch data loader. But in the next (soon) release we will address this problem! Thank you so much for the insights!

TiankangXie avatar Aug 26 '21 03:08 TiankangXie

@TiankangXie : Any update from your side on this? I use resmasknet model to get emotion scores data from videos. And Py-Feat is extremely slow. Any temporary solutions at least?

dexterdev avatar Jan 11 '22 13:01 dexterdev

@dexterdev I am sorry for the late reply. Have you tried to increase the parameter - batch_size, and increase the skip_frames? Currently, these are the two parameters that could affect the processing speed. Increasing the batch_size and skip_frames should reduce the processing time proportionally.

We are reading the frames of the video by frames with the OpenCV cap.read function. This is not optimal and we are working on a major update soon! Again thank you for the feedbacks!

TiankangXie avatar Jan 11 '22 18:01 TiankangXie

No I havent tried those options. And also I was always trying to load all frames. Thank you. Looking forward for the updated Py-Feat :)

dexterdev avatar Jan 12 '22 09:01 dexterdev

Thanks @ichitaka for the excellent suggestion. We have completely refactored our toolbox to use the pytorch data loaders. We can report that there is now dramatic speedups on CPU, but also the ability to use GPUs as well. We are finishing up testing and will be updating our release very shortly (https://github.com/cosanlab/py-feat/pull/133).

ljchang avatar Aug 05 '22 15:08 ljchang

Great update!

ichitaka avatar Aug 05 '22 15:08 ichitaka

Great. I think this is at right time for our requirements. Thanks for the great package and recent upgrade <3

dexterdev avatar Aug 05 '22 16:08 dexterdev