From af7dced53a6ef4ad891a8ff5bd2b41071d46cc23 Mon Sep 17 00:00:00 2001 From: Eitan Date: Mon, 23 Sep 2019 02:19:52 +0300 Subject: [PATCH 1/4] Expose num_workers in VideoClips --- torchvision/datasets/video_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/torchvision/datasets/video_utils.py b/torchvision/datasets/video_utils.py index 4b81f64ec77..1d60b6c72db 100644 --- a/torchvision/datasets/video_utils.py +++ b/torchvision/datasets/video_utils.py @@ -49,8 +49,9 @@ class VideoClips(object): on the resampled video """ def __init__(self, video_paths, clip_length_in_frames=16, frames_between_clips=1, - frame_rate=None, _precomputed_metadata=None): + frame_rate=None, _precomputed_metadata=None, num_workers=1): self.video_paths = video_paths + self.num_workers = num_workers if _precomputed_metadata is None: self._compute_frame_pts() else: @@ -77,7 +78,7 @@ def __getitem__(self, idx): dl = torch.utils.data.DataLoader( DS(self.video_paths), batch_size=16, - num_workers=torch.get_num_threads(), + num_workers=self.num_workers, collate_fn=lambda x: x) with tqdm(total=len(dl)) as pbar: From 36e2698d504f75b9e207ab8b54d769f8dc61b198 Mon Sep 17 00:00:00 2001 From: Eitan Date: Tue, 24 Sep 2019 19:20:25 +0300 Subject: [PATCH 2/4] add documentation for num_workers in VideoClips --- torchvision/datasets/video_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/torchvision/datasets/video_utils.py b/torchvision/datasets/video_utils.py index 1d60b6c72db..4e1417dda9c 100644 --- a/torchvision/datasets/video_utils.py +++ b/torchvision/datasets/video_utils.py @@ -47,9 +47,11 @@ class VideoClips(object): frame_rate (int, optional): if specified, it will resample the video so that it has `frame_rate`, and then the clips will be defined on the resampled video + num_workers: how many subprocesses to use for data loading. + 0 means that the data will be loaded in the main process. (default: 0) """ def __init__(self, video_paths, clip_length_in_frames=16, frames_between_clips=1, - frame_rate=None, _precomputed_metadata=None, num_workers=1): + frame_rate=None, _precomputed_metadata=None, num_workers=0): self.video_paths = video_paths self.num_workers = num_workers if _precomputed_metadata is None: From edf017adec258879586403a2e3f850204d4232f6 Mon Sep 17 00:00:00 2001 From: Eitan Date: Tue, 24 Sep 2019 19:56:12 +0300 Subject: [PATCH 3/4] add documentation for num_workers in VideoClips --- torchvision/datasets/video_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchvision/datasets/video_utils.py b/torchvision/datasets/video_utils.py index 4e1417dda9c..191a268841e 100644 --- a/torchvision/datasets/video_utils.py +++ b/torchvision/datasets/video_utils.py @@ -47,7 +47,7 @@ class VideoClips(object): frame_rate (int, optional): if specified, it will resample the video so that it has `frame_rate`, and then the clips will be defined on the resampled video - num_workers: how many subprocesses to use for data loading. + num_workers (int): how many subprocesses to use for data loading. 0 means that the data will be loaded in the main process. (default: 0) """ def __init__(self, video_paths, clip_length_in_frames=16, frames_between_clips=1, From bbc5a7711ceb5494dcc5dbfb6f22cc0487e8816e Mon Sep 17 00:00:00 2001 From: Eitan Date: Tue, 24 Sep 2019 20:25:10 +0300 Subject: [PATCH 4/4] add documentation for num_workers in VideoClips --- torchvision/datasets/video_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchvision/datasets/video_utils.py b/torchvision/datasets/video_utils.py index 191a268841e..a7e1cb60dc1 100644 --- a/torchvision/datasets/video_utils.py +++ b/torchvision/datasets/video_utils.py @@ -48,7 +48,7 @@ class VideoClips(object): so that it has `frame_rate`, and then the clips will be defined on the resampled video num_workers (int): how many subprocesses to use for data loading. - 0 means that the data will be loaded in the main process. (default: 0) + 0 means that the data will be loaded in the main process. (default: 0) """ def __init__(self, video_paths, clip_length_in_frames=16, frames_between_clips=1, frame_rate=None, _precomputed_metadata=None, num_workers=0):