1adrianb / face-alignment

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

Support for Batch Inference #115

Open Neltherion opened 5 years ago

Neltherion commented 5 years ago

Hi and Thanks for the great package.

I wanted to ask if there is any support for inferring Landmarks of a batch of images? Each fa.get_landmarks(image) takes a really long time compared to something like DLib's landmark detector even on a GPU and I was hoping I could use batch processing to process a batch of images at once and remedy this issue a bit.

Thanks again.

1adrianb commented 5 years ago

Hi @Neltherion,

This should definitely alleviate the issue to some extend. The only reason I didn't do this is because the face detector used (SFD) can be quite memory intensive (depending on the image resolution) unlike the face alignment network which is independent of this.

Neltherion commented 5 years ago

Thanks for the quick answer...

So... Can't we modify the fa.get_landmarks(image) method to accept variable-length inputs (with at least one image and at most n images as a batch)? or even make a new method to prevent backwards compatibility issues,,,

1adrianb commented 5 years ago

Sure, we can add as an optional paramter the batch size, with the default set to 1

AmirSh15 commented 5 years ago

Hi @Neltherion,

did you find any solution for this problem?

Neltherion commented 5 years ago

@AmirSh15 Not really. This is a real problem for lots of Face Alignment + Face Detection libraries out there: They don't support batch inference properly!