We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Make transform settable in Lightly Dataset 
Currently if one has created a Lightly Dataset and wants to apply transforms at a later stage, we have to do it as follows:
```
dataset = data.LightlyDataset(root="./", name='CIFAR10', download=True)
...
use dataset to train SimCLR model for example
...
test_transforms = torchvision.transforms.ToTensor()
dataset.dataset.transform = test_transforms
```

We should extend the Dataset wrapper to directly support transforms.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `lightly/data/dataset.py`
Content:
```
1 """ Lightly Dataset """
2 
3 # Copyright (c) 2020. Lightly AG and its affiliates.
4 # All Rights Reserved
5 
6 import os
7 import shutil
8 from PIL import Image
9 from typing import List, Union
10 
11 import torch.utils.data as data
12 import torchvision.datasets as datasets
13 
14 from lightly.data._helpers import _load_dataset
15 from lightly.data._helpers import DatasetFolder
16 from lightly.data._video import VideoDataset
17 
18 
19 def _get_filename_by_index(dataset, index):
20     """Default function which maps the index of an image to a filename.
21 
22     """
23     if isinstance(dataset, datasets.ImageFolder):
24         # filename is the path of the image relative to the dataset root
25         full_path = dataset.imgs[index][0]
26         return os.path.relpath(full_path, dataset.root)
27     elif isinstance(dataset, DatasetFolder):
28         # filename is the path of the image relative to the dataset root
29         full_path = dataset.samples[index][0]
30         return os.path.relpath(full_path, dataset.root)
31     elif isinstance(dataset, VideoDataset):
32         # filename is constructed by the video dataset
33         return dataset.get_filename(index)
34     else:
35         # dummy to prevent crashes
36         return str(index)
37 
38 
39 def _ensure_dir(path):
40     """Makes sure that the directory at path exists.
41 
42     """
43     dirname = os.path.dirname(path)
44     os.makedirs(dirname, exist_ok=True)
45 
46 
47 def _copy_image(input_dir, output_dir, filename):
48     """Copies an image from the input directory to the output directory.
49 
50     """
51     source = os.path.join(input_dir, filename)
52     target = os.path.join(output_dir, filename)
53     _ensure_dir(target)
54     shutil.copyfile(source, target)
55 
56 def _save_image(image, output_dir, filename, fmt):
57     """Saves an image in the output directory.
58 
59     """
60     target = os.path.join(output_dir, filename)
61     _ensure_dir(target)
62     try:
63         # try to save the image with the specified format or
64         # derive the format from the filename (if format=None)
65         image.save(target, format=fmt)
66     except ValueError:
67         # could not determine format from filename
68         image.save(target, format='png')
69 
70 
71 def _dump_image(dataset, output_dir, filename, index, fmt):
72     """Saves a single image to the output directory.
73 
74     Will copy the image from the input directory to the output directory
75     if possible. If not (e.g. for VideoDatasets), will load the image and
76     then save it to the output directory with the specified format.
77 
78     """
79 
80     if isinstance(dataset, datasets.ImageFolder):
81         # can safely copy the image from the input to the output directory
82         _copy_image(dataset.root, output_dir, filename)
83     elif isinstance(dataset, DatasetFolder):
84         # can safely copy the image from the input to the output directory
85         _copy_image(dataset.root, output_dir, filename)
86     else:
87         # need to load the image and save it to the output directory
88         image, _ = dataset[index]
89         _save_image(image, output_dir, filename, fmt)
90 
91 
92 class LightlyDataset:
93     """Provides a uniform data interface for the embedding models.
94 
95     Should be used for all models and functions in the lightly package.
96     Returns a tuple (sample, target, fname) when accessed using __getitem__
97 
98     Can either be used to load a dataset offered by torchvision (e.g. cifar10)
99     or to load a custom dataset from an input folder.
100 
101     Args:
102         input_dir:
103             Path to directory holding the images to load.
104         transform:
105             Image transforms (as in torchvision).
106         index_to_filename:
107             Function which takes the dataset and index as input and returns
108             the filename of the file at the index. If None, uses default.
109 
110     Examples:
111         >>> # load cifar10 from a local folder
112         >>> import lightly.data as data
113         >>> dataset = data.LightlyDataset(input_dir='path/to/cifar10/')
114         >>> sample, target, fname = dataset[0]
115 
116     """
117 
118     def __init__(self,
119                  input_dir: str,
120                  transform=None,
121                  index_to_filename=None):
122 
123         # can pass input_dir=None to create an "empty" dataset
124         self.input_dir = input_dir
125         if self.input_dir is not None:
126             self.dataset = _load_dataset(self.input_dir, transform)
127 
128         # initialize function to get filename of image
129         self.index_to_filename = _get_filename_by_index
130         if index_to_filename is  not None:
131             self.index_to_filename = index_to_filename
132 
133     @classmethod
134     def from_torch_dataset(cls,
135                            dataset,
136                            transform=None,
137                            index_to_filename=None):
138         """Builds a LightlyDataset from a PyTorch (or torchvision) dataset.
139 
140         Args:
141             dataset:
142                 PyTorch/torchvision dataset.
143             transform:
144                 Image transforms (as in torchvision).
145             index_to_filename:
146                 Function which takes the dataset and index as input and returns
147                 the filename of the file at the index. If None, uses default.
148 
149         Returns:
150             A LightlyDataset object.
151 
152         Examples:
153         >>> # load cifar10 from torchvision
154         >>> import torchvision
155         >>> import lightly.data as data
156         >>> base = torchvision.datasets.CIFAR10(root='./')
157         >>> dataset = data.LightlyDataset.from_torch_dataset(base)
158 
159         """
160         # create an "empty" dataset object
161         dataset_obj = cls(
162             None,
163             transform=transform,
164             index_to_filename=index_to_filename
165         )
166 
167         # populate it with the torch dataset
168         dataset_obj.dataset = dataset
169         return dataset_obj
170 
171     def __getitem__(self, index: int):
172         """Returns (sample, target, fname) of item at index.
173 
174         Args:
175             index:
176                 Index of the queried item.
177 
178         Returns:
179             The image, target, and filename of the item at index.
180 
181         """
182         fname = self.index_to_filename(self.dataset, index)
183         sample, target = self.dataset.__getitem__(index)
184         
185         return sample, target, fname
186 
187 
188     def __len__(self):
189         """Returns the length of the dataset.
190 
191         """
192         return len(self.dataset)
193 
194     def __add__(self, other):
195         """Adds another item to the dataset.
196 
197         """
198         raise NotImplementedError()
199 
200     def get_filenames(self) -> List[str]:
201         """Returns all filenames in the dataset.
202 
203         """
204         list_of_filenames = []
205         for index in range(len(self)):
206             fname = self.index_to_filename(self.dataset, index)
207             list_of_filenames.append(fname)
208         return list_of_filenames
209 
210     def dump(self,
211              output_dir: str,
212              filenames: Union[List[str], None] = None,
213              format: Union[str, None] = None):
214         """Saves images in the dataset to the output directory.
215 
216         Will copy the images from the input directory to the output directory
217         if possible. If not (e.g. for VideoDatasets), will load the images and
218         then save them to the output directory with the specified format.
219 
220         Args:
221             output_dir:
222                 Output directory where the image is stored.
223             filenames:
224                 Filenames of the images to store. If None, stores all images.
225             format:
226                 Image format.
227 
228         """
229 
230         if self.dataset.transform is not None:
231             raise RuntimeError('Cannot dump dataset which applies transforms!')
232 
233         # create directory if it doesn't exist yet
234         os.makedirs(output_dir, exist_ok=True)
235 
236         # dump all the files if no filenames were passed, otherwise dump only
237         # the ones referenced in the list
238         if filenames is None:
239             indices = [i for i in range(self.__len__())]
240             filenames = self.get_filenames()
241         else:
242             indices = []
243             all_filenames = self.get_filenames()
244             for i in range(len(filenames)):
245                 if filenames[i] in all_filenames:
246                     indices.append(i)
247 
248         # dump images
249         for i, filename in zip(indices, filenames):
250             _dump_image(self.dataset, output_dir, filename, i, fmt=format)
251
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/lightly/data/dataset.py b/lightly/data/dataset.py
--- a/lightly/data/dataset.py
+++ b/lightly/data/dataset.py
@@ -248,3 +248,17 @@
         # dump images
         for i, filename in zip(indices, filenames):
             _dump_image(self.dataset, output_dir, filename, i, fmt=format)
+
+    @property
+    def transform(self):
+        """Getter for the transform of the dataset.
+
+        """
+        return self.dataset.transform
+
+    @transform.setter
+    def transform(self, t):
+        """Setter for the transform of the dataset.
+
+        """
+        self.dataset.transform = t

{"golden_diff": "diff --git a/lightly/data/dataset.py b/lightly/data/dataset.py\n--- a/lightly/data/dataset.py\n+++ b/lightly/data/dataset.py\n@@ -248,3 +248,17 @@\n         # dump images\n         for i, filename in zip(indices, filenames):\n             _dump_image(self.dataset, output_dir, filename, i, fmt=format)\n+\n+    @property\n+    def transform(self):\n+        \"\"\"Getter for the transform of the dataset.\n+\n+        \"\"\"\n+        return self.dataset.transform\n+\n+    @transform.setter\n+    def transform(self, t):\n+        \"\"\"Setter for the transform of the dataset.\n+\n+        \"\"\"\n+        self.dataset.transform = t\n", "issue": "Make transform settable in Lightly Dataset \nCurrently if one has created a Lightly Dataset and wants to apply transforms at a later stage, we have to do it as follows:\r\n```\r\ndataset = data.LightlyDataset(root=\"./\", name='CIFAR10', download=True)\r\n...\r\nuse dataset to train SimCLR model for example\r\n...\r\ntest_transforms = torchvision.transforms.ToTensor()\r\ndataset.dataset.transform = test_transforms\r\n```\r\n\r\nWe should extend the Dataset wrapper to directly support transforms.\n", "before_files": [{"content": "\"\"\" Lightly Dataset \"\"\"\n\n# Copyright (c) 2020. Lightly AG and its affiliates.\n# All Rights Reserved\n\nimport os\nimport shutil\nfrom PIL import Image\nfrom typing import List, Union\n\nimport torch.utils.data as data\nimport torchvision.datasets as datasets\n\nfrom lightly.data._helpers import _load_dataset\nfrom lightly.data._helpers import DatasetFolder\nfrom lightly.data._video import VideoDataset\n\n\ndef _get_filename_by_index(dataset, index):\n    \"\"\"Default function which maps the index of an image to a filename.\n\n    \"\"\"\n    if isinstance(dataset, datasets.ImageFolder):\n        # filename is the path of the image relative to the dataset root\n        full_path = dataset.imgs[index][0]\n        return os.path.relpath(full_path, dataset.root)\n    elif isinstance(dataset, DatasetFolder):\n        # filename is the path of the image relative to the dataset root\n        full_path = dataset.samples[index][0]\n        return os.path.relpath(full_path, dataset.root)\n    elif isinstance(dataset, VideoDataset):\n        # filename is constructed by the video dataset\n        return dataset.get_filename(index)\n    else:\n        # dummy to prevent crashes\n        return str(index)\n\n\ndef _ensure_dir(path):\n    \"\"\"Makes sure that the directory at path exists.\n\n    \"\"\"\n    dirname = os.path.dirname(path)\n    os.makedirs(dirname, exist_ok=True)\n\n\ndef _copy_image(input_dir, output_dir, filename):\n    \"\"\"Copies an image from the input directory to the output directory.\n\n    \"\"\"\n    source = os.path.join(input_dir, filename)\n    target = os.path.join(output_dir, filename)\n    _ensure_dir(target)\n    shutil.copyfile(source, target)\n\ndef _save_image(image, output_dir, filename, fmt):\n    \"\"\"Saves an image in the output directory.\n\n    \"\"\"\n    target = os.path.join(output_dir, filename)\n    _ensure_dir(target)\n    try:\n        # try to save the image with the specified format or\n        # derive the format from the filename (if format=None)\n        image.save(target, format=fmt)\n    except ValueError:\n        # could not determine format from filename\n        image.save(target, format='png')\n\n\ndef _dump_image(dataset, output_dir, filename, index, fmt):\n    \"\"\"Saves a single image to the output directory.\n\n    Will copy the image from the input directory to the output directory\n    if possible. If not (e.g. for VideoDatasets), will load the image and\n    then save it to the output directory with the specified format.\n\n    \"\"\"\n\n    if isinstance(dataset, datasets.ImageFolder):\n        # can safely copy the image from the input to the output directory\n        _copy_image(dataset.root, output_dir, filename)\n    elif isinstance(dataset, DatasetFolder):\n        # can safely copy the image from the input to the output directory\n        _copy_image(dataset.root, output_dir, filename)\n    else:\n        # need to load the image and save it to the output directory\n        image, _ = dataset[index]\n        _save_image(image, output_dir, filename, fmt)\n\n\nclass LightlyDataset:\n    \"\"\"Provides a uniform data interface for the embedding models.\n\n    Should be used for all models and functions in the lightly package.\n    Returns a tuple (sample, target, fname) when accessed using __getitem__\n\n    Can either be used to load a dataset offered by torchvision (e.g. cifar10)\n    or to load a custom dataset from an input folder.\n\n    Args:\n        input_dir:\n            Path to directory holding the images to load.\n        transform:\n            Image transforms (as in torchvision).\n        index_to_filename:\n            Function which takes the dataset and index as input and returns\n            the filename of the file at the index. If None, uses default.\n\n    Examples:\n        >>> # load cifar10 from a local folder\n        >>> import lightly.data as data\n        >>> dataset = data.LightlyDataset(input_dir='path/to/cifar10/')\n        >>> sample, target, fname = dataset[0]\n\n    \"\"\"\n\n    def __init__(self,\n                 input_dir: str,\n                 transform=None,\n                 index_to_filename=None):\n\n        # can pass input_dir=None to create an \"empty\" dataset\n        self.input_dir = input_dir\n        if self.input_dir is not None:\n            self.dataset = _load_dataset(self.input_dir, transform)\n\n        # initialize function to get filename of image\n        self.index_to_filename = _get_filename_by_index\n        if index_to_filename is  not None:\n            self.index_to_filename = index_to_filename\n\n    @classmethod\n    def from_torch_dataset(cls,\n                           dataset,\n                           transform=None,\n                           index_to_filename=None):\n        \"\"\"Builds a LightlyDataset from a PyTorch (or torchvision) dataset.\n\n        Args:\n            dataset:\n                PyTorch/torchvision dataset.\n            transform:\n                Image transforms (as in torchvision).\n            index_to_filename:\n                Function which takes the dataset and index as input and returns\n                the filename of the file at the index. If None, uses default.\n\n        Returns:\n            A LightlyDataset object.\n\n        Examples:\n        >>> # load cifar10 from torchvision\n        >>> import torchvision\n        >>> import lightly.data as data\n        >>> base = torchvision.datasets.CIFAR10(root='./')\n        >>> dataset = data.LightlyDataset.from_torch_dataset(base)\n\n        \"\"\"\n        # create an \"empty\" dataset object\n        dataset_obj = cls(\n            None,\n            transform=transform,\n            index_to_filename=index_to_filename\n        )\n\n        # populate it with the torch dataset\n        dataset_obj.dataset = dataset\n        return dataset_obj\n\n    def __getitem__(self, index: int):\n        \"\"\"Returns (sample, target, fname) of item at index.\n\n        Args:\n            index:\n                Index of the queried item.\n\n        Returns:\n            The image, target, and filename of the item at index.\n\n        \"\"\"\n        fname = self.index_to_filename(self.dataset, index)\n        sample, target = self.dataset.__getitem__(index)\n        \n        return sample, target, fname\n\n\n    def __len__(self):\n        \"\"\"Returns the length of the dataset.\n\n        \"\"\"\n        return len(self.dataset)\n\n    def __add__(self, other):\n        \"\"\"Adds another item to the dataset.\n\n        \"\"\"\n        raise NotImplementedError()\n\n    def get_filenames(self) -> List[str]:\n        \"\"\"Returns all filenames in the dataset.\n\n        \"\"\"\n        list_of_filenames = []\n        for index in range(len(self)):\n            fname = self.index_to_filename(self.dataset, index)\n            list_of_filenames.append(fname)\n        return list_of_filenames\n\n    def dump(self,\n             output_dir: str,\n             filenames: Union[List[str], None] = None,\n             format: Union[str, None] = None):\n        \"\"\"Saves images in the dataset to the output directory.\n\n        Will copy the images from the input directory to the output directory\n        if possible. If not (e.g. for VideoDatasets), will load the images and\n        then save them to the output directory with the specified format.\n\n        Args:\n            output_dir:\n                Output directory where the image is stored.\n            filenames:\n                Filenames of the images to store. If None, stores all images.\n            format:\n                Image format.\n\n        \"\"\"\n\n        if self.dataset.transform is not None:\n            raise RuntimeError('Cannot dump dataset which applies transforms!')\n\n        # create directory if it doesn't exist yet\n        os.makedirs(output_dir, exist_ok=True)\n\n        # dump all the files if no filenames were passed, otherwise dump only\n        # the ones referenced in the list\n        if filenames is None:\n            indices = [i for i in range(self.__len__())]\n            filenames = self.get_filenames()\n        else:\n            indices = []\n            all_filenames = self.get_filenames()\n            for i in range(len(filenames)):\n                if filenames[i] in all_filenames:\n                    indices.append(i)\n\n        # dump images\n        for i, filename in zip(indices, filenames):\n            _dump_image(self.dataset, output_dir, filename, i, fmt=format)\n", "path": "lightly/data/dataset.py"}], "after_files": [{"content": "\"\"\" Lightly Dataset \"\"\"\n\n# Copyright (c) 2020. Lightly AG and its affiliates.\n# All Rights Reserved\n\nimport os\nimport shutil\nfrom PIL import Image\nfrom typing import List, Union\n\nimport torch.utils.data as data\nimport torchvision.datasets as datasets\n\nfrom lightly.data._helpers import _load_dataset\nfrom lightly.data._helpers import DatasetFolder\nfrom lightly.data._video import VideoDataset\n\n\ndef _get_filename_by_index(dataset, index):\n    \"\"\"Default function which maps the index of an image to a filename.\n\n    \"\"\"\n    if isinstance(dataset, datasets.ImageFolder):\n        # filename is the path of the image relative to the dataset root\n        full_path = dataset.imgs[index][0]\n        return os.path.relpath(full_path, dataset.root)\n    elif isinstance(dataset, DatasetFolder):\n        # filename is the path of the image relative to the dataset root\n        full_path = dataset.samples[index][0]\n        return os.path.relpath(full_path, dataset.root)\n    elif isinstance(dataset, VideoDataset):\n        # filename is constructed by the video dataset\n        return dataset.get_filename(index)\n    else:\n        # dummy to prevent crashes\n        return str(index)\n\n\ndef _ensure_dir(path):\n    \"\"\"Makes sure that the directory at path exists.\n\n    \"\"\"\n    dirname = os.path.dirname(path)\n    os.makedirs(dirname, exist_ok=True)\n\n\ndef _copy_image(input_dir, output_dir, filename):\n    \"\"\"Copies an image from the input directory to the output directory.\n\n    \"\"\"\n    source = os.path.join(input_dir, filename)\n    target = os.path.join(output_dir, filename)\n    _ensure_dir(target)\n    shutil.copyfile(source, target)\n\ndef _save_image(image, output_dir, filename, fmt):\n    \"\"\"Saves an image in the output directory.\n\n    \"\"\"\n    target = os.path.join(output_dir, filename)\n    _ensure_dir(target)\n    try:\n        # try to save the image with the specified format or\n        # derive the format from the filename (if format=None)\n        image.save(target, format=fmt)\n    except ValueError:\n        # could not determine format from filename\n        image.save(target, format='png')\n\n\ndef _dump_image(dataset, output_dir, filename, index, fmt):\n    \"\"\"Saves a single image to the output directory.\n\n    Will copy the image from the input directory to the output directory\n    if possible. If not (e.g. for VideoDatasets), will load the image and\n    then save it to the output directory with the specified format.\n\n    \"\"\"\n\n    if isinstance(dataset, datasets.ImageFolder):\n        # can safely copy the image from the input to the output directory\n        _copy_image(dataset.root, output_dir, filename)\n    elif isinstance(dataset, DatasetFolder):\n        # can safely copy the image from the input to the output directory\n        _copy_image(dataset.root, output_dir, filename)\n    else:\n        # need to load the image and save it to the output directory\n        image, _ = dataset[index]\n        _save_image(image, output_dir, filename, fmt)\n\n\nclass LightlyDataset:\n    \"\"\"Provides a uniform data interface for the embedding models.\n\n    Should be used for all models and functions in the lightly package.\n    Returns a tuple (sample, target, fname) when accessed using __getitem__\n\n    Can either be used to load a dataset offered by torchvision (e.g. cifar10)\n    or to load a custom dataset from an input folder.\n\n    Args:\n        input_dir:\n            Path to directory holding the images to load.\n        transform:\n            Image transforms (as in torchvision).\n        index_to_filename:\n            Function which takes the dataset and index as input and returns\n            the filename of the file at the index. If None, uses default.\n\n    Examples:\n        >>> # load cifar10 from a local folder\n        >>> import lightly.data as data\n        >>> dataset = data.LightlyDataset(input_dir='path/to/cifar10/')\n        >>> sample, target, fname = dataset[0]\n\n    \"\"\"\n\n    def __init__(self,\n                 input_dir: str,\n                 transform=None,\n                 index_to_filename=None):\n\n        # can pass input_dir=None to create an \"empty\" dataset\n        self.input_dir = input_dir\n        if self.input_dir is not None:\n            self.dataset = _load_dataset(self.input_dir, transform)\n\n        # initialize function to get filename of image\n        self.index_to_filename = _get_filename_by_index\n        if index_to_filename is  not None:\n            self.index_to_filename = index_to_filename\n\n    @classmethod\n    def from_torch_dataset(cls,\n                           dataset,\n                           transform=None,\n                           index_to_filename=None):\n        \"\"\"Builds a LightlyDataset from a PyTorch (or torchvision) dataset.\n\n        Args:\n            dataset:\n                PyTorch/torchvision dataset.\n            transform:\n                Image transforms (as in torchvision).\n            index_to_filename:\n                Function which takes the dataset and index as input and returns\n                the filename of the file at the index. If None, uses default.\n\n        Returns:\n            A LightlyDataset object.\n\n        Examples:\n        >>> # load cifar10 from torchvision\n        >>> import torchvision\n        >>> import lightly.data as data\n        >>> base = torchvision.datasets.CIFAR10(root='./')\n        >>> dataset = data.LightlyDataset.from_torch_dataset(base)\n\n        \"\"\"\n        # create an \"empty\" dataset object\n        dataset_obj = cls(\n            None,\n            transform=transform,\n            index_to_filename=index_to_filename\n        )\n\n        # populate it with the torch dataset\n        dataset_obj.dataset = dataset\n        return dataset_obj\n\n    def __getitem__(self, index: int):\n        \"\"\"Returns (sample, target, fname) of item at index.\n\n        Args:\n            index:\n                Index of the queried item.\n\n        Returns:\n            The image, target, and filename of the item at index.\n\n        \"\"\"\n        fname = self.index_to_filename(self.dataset, index)\n        sample, target = self.dataset.__getitem__(index)\n        \n        return sample, target, fname\n\n\n    def __len__(self):\n        \"\"\"Returns the length of the dataset.\n\n        \"\"\"\n        return len(self.dataset)\n\n    def __add__(self, other):\n        \"\"\"Adds another item to the dataset.\n\n        \"\"\"\n        raise NotImplementedError()\n\n    def get_filenames(self) -> List[str]:\n        \"\"\"Returns all filenames in the dataset.\n\n        \"\"\"\n        list_of_filenames = []\n        for index in range(len(self)):\n            fname = self.index_to_filename(self.dataset, index)\n            list_of_filenames.append(fname)\n        return list_of_filenames\n\n    def dump(self,\n             output_dir: str,\n             filenames: Union[List[str], None] = None,\n             format: Union[str, None] = None):\n        \"\"\"Saves images in the dataset to the output directory.\n\n        Will copy the images from the input directory to the output directory\n        if possible. If not (e.g. for VideoDatasets), will load the images and\n        then save them to the output directory with the specified format.\n\n        Args:\n            output_dir:\n                Output directory where the image is stored.\n            filenames:\n                Filenames of the images to store. If None, stores all images.\n            format:\n                Image format.\n\n        \"\"\"\n\n        if self.dataset.transform is not None:\n            raise RuntimeError('Cannot dump dataset which applies transforms!')\n\n        # create directory if it doesn't exist yet\n        os.makedirs(output_dir, exist_ok=True)\n\n        # dump all the files if no filenames were passed, otherwise dump only\n        # the ones referenced in the list\n        if filenames is None:\n            indices = [i for i in range(self.__len__())]\n            filenames = self.get_filenames()\n        else:\n            indices = []\n            all_filenames = self.get_filenames()\n            for i in range(len(filenames)):\n                if filenames[i] in all_filenames:\n                    indices.append(i)\n\n        # dump images\n        for i, filename in zip(indices, filenames):\n            _dump_image(self.dataset, output_dir, filename, i, fmt=format)\n\n    @property\n    def transform(self):\n        \"\"\"Getter for the transform of the dataset.\n\n        \"\"\"\n        return self.dataset.transform\n\n    @transform.setter\n    def transform(self, t):\n        \"\"\"Setter for the transform of the dataset.\n\n        \"\"\"\n        self.dataset.transform = t\n", "path": "lightly/data/dataset.py"}]}