From 4c6452960d00fc9fe09bca4762bc4bf92406ed78 Mon Sep 17 00:00:00 2001 From: ChiragAgg5k Date: Wed, 20 Nov 2024 23:41:16 +0530 Subject: [PATCH] fix: patch coverages --- lightly/data/_image.py | 11 +++-------- lightly/data/lightly_subset.py | 3 ++- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lightly/data/_image.py b/lightly/data/_image.py index 129031e4b..864913db1 100644 --- a/lightly/data/_image.py +++ b/lightly/data/_image.py @@ -13,11 +13,6 @@ from lightly.data._image_loaders import default_loader -class ImageLoader(Protocol): - def __call__(self, path: str) -> torch.Tensor: - ... - - class DatasetFolder(datasets.VisionDataset): # type: ignore """Implements a dataset folder. @@ -46,7 +41,7 @@ class DatasetFolder(datasets.VisionDataset): # type: ignore def __init__( self, root: str, - loader: ImageLoader = default_loader, + loader: Callable[[str], Any] = default_loader, extensions: Optional[Tuple[str, ...]] = None, transform: Optional[Callable[[Any], Any]] = None, target_transform: Optional[Callable[[Any], Any]] = None, @@ -73,9 +68,9 @@ def __init__( samples = _make_dataset(self.root, extensions, is_valid_file) if len(samples) == 0: - msg = f"Found 0 files in folder: {self.root}\n" + msg = "Found 0 files in folder: {}\n".format(self.root) if extensions is not None: - msg += f"Supported extensions are: {','.join(extensions)}" + msg += "Supported extensions are: {}".format(",".join(extensions)) raise RuntimeError(msg) self.loader = loader diff --git a/lightly/data/lightly_subset.py b/lightly/data/lightly_subset.py index 4ee1836a0..2dc77fe6e 100644 --- a/lightly/data/lightly_subset.py +++ b/lightly/data/lightly_subset.py @@ -74,7 +74,8 @@ def index_to_filename( Returns: The filename of the sample at the specified subset index. """ - return self.filenames_subset[index_subset] + fname = self.filenames_subset[index_subset] + return fname @property def input_dir(self) -> str: