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
333af7aa
Commit
333af7aa
authored
Dec 10, 2019
by
James Thewlis
Committed by
Francisco Massa
Dec 10, 2019
Browse files
Move VideoClips dummy dataset to top level for pickling (#1649)
parent
4ab94cb7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
11 deletions
+16
-11
torchvision/datasets/video_utils.py
torchvision/datasets/video_utils.py
+16
-11
No files found.
torchvision/datasets/video_utils.py
View file @
333af7aa
...
...
@@ -43,6 +43,21 @@ def unfold(tensor, size, step, dilation=1):
return
torch
.
as_strided
(
tensor
,
new_size
,
new_stride
)
class
_DummyDataset
(
object
):
"""
Dummy dataset used for DataLoader in VideoClips.
Defined at top level so it can be pickled when forking.
"""
def
__init__
(
self
,
x
):
self
.
x
=
x
def
__len__
(
self
):
return
len
(
self
.
x
)
def
__getitem__
(
self
,
idx
):
return
read_video_timestamps
(
self
.
x
[
idx
])
class
VideoClips
(
object
):
"""
Given a list of video files, computes all consecutive subvideos of size
...
...
@@ -95,19 +110,9 @@ class VideoClips(object):
# strategy: use a DataLoader to parallelize read_video_timestamps
# so need to create a dummy dataset first
class
DS
(
object
):
def
__init__
(
self
,
x
):
self
.
x
=
x
def
__len__
(
self
):
return
len
(
self
.
x
)
def
__getitem__
(
self
,
idx
):
return
read_video_timestamps
(
self
.
x
[
idx
])
import
torch.utils.data
dl
=
torch
.
utils
.
data
.
DataLoader
(
DS
(
self
.
video_paths
),
_DummyDataset
(
self
.
video_paths
),
batch_size
=
16
,
num_workers
=
self
.
num_workers
,
collate_fn
=
lambda
x
:
x
)
...
...
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