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
203a7841
"test/test_transforms_v2_utils.py" did not exist on "5dd95944c609ac399743fa843ddb7b83780512b3"
Unverified
Commit
203a7841
authored
Aug 03, 2020
by
Philip Meier
Committed by
GitHub
Aug 03, 2020
Browse files
add typehints to torchvision.datasets.sbu (#2536)
parent
bf584072
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
torchvision/datasets/sbu.py
torchvision/datasets/sbu.py
+12
-5
No files found.
torchvision/datasets/sbu.py
View file @
203a7841
from
PIL
import
Image
from
.utils
import
download_url
,
check_integrity
from
typing
import
Any
,
Callable
,
Optional
,
Tuple
import
os
from
.vision
import
VisionDataset
...
...
@@ -23,7 +24,13 @@ class SBU(VisionDataset):
filename
=
"SBUCaptionedPhotoDataset.tar.gz"
md5_checksum
=
'9aec147b3488753cf758b4d493422285'
def
__init__
(
self
,
root
,
transform
=
None
,
target_transform
=
None
,
download
=
True
):
def
__init__
(
self
,
root
:
str
,
transform
:
Optional
[
Callable
]
=
None
,
target_transform
:
Optional
[
Callable
]
=
None
,
download
:
bool
=
True
,
)
->
None
:
super
(
SBU
,
self
).
__init__
(
root
,
transform
=
transform
,
target_transform
=
target_transform
)
...
...
@@ -50,7 +57,7 @@ class SBU(VisionDataset):
self
.
photos
.
append
(
photo
)
self
.
captions
.
append
(
caption
)
def
__getitem__
(
self
,
index
)
:
def
__getitem__
(
self
,
index
:
int
)
->
Tuple
[
Any
,
Any
]
:
"""
Args:
index (int): Index
...
...
@@ -69,11 +76,11 @@ class SBU(VisionDataset):
return
img
,
target
def
__len__
(
self
):
def
__len__
(
self
)
->
int
:
"""The number of photos in the dataset."""
return
len
(
self
.
photos
)
def
_check_integrity
(
self
):
def
_check_integrity
(
self
)
->
bool
:
"""Check the md5 checksum of the downloaded tarball."""
root
=
self
.
root
fpath
=
os
.
path
.
join
(
root
,
self
.
filename
)
...
...
@@ -81,7 +88,7 @@ class SBU(VisionDataset):
return
False
return
True
def
download
(
self
):
def
download
(
self
)
->
None
:
"""Download and extract the tarball, and download each individual photo."""
import
tarfile
...
...
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