Unverified Commit e0068d8e authored by F-G Fernandez's avatar F-G Fernandez Committed by GitHub
Browse files

Added missing typing annotations in dataset __getitem__ (#6843)



* style: Fixed typing of dataset __getitem__

* style: Fixed last missing typing
Co-authored-by: default avatarPhilip Meier <github.pmeier@posteo.de>
parent e1f464bd
import os import os
import pathlib import pathlib
from typing import Callable, Optional from typing import Any, Callable, Optional, Tuple
import PIL.Image import PIL.Image
...@@ -76,7 +76,7 @@ class DTD(VisionDataset): ...@@ -76,7 +76,7 @@ class DTD(VisionDataset):
def __len__(self) -> int: def __len__(self) -> int:
return len(self._image_files) return len(self._image_files)
def __getitem__(self, idx): def __getitem__(self, idx: int) -> Tuple[Any, Any]:
image_file, label = self._image_files[idx], self._labels[idx] image_file, label = self._image_files[idx], self._labels[idx]
image = PIL.Image.open(image_file).convert("RGB") image = PIL.Image.open(image_file).convert("RGB")
......
...@@ -90,7 +90,7 @@ class FGVCAircraft(VisionDataset): ...@@ -90,7 +90,7 @@ class FGVCAircraft(VisionDataset):
def __len__(self) -> int: def __len__(self) -> int:
return len(self._image_files) return len(self._image_files)
def __getitem__(self, idx) -> Tuple[Any, Any]: def __getitem__(self, idx: int) -> Tuple[Any, Any]:
image_file, label = self._image_files[idx], self._labels[idx] image_file, label = self._image_files[idx], self._labels[idx]
image = PIL.Image.open(image_file).convert("RGB") image = PIL.Image.open(image_file).convert("RGB")
......
...@@ -76,7 +76,7 @@ class Flowers102(VisionDataset): ...@@ -76,7 +76,7 @@ class Flowers102(VisionDataset):
def __len__(self) -> int: def __len__(self) -> int:
return len(self._image_files) return len(self._image_files)
def __getitem__(self, idx) -> Tuple[Any, Any]: def __getitem__(self, idx: int) -> Tuple[Any, Any]:
image_file, label = self._image_files[idx], self._labels[idx] image_file, label = self._image_files[idx], self._labels[idx]
image = PIL.Image.open(image_file).convert("RGB") image = PIL.Image.open(image_file).convert("RGB")
......
...@@ -69,7 +69,7 @@ class Food101(VisionDataset): ...@@ -69,7 +69,7 @@ class Food101(VisionDataset):
def __len__(self) -> int: def __len__(self) -> int:
return len(self._image_files) return len(self._image_files)
def __getitem__(self, idx) -> Tuple[Any, Any]: def __getitem__(self, idx: int) -> Tuple[Any, Any]:
image_file, label = self._image_files[idx], self._labels[idx] image_file, label = self._image_files[idx], self._labels[idx]
image = PIL.Image.open(image_file).convert("RGB") image = PIL.Image.open(image_file).convert("RGB")
......
...@@ -59,7 +59,7 @@ class RenderedSST2(VisionDataset): ...@@ -59,7 +59,7 @@ class RenderedSST2(VisionDataset):
def __len__(self) -> int: def __len__(self) -> int:
return len(self._samples) return len(self._samples)
def __getitem__(self, idx) -> Tuple[Any, Any]: def __getitem__(self, idx: int) -> Tuple[Any, Any]:
image_file, label = self._samples[idx] image_file, label = self._samples[idx]
image = PIL.Image.open(image_file).convert("RGB") image = PIL.Image.open(image_file).convert("RGB")
......
...@@ -55,7 +55,7 @@ class SUN397(VisionDataset): ...@@ -55,7 +55,7 @@ class SUN397(VisionDataset):
def __len__(self) -> int: def __len__(self) -> int:
return len(self._image_files) return len(self._image_files)
def __getitem__(self, idx) -> Tuple[Any, Any]: def __getitem__(self, idx: int) -> Tuple[Any, Any]:
image_file, label = self._image_files[idx], self._labels[idx] image_file, label = self._image_files[idx], self._labels[idx]
image = PIL.Image.open(image_file).convert("RGB") image = PIL.Image.open(image_file).convert("RGB")
......
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