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

Small knob polishing and amend duplicated attempts to add undetectable images to pickle #1031

Merged
merged 10 commits into from
Feb 22, 2024
14 changes: 8 additions & 6 deletions deepface/modules/recognition.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# built-in dependencies
import os
import re
import pickle
from typing import List, Union, Optional
import time
Expand All @@ -14,6 +15,7 @@
from deepface.modules import representation, detection, modeling, verification
from deepface.models.FacialRecognition import FacialRecognition


logger = Logger(module="deepface/modules/recognition.py")


Expand Down Expand Up @@ -295,7 +297,7 @@ def find(
return resp_obj


def __list_images(path: str) -> list[str]:
def __list_images(path: str) -> List[str]:
"""
List images in a given path
Args:
Expand All @@ -304,11 +306,11 @@ def __list_images(path: str) -> list[str]:
images (list): list of exact image paths
"""
images = []
for r, _, f in os.walk(path):
for file in f:
if file.lower().endswith((".jpg", ".jpeg", ".png")):
exact_path = os.path.join(r, file)
images.append(exact_path)
pattern = re.compile(r".*\.(jpg|jpeg|png)$", re.IGNORECASE)
for file_name in os.listdir(path):
if pattern.match(file_name):
images.append(os.path.join(path, file_name))

return images


Expand Down