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

[BUG]: Image format (RGB/BGR) is inconsistent when using DeepFace.represent #1426

Open
2 tasks done
dakotah-jones opened this issue Jan 14, 2025 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@dakotah-jones
Copy link

dakotah-jones commented Jan 14, 2025

Before You Report a Bug, Please Confirm You Have Done The Following...

  • I have updated to the latest version of the packages.
  • I have searched for both existing issues and closed issues and found none that matched my issue.

DeepFace's version

v0.0.93

Python version

3.12.8

Operating System

Ubuntu 20.04.6 LTS

Dependencies

N/A

Reproducible example

representations = DeepFace.represent(
    file_path,
    model_name='Facenet',
    detector_backend='skip',
    normalization='Facenet'
)

# vs

representations = DeepFace.represent(
    file_path,
    model_name='Facenet',
    detector_backend='retinaface',
    normalization='Facenet'
)

Relevant Log Output

N/A

Expected Result

I expect the image format to be consistent regardless of detector_backend.

What happened instead?

When detector_backend is "skip" the final image used for the embedding is in "RGB" format.
When detector_backend is any other valid option, like "retinaface" the final image used for the embedding is in "BGR" format.

Additional Info

When using detector_backend="skip":

  • The image is loaded using image_utils.load_image. (here)
  • The image is in "BGR" format.
  • The image format is swapped using img = img[:, :, ::-1]. (here)
  • The image is in "RGB" format.
  • The image embedding is calculated.

When using any other detector_backend:

  • detection.extract_faces is called.
  • The color_face argument is defaulted to "rgb"
  • The image is loaded using image_utils.load_image. (here)
  • The image is now in "BGR" format.
  • The color_face argument is "rgb" so the format is swapped using current_img = current_img[:, :, ::-1]. (here)
  • The image is now in "RGB" format.
  • The format is swapped again within represent using img = img[:, :, ::-1]. (here)
  • The image is now in "BGR" format.
  • The image embedding is calculated.
@dakotah-jones dakotah-jones added the bug Something isn't working label Jan 14, 2025
@dakotah-jones dakotah-jones changed the title [BUG]: Image format (RGB/BRG) is inconsistent when using DeepFace.represent [BUG]: Image format (RGB/BGR) is inconsistent when using DeepFace.represent Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant