mirror of
https://github.com/serengil/deepface.git
synced 2025-06-10 05:17:08 +00:00
Use regex to match file patterns
Also use os.listdir as is clear recursion is not intended
This commit is contained in:
parent
72e5669302
commit
63079d3095
@ -1,5 +1,6 @@
|
||||
# built-in dependencies
|
||||
import os
|
||||
import re
|
||||
import pickle
|
||||
from typing import List, Union, Optional
|
||||
import time
|
||||
@ -14,6 +15,7 @@ from deepface.commons.logger import Logger
|
||||
from deepface.modules import representation, detection, modeling, verification
|
||||
from deepface.models.FacialRecognition import FacialRecognition
|
||||
|
||||
|
||||
logger = Logger(module="deepface/modules/recognition.py")
|
||||
|
||||
|
||||
@ -303,12 +305,12 @@ def __list_images(path: str) -> list[str]:
|
||||
Returns:
|
||||
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)
|
||||
images = list[str]()
|
||||
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
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user