1adrianb / face-alignment

:fire: 2D and 3D Face alignment library build using pytorch
https://www.adrianbulat.com
BSD 3-Clause "New" or "Revised" License
6.88k stars 1.33k forks source link

Slow inference speed in first 2 images #304

Closed Mofafa closed 2 years ago

Mofafa commented 2 years ago

Hi, thanks for your wonderful work!

I tried to get face landmarks for a group of images in a for loop, and I found that it is always slow in the first 2 images.

time

I used 3D model and "get_landmarks_from_image" function.

Why?

Mofafa commented 2 years ago

my code structure looks like this: ` build 3d face model

for video in videos frames for frame in frames get_landmarks_from_image(frame)

` It's always slow in the first 2 frames.

1adrianb commented 2 years ago

Hi, during the first iteration some internal buffers are initialized and the model is basically warmed up + the torch.backends.cudnn.benchmark makes a few checks to find the optimal algorithms for the convs on the given hardware.

Mofafa commented 2 years ago

Hi, during the first iteration some internal buffers are initialized and the model is basically warmed up + the torch.backends.cudnn.benchmark makes a few checks to find the optimal algorithms for the convs on the given hardware.

Thank you!