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
681c6c11
Commit
681c6c11
authored
Nov 13, 2019
by
Rahul Somani
Committed by
Francisco Massa
Nov 13, 2019
Browse files
Refactored clip_sampler (#1562)
parent
95131de3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
torchvision/datasets/samplers/clip_sampler.py
torchvision/datasets/samplers/clip_sampler.py
+5
-5
No files found.
torchvision/datasets/samplers/clip_sampler.py
View file @
681c6c11
...
@@ -2,7 +2,7 @@ import math
...
@@ -2,7 +2,7 @@ import math
import
torch
import
torch
from
torch.utils.data
import
Sampler
from
torch.utils.data
import
Sampler
import
torch.distributed
as
dist
import
torch.distributed
as
dist
import
torchvision.datasets.video_utils
from
torchvision.datasets.video_utils
import
VideoClips
class
DistributedSampler
(
Sampler
):
class
DistributedSampler
(
Sampler
):
...
@@ -96,7 +96,7 @@ class DistributedSampler(Sampler):
...
@@ -96,7 +96,7 @@ class DistributedSampler(Sampler):
self
.
epoch
=
epoch
self
.
epoch
=
epoch
class
UniformClipSampler
(
torch
.
utils
.
data
.
Sampler
):
class
UniformClipSampler
(
Sampler
):
"""
"""
Sample `num_video_clips_per_video` clips for each video, equally spaced.
Sample `num_video_clips_per_video` clips for each video, equally spaced.
When number of unique clips in the video is fewer than num_video_clips_per_video,
When number of unique clips in the video is fewer than num_video_clips_per_video,
...
@@ -107,7 +107,7 @@ class UniformClipSampler(torch.utils.data.Sampler):
...
@@ -107,7 +107,7 @@ class UniformClipSampler(torch.utils.data.Sampler):
num_clips_per_video (int): number of clips to be sampled per video
num_clips_per_video (int): number of clips to be sampled per video
"""
"""
def
__init__
(
self
,
video_clips
,
num_clips_per_video
):
def
__init__
(
self
,
video_clips
,
num_clips_per_video
):
if
not
isinstance
(
video_clips
,
torchvision
.
datasets
.
video_utils
.
VideoClips
):
if
not
isinstance
(
video_clips
,
VideoClips
):
raise
TypeError
(
"Expected video_clips to be an instance of VideoClips, "
raise
TypeError
(
"Expected video_clips to be an instance of VideoClips, "
"got {}"
.
format
(
type
(
video_clips
)))
"got {}"
.
format
(
type
(
video_clips
)))
self
.
video_clips
=
video_clips
self
.
video_clips
=
video_clips
...
@@ -139,7 +139,7 @@ class UniformClipSampler(torch.utils.data.Sampler):
...
@@ -139,7 +139,7 @@ class UniformClipSampler(torch.utils.data.Sampler):
)
)
class
RandomClipSampler
(
torch
.
utils
.
data
.
Sampler
):
class
RandomClipSampler
(
Sampler
):
"""
"""
Samples at most `max_video_clips_per_video` clips for each video randomly
Samples at most `max_video_clips_per_video` clips for each video randomly
...
@@ -148,7 +148,7 @@ class RandomClipSampler(torch.utils.data.Sampler):
...
@@ -148,7 +148,7 @@ class RandomClipSampler(torch.utils.data.Sampler):
max_clips_per_video (int): maximum number of clips to be sampled per video
max_clips_per_video (int): maximum number of clips to be sampled per video
"""
"""
def
__init__
(
self
,
video_clips
,
max_clips_per_video
):
def
__init__
(
self
,
video_clips
,
max_clips_per_video
):
if
not
isinstance
(
video_clips
,
torchvision
.
datasets
.
video_utils
.
VideoClips
):
if
not
isinstance
(
video_clips
,
VideoClips
):
raise
TypeError
(
"Expected video_clips to be an instance of VideoClips, "
raise
TypeError
(
"Expected video_clips to be an instance of VideoClips, "
"got {}"
.
format
(
type
(
video_clips
)))
"got {}"
.
format
(
type
(
video_clips
)))
self
.
video_clips
=
video_clips
self
.
video_clips
=
video_clips
...
...
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