Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
2e255335
Commit
2e255335
authored
May 17, 2018
by
Ben
Committed by
Soumith Chintala
May 18, 2018
Browse files
Fix documentation and add is_image_file (#507)
parent
628e90cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
torchvision/datasets/folder.py
torchvision/datasets/folder.py
+14
-1
No files found.
torchvision/datasets/folder.py
View file @
2e255335
...
...
@@ -11,14 +11,27 @@ def has_file_allowed_extension(filename, extensions):
Args:
filename (string): path to a file
extensions (iterable of strings): extensions to consider (lowercase)
Returns:
bool: True if the filename ends with
a known image
extension
bool: True if the filename ends with
one of given
extension
s
"""
filename_lower
=
filename
.
lower
()
return
any
(
filename_lower
.
endswith
(
ext
)
for
ext
in
extensions
)
def
is_image_file
(
filename
):
"""Checks if a file is an allowed image extension.
Args:
filename (string): path to a file
Returns:
bool: True if the filename ends with a known image extension
"""
return
has_file_allowed_extension
(
filename
,
IMG_EXTENSIONS
)
def
find_classes
(
dir
):
classes
=
[
d
for
d
in
os
.
listdir
(
dir
)
if
os
.
path
.
isdir
(
os
.
path
.
join
(
dir
,
d
))]
classes
.
sort
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment