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
f96a8a00
"doc/git@developer.sourcefind.cn:OpenDAS/ktransformers.git" did not exist on "3015e9dfa73edbc2da03105d14e2aefc6e4ea95e"
Unverified
Commit
f96a8a00
authored
Jul 16, 2021
by
F-G Fernandez
Committed by
GitHub
Jul 16, 2021
Browse files
Added missing typing annotations in datasets/kinetics (#4170)
parent
835c2c35
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
torchvision/datasets/kinetics.py
torchvision/datasets/kinetics.py
+9
-8
No files found.
torchvision/datasets/kinetics.py
View file @
f96a8a00
...
@@ -8,6 +8,7 @@ import csv
...
@@ -8,6 +8,7 @@ import csv
from
typing
import
Any
,
Callable
,
Dict
,
Optional
,
Tuple
from
typing
import
Any
,
Callable
,
Dict
,
Optional
,
Tuple
from
functools
import
partial
from
functools
import
partial
from
multiprocessing
import
Pool
from
multiprocessing
import
Pool
from
torch
import
Tensor
from
.utils
import
download_and_extract_archive
,
download_url
,
verify_str_arg
,
check_integrity
from
.utils
import
download_and_extract_archive
,
download_url
,
verify_str_arg
,
check_integrity
from
.folder
import
find_classes
,
make_dataset
from
.folder
import
find_classes
,
make_dataset
...
@@ -15,7 +16,7 @@ from .video_utils import VideoClips
...
@@ -15,7 +16,7 @@ from .video_utils import VideoClips
from
.vision
import
VisionDataset
from
.vision
import
VisionDataset
def
_dl_wrap
(
tarpath
,
videopath
,
line
)
:
def
_dl_wrap
(
tarpath
:
str
,
videopath
:
str
,
line
:
str
)
->
None
:
download_and_extract_archive
(
line
,
tarpath
,
videopath
)
download_and_extract_archive
(
line
,
tarpath
,
videopath
)
...
@@ -90,14 +91,14 @@ class Kinetics(VisionDataset):
...
@@ -90,14 +91,14 @@ class Kinetics(VisionDataset):
frames_per_clip
:
int
,
frames_per_clip
:
int
,
num_classes
:
str
=
"400"
,
num_classes
:
str
=
"400"
,
split
:
str
=
"train"
,
split
:
str
=
"train"
,
frame_rate
:
Optional
[
floa
t
]
=
None
,
frame_rate
:
Optional
[
in
t
]
=
None
,
step_between_clips
:
int
=
1
,
step_between_clips
:
int
=
1
,
transform
:
Optional
[
Callable
]
=
None
,
transform
:
Optional
[
Callable
]
=
None
,
extensions
:
Tuple
[
str
,
...]
=
(
"avi"
,
"mp4"
),
extensions
:
Tuple
[
str
,
...]
=
(
"avi"
,
"mp4"
),
download
:
bool
=
False
,
download
:
bool
=
False
,
num_download_workers
:
int
=
1
,
num_download_workers
:
int
=
1
,
num_workers
:
int
=
1
,
num_workers
:
int
=
1
,
_precomputed_metadata
:
Optional
[
Dict
]
=
None
,
_precomputed_metadata
:
Optional
[
Dict
[
str
,
Any
]
]
=
None
,
_video_width
:
int
=
0
,
_video_width
:
int
=
0
,
_video_height
:
int
=
0
,
_video_height
:
int
=
0
,
_video_min_dimension
:
int
=
0
,
_video_min_dimension
:
int
=
0
,
...
@@ -187,7 +188,7 @@ class Kinetics(VisionDataset):
...
@@ -187,7 +188,7 @@ class Kinetics(VisionDataset):
poolproc
=
Pool
(
self
.
num_download_workers
)
poolproc
=
Pool
(
self
.
num_download_workers
)
poolproc
.
map
(
part
,
lines
)
poolproc
.
map
(
part
,
lines
)
def
_make_ds_structure
(
self
):
def
_make_ds_structure
(
self
)
->
None
:
"""move videos from
"""move videos from
split_folder/
split_folder/
├── clip1.avi
├── clip1.avi
...
@@ -228,13 +229,13 @@ class Kinetics(VisionDataset):
...
@@ -228,13 +229,13 @@ class Kinetics(VisionDataset):
)
)
@
property
@
property
def
metadata
(
self
):
def
metadata
(
self
)
->
Dict
[
str
,
Any
]
:
return
self
.
video_clips
.
metadata
return
self
.
video_clips
.
metadata
def
__len__
(
self
):
def
__len__
(
self
)
->
int
:
return
self
.
video_clips
.
num_clips
()
return
self
.
video_clips
.
num_clips
()
def
__getitem__
(
self
,
idx
)
:
def
__getitem__
(
self
,
idx
:
int
)
->
Tuple
[
Tensor
,
Tensor
,
int
]
:
video
,
audio
,
info
,
video_idx
=
self
.
video_clips
.
get_clip
(
idx
)
video
,
audio
,
info
,
video_idx
=
self
.
video_clips
.
get_clip
(
idx
)
if
not
self
.
_legacy
:
if
not
self
.
_legacy
:
# [T,H,W,C] --> [T,C,H,W]
# [T,H,W,C] --> [T,C,H,W]
...
@@ -303,7 +304,7 @@ class Kinetics400(Kinetics):
...
@@ -303,7 +304,7 @@ class Kinetics400(Kinetics):
download
:
Any
=
None
,
download
:
Any
=
None
,
num_download_workers
:
Any
=
None
,
num_download_workers
:
Any
=
None
,
**
kwargs
:
Any
**
kwargs
:
Any
):
)
->
None
:
warnings
.
warn
(
warnings
.
warn
(
"Kinetics400 is deprecated and will be removed in a future release."
"Kinetics400 is deprecated and will be removed in a future release."
"It was replaced by Kinetics(..., num_classes=
\"
400
\"
)."
)
"It was replaced by Kinetics(..., num_classes=
\"
400
\"
)."
)
...
...
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