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

Double load of matching image in realtime.py #1036

Closed
AndreaLanfranchi opened this issue Feb 23, 2024 · 2 comments
Closed

Double load of matching image in realtime.py #1036

AndreaLanfranchi opened this issue Feb 23, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@AndreaLanfranchi
Copy link
Contributor

Consider this snippet

                                # to use this source image as is
                                display_img = cv2.imread(label)
                                # to use extracted face
                                source_objs = DeepFace.extract_faces(
                                    img_path=label,
                                    target_size=(pivot_img_size, pivot_img_size),
                                    detector_backend=detector_backend,
                                    enforce_detection=False,
                                    align=False,
                                )

display_img is firstly initialized by a direct load of image from file on disk
Eventually DeepFace.extract_faces is called passing the string path to file (which implies a second load)
IMO the code should like

                                # to use this source image as is
                                display_img = cv2.imread(label)
                                # to use extracted face
                                source_objs = DeepFace.extract_faces(
                                    img_path=display_img,
                                    target_size=(pivot_img_size, pivot_img_size),
                                    detector_backend=detector_backend,
                                    enforce_detection=False,
                                    align=False,
                                )

@serengil
Copy link
Owner

Right, second usage will avoid re-load twice.

@serengil
Copy link
Owner

Closed with PR - #1038

Thank you for your contribution

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

No branches or pull requests

2 participants