"doc/git@developer.sourcefind.cn:OpenDAS/ktransformers.git" did not exist on "3015e9dfa73edbc2da03105d14e2aefc6e4ea95e"
Unverified Commit f96a8a00 authored by F-G Fernandez's avatar F-G Fernandez Committed by GitHub
Browse files

Added missing typing annotations in datasets/kinetics (#4170)

parent 835c2c35
...@@ -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[float] = None, frame_rate: Optional[int] = 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\").")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment