serengil / deepface

A Lightweight Face Recognition and Facial Attribute Analysis (Age, Gender, Emotion and Race) Library for Python
https://www.youtube.com/watch?v=WnUVYQP4h44&list=PLsS_1RYmYQQFdWqxQggXHynP1rqaYXv_E&index=1
MIT License
11.73k stars 2.02k forks source link

it uses build_model for every represent function #675

Closed liveseongho closed 1 year ago

liveseongho commented 1 year ago

Hey, serengil.

I found you use build_model for every represent function. But, it's really inefficient when one tries to use this library to get multiple image features (it were millions for me).

So, I called build_model before I use represent and pass the model to the function (it was quite simple). I hope my experience can help many others and update this library.

serengil commented 1 year ago

How did you decide that is inefficient? Build_model uses singleton pattern. So, once it is built, then it will use pre-built one in the memory. So, you do not have to build it beforehand.