Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]: possible improvement: 1. Avoid duplicated face detection and 2. Batch image process for Emotion analysis #1288

Closed
captainst opened this issue Jul 30, 2024 · 1 comment · Fixed by #1298
Labels
enhancement New feature or request

Comments

@captainst
Copy link

Description

First, thank you for this handy library!

We found 2 issues that could potentially be improved:

  1. In certain cases, we need both the face identification, and emotion. Given the current implementation, we need to first call Deepface.represent(...), then DeepFace.analyze(...). Both functions call the detector, which is a duplication, especially when a slow detector, like Retinaface, or yolov8 is employed. Since the Deepface.represent() already detects the face patches, it is natural to directly use these patches for analyze.
  2. Inside deepface/extenedmodels/Emotion.py, the predict(...) is used to processes the face patches one by one. If there are many faces to be processed, this sequential operation may lead to performance degradation, especially when using GPU. It is possible to add a batch predict function to address it.

I could submit a PR if the above could be beneficial.

Many thanks again!
4.

Additional Info

No response

@captainst captainst added the enhancement New feature or request label Jul 30, 2024
@serengil
Copy link
Owner

1- You can call extract_faces firstly and pass its output to repesent and analyze function. In that way, detection will be done once. All functions are accepting pre-loaded numpy arrays. So, I disagree to do anything for this topic.

2- in facial recognition models, we handled batch processing like - https://github.com/serengil/deepface/blob/master/deepface/basemodels/VGGFace.py#L66 . Same approach can be adopted in emotion model. If you are volunteer to do this, PRs are more than welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants