|
1 | 1 | import csv
|
2 | 2 | import os
|
3 | 3 | import time
|
| 4 | +import urllib |
4 | 5 | import warnings
|
5 | 6 | from functools import partial
|
6 | 7 | from multiprocessing import Pool
|
@@ -53,7 +54,7 @@ class Kinetics(VisionDataset):
|
53 | 54 | Note: split is appended automatically using the split argument.
|
54 | 55 | frames_per_clip (int): number of frames in a clip
|
55 | 56 | num_classes (int): select between Kinetics-400 (default), Kinetics-600, and Kinetics-700
|
56 |
| - split (str): split of the dataset to consider; supports ``"train"`` (default) ``"val"`` |
| 57 | + split (str): split of the dataset to consider; supports ``"train"`` (default) ``"val"`` ``"test"`` |
57 | 58 | frame_rate (float): If omitted, interpolate different frame rate for each clip.
|
58 | 59 | step_between_clips (int): number of frames between each clip
|
59 | 60 | transform (callable, optional): A function/transform that takes in a TxHxWxC video
|
@@ -81,7 +82,7 @@ class Kinetics(VisionDataset):
|
81 | 82 | }
|
82 | 83 | _ANNOTATION_URLS = {
|
83 | 84 | "400": "https://s3.amazonaws.com/kinetics/400/annotations/{split}.csv",
|
84 |
| - "600": "https://s3.amazonaws.com/kinetics/600/annotations/{split}.txt", |
| 85 | + "600": "https://s3.amazonaws.com/kinetics/600/annotations/{split}.csv", |
85 | 86 | "700": "https://s3.amazonaws.com/kinetics/700_2020/annotations/{split}.csv",
|
86 | 87 | }
|
87 | 88 |
|
@@ -122,7 +123,7 @@ def __init__(
|
122 | 123 | raise ValueError("Cannot download the videos using legacy_structure.")
|
123 | 124 | else:
|
124 | 125 | self.split_folder = path.join(root, split)
|
125 |
| - self.split = verify_str_arg(split, arg="split", valid_values=["train", "val"]) |
| 126 | + self.split = verify_str_arg(split, arg="split", valid_values=["train", "val", "test"]) |
126 | 127 |
|
127 | 128 | if download:
|
128 | 129 | self.download_and_process_videos()
|
@@ -177,17 +178,16 @@ def _download_videos(self) -> None:
|
177 | 178 | split_url_filepath = path.join(file_list_path, path.basename(split_url))
|
178 | 179 | if not check_integrity(split_url_filepath):
|
179 | 180 | download_url(split_url, file_list_path)
|
180 |
| - list_video_urls = open(split_url_filepath) |
| 181 | + with open(split_url_filepath) as file: |
| 182 | + list_video_urls = [urllib.parse.quote(line, safe="/,:") for line in file.read().splitlines()] |
181 | 183 |
|
182 | 184 | if self.num_download_workers == 1:
|
183 |
| - for line in list_video_urls.readlines(): |
184 |
| - line = str(line).replace("\n", "") |
| 185 | + for line in list_video_urls: |
185 | 186 | download_and_extract_archive(line, tar_path, self.split_folder)
|
186 | 187 | else:
|
187 | 188 | part = partial(_dl_wrap, tar_path, self.split_folder)
|
188 |
| - lines = [str(line).replace("\n", "") for line in list_video_urls.readlines()] |
189 | 189 | poolproc = Pool(self.num_download_workers)
|
190 |
| - poolproc.map(part, lines) |
| 190 | + poolproc.map(part, list_video_urls) |
191 | 191 |
|
192 | 192 | def _make_ds_structure(self) -> None:
|
193 | 193 | """move videos from
|
|
0 commit comments