Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LabeledVideoPaths type hint and inheritance issue #107

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pytorchvideo/data/labeled_video_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os
import pathlib
from typing import List, Optional, Tuple
from typing import Dict, List, Optional, Tuple

from iopath.common.file_io import g_pathmgr
from torchvision.datasets.folder import make_dataset
Expand All @@ -23,13 +23,13 @@ def from_path(cls, data_path: str) -> LabeledVideoPaths:
- If it is a directory path it uses the LabeledVideoPaths.from_directory function.
- If it's a file it uses the LabeledVideoPaths.from_csv file.
Args:
file_path (str): The path to the file to be read.
data_path (str): The path to the file to be read.
"""

if g_pathmgr.isfile(data_path):
return LabeledVideoPaths.from_csv(data_path)
return cls.from_csv(data_path)
elif g_pathmgr.isdir(data_path):
return LabeledVideoPaths.from_directory(data_path)
return cls.from_directory(data_path)
else:
raise FileNotFoundError(f"{data_path} not found.")

Expand Down Expand Up @@ -107,7 +107,7 @@ def from_directory(cls, dir_path: str) -> LabeledVideoPaths:
return cls(video_paths_and_label)

def __init__(
self, paths_and_labels: List[Tuple[str, Optional[int]]], path_prefix=""
self, paths_and_labels: List[Tuple[str, Optional[int]]], path_prefix: str = ""
) -> None:
"""
Args:
Expand All @@ -117,12 +117,12 @@ def __init__(
self._paths_and_labels = paths_and_labels
self._path_prefix = path_prefix

def path_prefix(self, prefix):
def path_prefix(self, prefix: str) -> None:
self._path_prefix = prefix

path_prefix = property(None, path_prefix)

def __getitem__(self, index: int) -> Tuple[str, int]:
def __getitem__(self, index: int) -> Tuple[str, Dict[str, int]]:
"""
Args:
index (int): the path and label index.
Expand Down