Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
List valid filenames in directory efficiency (#277)
Browse files Browse the repository at this point in the history
* Made the function a little more efficient by removing one redundant 'list' call

* Revert "Made the function a little more efficient by removing one redundant 'list' call"

This reverts commit ed3d045.

* Made more efficient by removing one redundant 'list' call

* Fixed PEP8 row length
  • Loading branch information
itaihay authored Mar 9, 2020
1 parent f80d4a1 commit daadd51
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions keras_preprocessing/image/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,11 @@ def _list_valid_filenames_in_directory(directory, white_list_formats, split,
"""
dirname = os.path.basename(directory)
if split:
num_files = len(list(
_iter_valid_files(directory, white_list_formats, follow_links)))
all_files = list(_iter_valid_files(directory, white_list_formats,
follow_links))
num_files = len(all_files)
start, stop = int(split[0] * num_files), int(split[1] * num_files)
valid_files = list(
_iter_valid_files(
directory, white_list_formats, follow_links))[start: stop]
valid_files = all_files[start: stop]
else:
valid_files = _iter_valid_files(
directory, white_list_formats, follow_links)
Expand Down

0 comments on commit daadd51

Please sign in to comment.