Skip to content

Commit 83031a4

Browse files
committed
image_exts and pil_exts are now global variables and are now named as IMAGE_EXTS and PIL_EXTS to match Python naming conventions.
1 parent 6a75052 commit 83031a4

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

deepface/commons/image_utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
from werkzeug.datastructures import FileStorage
1515

1616

17+
IMAGE_EXTS = {".jpg", ".jpeg", ".png"}
18+
PIL_EXTS = {"jpeg", "png"}
19+
20+
1721
def list_images(path: str) -> List[str]:
1822
"""
1923
List images in a given path
@@ -23,14 +27,12 @@ def list_images(path: str) -> List[str]:
2327
images (list): list of exact image paths
2428
"""
2529
images = []
26-
image_exts = {".jpg", ".jpeg", ".png"}
27-
pil_exts = {"jpeg", "png"}
2830
for r, _, f in os.walk(path):
2931
for file in f:
30-
if os.path.splitext(file)[1].lower() in image_exts:
32+
if os.path.splitext(file)[1].lower() in IMAGE_EXTS:
3133
exact_path = os.path.join(r, file)
3234
with Image.open(exact_path) as img: # lazy
33-
if img.format.lower() in pil_exts:
35+
if img.format.lower() in PIL_EXTS:
3436
images.append(exact_path)
3537
return images
3638

@@ -43,14 +45,12 @@ def yield_images(path: str) -> Generator[str, None, None]:
4345
Yields:
4446
image (str): image path
4547
"""
46-
image_exts = {".jpg", ".jpeg", ".png"}
47-
pil_exts = {"jpeg", "png"}
4848
for r, _, f in os.walk(path):
4949
for file in f:
50-
if os.path.splitext(file)[1].lower() in image_exts:
50+
if os.path.splitext(file)[1].lower() in IMAGE_EXTS:
5151
exact_path = os.path.join(r, file)
5252
with Image.open(exact_path) as img: # lazy
53-
if img.format.lower() in pil_exts:
53+
if img.format.lower() in PIL_EXTS:
5454
yield exact_path
5555

5656

0 commit comments

Comments
 (0)