We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Ignore lightly outputs when creating a dataset
When working on a folder of images, e.g.
```
dataset/
L image_1.jpg
L image_2.jpg
L image_3.jpg
```
the following commands will not work when in the dataset directory:
```
lightly-embed input_dir=./
lightly-train input_dir=./
lightly-magic input_dir=./
```

This is because the command-line tool creates a directory `lightly_outputs` where logs and results are stored. However, when creating the `LightlyDataset`, this directory will be interpreted as a subfolder with images in it which leads to an error. We can handle this by ignoring the `lightly_outputs` directory.

--- 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/_helpers.py`
Content:
```
1 """ Helper Functions """
2 
3 # Copyright (c) 2020. Lightly AG and its affiliates.
4 # All Rights Reserved
5 
6 import os
7 from torchvision import datasets
8 
9 from lightly.data._image import DatasetFolder
10 
11 try:
12     from lightly.data._video import VideoDataset
13     VIDEO_DATASET_AVAILABLE = True
14 except Exception as e:
15     VIDEO_DATASET_AVAILABLE = False
16     VIDEO_DATASET_ERRORMSG = e
17 
18 
19 IMG_EXTENSIONS = ('.jpg', '.jpeg', '.png', '.ppm', '.bmp',
20                   '.pgm', '.tif', '.tiff', '.webp')
21 
22 VIDEO_EXTENSIONS = ('.mp4', '.mov', '.avi')
23 
24 
25 def _contains_videos(root: str, extensions: tuple):
26     """Checks whether directory contains video files.
27 
28     Args:
29         root: Root directory path.
30 
31     Returns:
32         True if root contains subdirectories else false.
33     """
34     list_dir = os.listdir(root)
35     is_video = \
36         [f.lower().endswith(extensions) for f in list_dir]
37     return any(is_video)
38 
39 
40 def _contains_subdirs(root: str):
41     """Checks whether directory contains subdirectories.
42 
43     Args:
44         root: Root directory path.
45 
46     Returns:
47         True if root contains subdirectories else false.
48 
49     """
50     list_dir = os.listdir(root)
51     is_dir = \
52         [os.path.isdir(os.path.join(root, f)) for f in list_dir]
53     return any(is_dir)
54 
55 
56 def _load_dataset_from_folder(root: str, transform):
57     """Initializes dataset from folder.
58 
59     Args:
60         root: (str) Root directory path
61         transform: (torchvision.transforms.Compose) image transformations
62 
63     Returns:
64         Dataset consisting of images in the root directory.
65 
66     """
67 
68     # if there is a video in the input directory but we do not have
69     # the right dependencies, raise a ValueError
70     contains_videos = _contains_videos(root, VIDEO_EXTENSIONS)
71     if contains_videos and not VIDEO_DATASET_AVAILABLE:
72         raise ValueError(f'The input directory {root} contains videos '
73                          'but the VideoDataset is not available. \n'
74                          'Make sure you have installed the right '
75                          'dependencies. The error from the imported '
76                          f'module was: {VIDEO_DATASET_ERRORMSG}')
77 
78     if contains_videos:
79         # root contains videos -> create a video dataset
80         dataset = VideoDataset(root,
81                                extensions=VIDEO_EXTENSIONS,
82                                transform=transform)
83     elif _contains_subdirs(root):
84         # root contains subdirectories -> create an image folder dataset
85         dataset = datasets.ImageFolder(root,
86                                        transform=transform)
87     else:
88         # root contains plain images -> create a folder dataset
89         dataset = DatasetFolder(root,
90                                 extensions=IMG_EXTENSIONS,
91                                 transform=transform)
92 
93     return dataset
94 
95 
96 def _load_dataset(input_dir: str,
97                   transform=None):
98     """Initializes dataset from torchvision or from folder.
99 
100     Args:
101         root: (str) Directory where dataset is stored
102         name: (str) Name of the dataset (e.g. cifar10, cifar100)
103         train: (bool) Use the training set
104         download: (bool) Download the dataset
105         transform: (torchvision.transforms.Compose) image transformations
106         from_folder: (str) Path to directory holding the images to load.
107 
108     Returns:
109         A torchvision dataset
110 
111     Raises:
112         ValueError: If the specified dataset doesn't exist
113 
114     """
115 
116     if not os.path.exists(input_dir):
117         raise ValueError(f'The input directory {input_dir} does not exist!')
118 
119     return _load_dataset_from_folder(input_dir, transform)
120
```
--- 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/_helpers.py b/lightly/data/_helpers.py
--- a/lightly/data/_helpers.py
+++ b/lightly/data/_helpers.py
@@ -37,6 +37,19 @@
     return any(is_video)
 
 
+def _is_lightly_output_dir(dirname: str):
+    """Checks whether the directory is a lightly_output directory.
+
+    Args:
+        dirname: Directory to check.
+
+    Returns:
+        True if dirname is "lightly_outputs" else false.
+
+    """
+    return 'lightly_outputs' in dirname
+
+
 def _contains_subdirs(root: str):
     """Checks whether directory contains subdirectories.
 
@@ -48,6 +61,7 @@
 
     """
     list_dir = os.listdir(root)
+    list_dir = list(filter(lambda x: not _is_lightly_output_dir(x), list_dir))
     is_dir = \
         [os.path.isdir(os.path.join(root, f)) for f in list_dir]
     return any(is_dir)

{"golden_diff": "diff --git a/lightly/data/_helpers.py b/lightly/data/_helpers.py\n--- a/lightly/data/_helpers.py\n+++ b/lightly/data/_helpers.py\n@@ -37,6 +37,19 @@\n     return any(is_video)\n \n \n+def _is_lightly_output_dir(dirname: str):\n+    \"\"\"Checks whether the directory is a lightly_output directory.\n+\n+    Args:\n+        dirname: Directory to check.\n+\n+    Returns:\n+        True if dirname is \"lightly_outputs\" else false.\n+\n+    \"\"\"\n+    return 'lightly_outputs' in dirname\n+\n+\n def _contains_subdirs(root: str):\n     \"\"\"Checks whether directory contains subdirectories.\n \n@@ -48,6 +61,7 @@\n \n     \"\"\"\n     list_dir = os.listdir(root)\n+    list_dir = list(filter(lambda x: not _is_lightly_output_dir(x), list_dir))\n     is_dir = \\\n         [os.path.isdir(os.path.join(root, f)) for f in list_dir]\n     return any(is_dir)\n", "issue": "Ignore lightly outputs when creating a dataset\nWhen working on a folder of images, e.g.\r\n```\r\ndataset/\r\nL image_1.jpg\r\nL image_2.jpg\r\nL image_3.jpg\r\n```\r\nthe following commands will not work when in the dataset directory:\r\n```\r\nlightly-embed input_dir=./\r\nlightly-train input_dir=./\r\nlightly-magic input_dir=./\r\n```\r\n\r\nThis is because the command-line tool creates a directory `lightly_outputs` where logs and results are stored. However, when creating the `LightlyDataset`, this directory will be interpreted as a subfolder with images in it which leads to an error. We can handle this by ignoring the `lightly_outputs` directory.\n", "before_files": [{"content": "\"\"\" Helper Functions \"\"\"\n\n# Copyright (c) 2020. Lightly AG and its affiliates.\n# All Rights Reserved\n\nimport os\nfrom torchvision import datasets\n\nfrom lightly.data._image import DatasetFolder\n\ntry:\n    from lightly.data._video import VideoDataset\n    VIDEO_DATASET_AVAILABLE = True\nexcept Exception as e:\n    VIDEO_DATASET_AVAILABLE = False\n    VIDEO_DATASET_ERRORMSG = e\n\n\nIMG_EXTENSIONS = ('.jpg', '.jpeg', '.png', '.ppm', '.bmp',\n                  '.pgm', '.tif', '.tiff', '.webp')\n\nVIDEO_EXTENSIONS = ('.mp4', '.mov', '.avi')\n\n\ndef _contains_videos(root: str, extensions: tuple):\n    \"\"\"Checks whether directory contains video files.\n\n    Args:\n        root: Root directory path.\n\n    Returns:\n        True if root contains subdirectories else false.\n    \"\"\"\n    list_dir = os.listdir(root)\n    is_video = \\\n        [f.lower().endswith(extensions) for f in list_dir]\n    return any(is_video)\n\n\ndef _contains_subdirs(root: str):\n    \"\"\"Checks whether directory contains subdirectories.\n\n    Args:\n        root: Root directory path.\n\n    Returns:\n        True if root contains subdirectories else false.\n\n    \"\"\"\n    list_dir = os.listdir(root)\n    is_dir = \\\n        [os.path.isdir(os.path.join(root, f)) for f in list_dir]\n    return any(is_dir)\n\n\ndef _load_dataset_from_folder(root: str, transform):\n    \"\"\"Initializes dataset from folder.\n\n    Args:\n        root: (str) Root directory path\n        transform: (torchvision.transforms.Compose) image transformations\n\n    Returns:\n        Dataset consisting of images in the root directory.\n\n    \"\"\"\n\n    # if there is a video in the input directory but we do not have\n    # the right dependencies, raise a ValueError\n    contains_videos = _contains_videos(root, VIDEO_EXTENSIONS)\n    if contains_videos and not VIDEO_DATASET_AVAILABLE:\n        raise ValueError(f'The input directory {root} contains videos '\n                         'but the VideoDataset is not available. \\n'\n                         'Make sure you have installed the right '\n                         'dependencies. The error from the imported '\n                         f'module was: {VIDEO_DATASET_ERRORMSG}')\n\n    if contains_videos:\n        # root contains videos -> create a video dataset\n        dataset = VideoDataset(root,\n                               extensions=VIDEO_EXTENSIONS,\n                               transform=transform)\n    elif _contains_subdirs(root):\n        # root contains subdirectories -> create an image folder dataset\n        dataset = datasets.ImageFolder(root,\n                                       transform=transform)\n    else:\n        # root contains plain images -> create a folder dataset\n        dataset = DatasetFolder(root,\n                                extensions=IMG_EXTENSIONS,\n                                transform=transform)\n\n    return dataset\n\n\ndef _load_dataset(input_dir: str,\n                  transform=None):\n    \"\"\"Initializes dataset from torchvision or from folder.\n\n    Args:\n        root: (str) Directory where dataset is stored\n        name: (str) Name of the dataset (e.g. cifar10, cifar100)\n        train: (bool) Use the training set\n        download: (bool) Download the dataset\n        transform: (torchvision.transforms.Compose) image transformations\n        from_folder: (str) Path to directory holding the images to load.\n\n    Returns:\n        A torchvision dataset\n\n    Raises:\n        ValueError: If the specified dataset doesn't exist\n\n    \"\"\"\n\n    if not os.path.exists(input_dir):\n        raise ValueError(f'The input directory {input_dir} does not exist!')\n\n    return _load_dataset_from_folder(input_dir, transform)\n", "path": "lightly/data/_helpers.py"}], "after_files": [{"content": "\"\"\" Helper Functions \"\"\"\n\n# Copyright (c) 2020. Lightly AG and its affiliates.\n# All Rights Reserved\n\nimport os\nfrom torchvision import datasets\n\nfrom lightly.data._image import DatasetFolder\n\ntry:\n    from lightly.data._video import VideoDataset\n    VIDEO_DATASET_AVAILABLE = True\nexcept Exception as e:\n    VIDEO_DATASET_AVAILABLE = False\n    VIDEO_DATASET_ERRORMSG = e\n\n\nIMG_EXTENSIONS = ('.jpg', '.jpeg', '.png', '.ppm', '.bmp',\n                  '.pgm', '.tif', '.tiff', '.webp')\n\nVIDEO_EXTENSIONS = ('.mp4', '.mov', '.avi')\n\n\ndef _contains_videos(root: str, extensions: tuple):\n    \"\"\"Checks whether directory contains video files.\n\n    Args:\n        root: Root directory path.\n\n    Returns:\n        True if root contains subdirectories else false.\n    \"\"\"\n    list_dir = os.listdir(root)\n    is_video = \\\n        [f.lower().endswith(extensions) for f in list_dir]\n    return any(is_video)\n\n\ndef _is_lightly_output_dir(dirname: str):\n    \"\"\"Checks whether the directory is a lightly_output directory.\n\n    Args:\n        dirname: Directory to check.\n\n    Returns:\n        True if dirname is \"lightly_outputs\" else false.\n\n    \"\"\"\n    return 'lightly_outputs' in dirname\n\n\ndef _contains_subdirs(root: str):\n    \"\"\"Checks whether directory contains subdirectories.\n\n    Args:\n        root: Root directory path.\n\n    Returns:\n        True if root contains subdirectories else false.\n\n    \"\"\"\n    list_dir = os.listdir(root)\n    list_dir = list(filter(lambda x: not _is_lightly_output_dir(x), list_dir))\n    is_dir = \\\n        [os.path.isdir(os.path.join(root, f)) for f in list_dir]\n    return any(is_dir)\n\n\ndef _load_dataset_from_folder(root: str, transform):\n    \"\"\"Initializes dataset from folder.\n\n    Args:\n        root: (str) Root directory path\n        transform: (torchvision.transforms.Compose) image transformations\n\n    Returns:\n        Dataset consisting of images in the root directory.\n\n    \"\"\"\n\n    # if there is a video in the input directory but we do not have\n    # the right dependencies, raise a ValueError\n    contains_videos = _contains_videos(root, VIDEO_EXTENSIONS)\n    if contains_videos and not VIDEO_DATASET_AVAILABLE:\n        raise ValueError(f'The input directory {root} contains videos '\n                         'but the VideoDataset is not available. \\n'\n                         'Make sure you have installed the right '\n                         'dependencies. The error from the imported '\n                         f'module was: {VIDEO_DATASET_ERRORMSG}')\n\n    if contains_videos:\n        # root contains videos -> create a video dataset\n        dataset = VideoDataset(root,\n                               extensions=VIDEO_EXTENSIONS,\n                               transform=transform)\n    elif _contains_subdirs(root):\n        # root contains subdirectories -> create an image folder dataset\n        dataset = datasets.ImageFolder(root,\n                                       transform=transform)\n    else:\n        # root contains plain images -> create a folder dataset\n        dataset = DatasetFolder(root,\n                                extensions=IMG_EXTENSIONS,\n                                transform=transform)\n\n    return dataset\n\n\ndef _load_dataset(input_dir: str,\n                  transform=None):\n    \"\"\"Initializes dataset from torchvision or from folder.\n\n    Args:\n        root: (str) Directory where dataset is stored\n        name: (str) Name of the dataset (e.g. cifar10, cifar100)\n        train: (bool) Use the training set\n        download: (bool) Download the dataset\n        transform: (torchvision.transforms.Compose) image transformations\n        from_folder: (str) Path to directory holding the images to load.\n\n    Returns:\n        A torchvision dataset\n\n    Raises:\n        ValueError: If the specified dataset doesn't exist\n\n    \"\"\"\n\n    if not os.path.exists(input_dir):\n        raise ValueError(f'The input directory {input_dir} does not exist!')\n\n    return _load_dataset_from_folder(input_dir, transform)\n", "path": "lightly/data/_helpers.py"}]}