From 4f26fee9117c1653c1ffbd3203a35ed6f3fed325 Mon Sep 17 00:00:00 2001
From: Patrick Labatut <60359573+patricklabatut@users.noreply.github.com>
Date: Wed, 26 Apr 2023 00:06:05 +0200
Subject: [PATCH] Datasets interface cleanup (#59)

Remove unused sample decoding interface in datasets.
---
 dinov2/data/adapters.py               |  3 ---
 dinov2/data/datasets/decoders.py      | 10 +---------
 dinov2/data/datasets/extended.py      | 10 +---------
 dinov2/data/datasets/image_net_22k.py |  1 -
 4 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/dinov2/data/adapters.py b/dinov2/data/adapters.py
index fe9ce78..7dcbc68 100644
--- a/dinov2/data/adapters.py
+++ b/dinov2/data/adapters.py
@@ -20,9 +20,6 @@ class DatasetWithEnumeratedTargets(Dataset):
         target = self._dataset.get_target(index)
         return (index, target)
 
-    def get_sample_decoder(self, index: int) -> Any:
-        return self._dataset.get_sample_decoder(index)
-
     def __getitem__(self, index: int) -> Tuple[Any, Tuple[Any, int]]:
         image, target = self._dataset[index]
         target = index if target is None else target
diff --git a/dinov2/data/datasets/decoders.py b/dinov2/data/datasets/decoders.py
index ec6daee..548720b 100644
--- a/dinov2/data/datasets/decoders.py
+++ b/dinov2/data/datasets/decoders.py
@@ -5,7 +5,7 @@
 # LICENSE file in the root directory of this source tree.
 
 from io import BytesIO
-from typing import Any, Tuple
+from typing import Any
 
 from PIL import Image
 
@@ -30,11 +30,3 @@ class TargetDecoder(Decoder):
 
     def decode(self) -> Any:
         return self._target
-
-
-class TupleDecoder(Decoder):
-    def __init__(self, *decoders: Decoder):
-        self._decoders: Tuple[Decoder, ...] = decoders
-
-    def decode(self) -> Any:
-        return (decoder.decode() for decoder in self._decoders)
diff --git a/dinov2/data/datasets/extended.py b/dinov2/data/datasets/extended.py
index 4189463..4da831e 100644
--- a/dinov2/data/datasets/extended.py
+++ b/dinov2/data/datasets/extended.py
@@ -8,7 +8,7 @@ from typing import Any, Tuple
 
 from torchvision.datasets import VisionDataset
 
-from .decoders import Decoder, TargetDecoder, ImageDataDecoder, TupleDecoder
+from .decoders import TargetDecoder, ImageDataDecoder
 
 
 class ExtendedVisionDataset(VisionDataset):
@@ -35,13 +35,5 @@ class ExtendedVisionDataset(VisionDataset):
 
         return image, target
 
-    def get_sample_decoder(self, index: int) -> Decoder:
-        image_data = self.get_image_data(index)
-        target = self.get_target(index)
-        return TupleDecoder(
-            ImageDataDecoder(image_data),
-            TargetDecoder(target),
-        )
-
     def __len__(self) -> int:
         raise NotImplementedError
diff --git a/dinov2/data/datasets/image_net_22k.py b/dinov2/data/datasets/image_net_22k.py
index 323ee6f..2c0bfd3 100644
--- a/dinov2/data/datasets/image_net_22k.py
+++ b/dinov2/data/datasets/image_net_22k.py
@@ -22,7 +22,6 @@ from .extended import ExtendedVisionDataset
 _Labels = int
 
 _DEFAULT_MMAP_CACHE_SIZE = 16  # Warning: This can exhaust file descriptors
-_IMAGES_SUBDIR_IMAGENET_21KP = "062717"
 
 
 @dataclass
-- 
GitLab