We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Is there a way to seed experiments?
## ❓ Questions and Help

#### What is your question?
Is there a way to seed experiments? Attempts at using `seed_everything` from pytorch lightning do not appear to work (also with the the workers argument set to True).

#### What's your environment?

 - OS: Linux
 - Packaging: pip
 - Version: 0.5.2


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `flash/image/segmentation/input.py`
Content:
```
1 # Copyright The PyTorch Lightning team.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 import os
15 from typing import Any, Dict, List, Optional, Tuple, TYPE_CHECKING, Union
16 
17 import torch
18 from pytorch_lightning.utilities import rank_zero_warn
19 
20 from flash.core.data.io.input import DataKeys, ImageLabelsMap, Input
21 from flash.core.data.utilities.paths import filter_valid_files, PATH_TYPE
22 from flash.core.data.utilities.samples import to_samples
23 from flash.core.data.utils import image_default_loader
24 from flash.core.integrations.fiftyone.utils import FiftyOneLabelUtilities
25 from flash.core.utilities.imports import _FIFTYONE_AVAILABLE, _TORCHVISION_AVAILABLE, lazy_import
26 from flash.image.data import ImageDeserializer, IMG_EXTENSIONS
27 from flash.image.segmentation.output import SegmentationLabelsOutput
28 
29 SampleCollection = None
30 if _FIFTYONE_AVAILABLE:
31     fo = lazy_import("fiftyone")
32     if TYPE_CHECKING:
33         from fiftyone.core.collections import SampleCollection
34 else:
35     fo = None
36 
37 if _TORCHVISION_AVAILABLE:
38     import torchvision
39     import torchvision.transforms.functional as FT
40 
41 
42 class SemanticSegmentationInput(Input):
43     def load_labels_map(
44         self, num_classes: Optional[int] = None, labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None
45     ) -> None:
46         if num_classes is not None:
47             self.num_classes = num_classes
48             labels_map = labels_map or SegmentationLabelsOutput.create_random_labels_map(num_classes)
49 
50         if labels_map is not None:
51             self.set_state(ImageLabelsMap(labels_map))
52             self.labels_map = labels_map
53 
54     def load_sample(self, sample: Dict[str, Any]) -> Dict[str, Any]:
55         sample[DataKeys.INPUT] = sample[DataKeys.INPUT].float()
56         if DataKeys.TARGET in sample:
57             sample[DataKeys.TARGET] = sample[DataKeys.TARGET].float()
58         sample[DataKeys.METADATA] = {"size": sample[DataKeys.INPUT].shape[-2:]}
59         return sample
60 
61 
62 class SemanticSegmentationTensorInput(SemanticSegmentationInput):
63     def load_data(
64         self,
65         tensor: Any,
66         masks: Any = None,
67         num_classes: Optional[int] = None,
68         labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None,
69     ) -> List[Dict[str, Any]]:
70         self.load_labels_map(num_classes, labels_map)
71         return to_samples(tensor, masks)
72 
73 
74 class SemanticSegmentationNumpyInput(SemanticSegmentationInput):
75     def load_data(
76         self,
77         array: Any,
78         masks: Any = None,
79         num_classes: Optional[int] = None,
80         labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None,
81     ) -> List[Dict[str, Any]]:
82         self.load_labels_map(num_classes, labels_map)
83         return to_samples(array, masks)
84 
85     def load_sample(self, sample: Dict[str, Any]) -> Dict[str, Any]:
86         sample[DataKeys.INPUT] = torch.from_numpy(sample[DataKeys.INPUT])
87         if DataKeys.TARGET in sample:
88             sample[DataKeys.TARGET] = torch.from_numpy(sample[DataKeys.TARGET])
89         return super().load_sample(sample)
90 
91 
92 class SemanticSegmentationFilesInput(SemanticSegmentationInput):
93     def load_data(
94         self,
95         files: Union[PATH_TYPE, List[PATH_TYPE]],
96         mask_files: Optional[Union[PATH_TYPE, List[PATH_TYPE]]] = None,
97         num_classes: Optional[int] = None,
98         labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None,
99     ) -> List[Dict[str, Any]]:
100         self.load_labels_map(num_classes, labels_map)
101         if mask_files is None:
102             files = filter_valid_files(files, valid_extensions=IMG_EXTENSIONS)
103         else:
104             files, masks = filter_valid_files(files, mask_files, valid_extensions=IMG_EXTENSIONS)
105         return to_samples(files, mask_files)
106 
107     def load_sample(self, sample: Dict[str, Any]) -> Dict[str, Any]:
108         filepath = sample[DataKeys.INPUT]
109         sample[DataKeys.INPUT] = FT.to_tensor(image_default_loader(filepath))
110         if DataKeys.TARGET in sample:
111             sample[DataKeys.TARGET] = torchvision.io.read_image(sample[DataKeys.TARGET])[0]
112         sample = super().load_sample(sample)
113         sample[DataKeys.METADATA]["filepath"] = filepath
114         return sample
115 
116 
117 class SemanticSegmentationFolderInput(SemanticSegmentationFilesInput):
118     def load_data(
119         self,
120         folder: PATH_TYPE,
121         mask_folder: Optional[PATH_TYPE] = None,
122         num_classes: Optional[int] = None,
123         labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None,
124     ) -> List[Dict[str, Any]]:
125         self.load_labels_map(num_classes, labels_map)
126         files = os.listdir(folder)
127         if mask_folder is not None:
128             mask_files = os.listdir(mask_folder)
129 
130             all_files = set(files).intersection(set(mask_files))
131             if len(all_files) != len(files) or len(all_files) != len(mask_files):
132                 rank_zero_warn(
133                     f"Found inconsistent files in input folder: {folder} and mask folder: {mask_folder}. Some files"
134                     " have been dropped.",
135                     UserWarning,
136                 )
137 
138             files = [os.path.join(folder, file) for file in all_files]
139             mask_files = [os.path.join(mask_folder, file) for file in all_files]
140             return super().load_data(files, mask_files)
141         return super().load_data(files)
142 
143 
144 class SemanticSegmentationFiftyOneInput(SemanticSegmentationFilesInput):
145     def load_data(
146         self,
147         sample_collection: SampleCollection,
148         label_field: str = "ground_truth",
149         num_classes: Optional[int] = None,
150         labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None,
151     ) -> List[Dict[str, Any]]:
152         self.load_labels_map(num_classes, labels_map)
153 
154         self.label_field = label_field
155         label_utilities = FiftyOneLabelUtilities(label_field, fo.Segmentation)
156         label_utilities.validate(sample_collection)
157 
158         self._fo_dataset_name = sample_collection.name
159         return to_samples(sample_collection.values("filepath"))
160 
161     def load_sample(self, sample: Dict[str, Any]) -> Dict[str, Any]:
162         filepath = sample[DataKeys.INPUT]
163         sample = super().load_sample(sample)
164         if not self.predicting:
165             fo_dataset = fo.load_dataset(self._fo_dataset_name)
166             fo_sample = fo_dataset[filepath]
167             sample[DataKeys.TARGET] = torch.from_numpy(fo_sample[self.label_field].mask).float()  # H x W
168         return sample
169 
170 
171 class SemanticSegmentationDeserializer(ImageDeserializer):
172     def serve_load_sample(self, data: str) -> Dict[str, Any]:
173         result = super().serve_load_sample(data)
174         result[DataKeys.INPUT] = FT.to_tensor(result[DataKeys.INPUT])
175         result[DataKeys.METADATA] = {"size": result[DataKeys.INPUT].shape[-2:]}
176         return result
177
```
--- 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/flash/image/segmentation/input.py b/flash/image/segmentation/input.py
--- a/flash/image/segmentation/input.py
+++ b/flash/image/segmentation/input.py
@@ -124,6 +124,7 @@
     ) -> List[Dict[str, Any]]:
         self.load_labels_map(num_classes, labels_map)
         files = os.listdir(folder)
+        files.sort()
         if mask_folder is not None:
             mask_files = os.listdir(mask_folder)
 
@@ -137,6 +138,8 @@
 
             files = [os.path.join(folder, file) for file in all_files]
             mask_files = [os.path.join(mask_folder, file) for file in all_files]
+            files.sort()
+            mask_files.sort()
             return super().load_data(files, mask_files)
         return super().load_data(files)

{"golden_diff": "diff --git a/flash/image/segmentation/input.py b/flash/image/segmentation/input.py\n--- a/flash/image/segmentation/input.py\n+++ b/flash/image/segmentation/input.py\n@@ -124,6 +124,7 @@\n     ) -> List[Dict[str, Any]]:\n         self.load_labels_map(num_classes, labels_map)\n         files = os.listdir(folder)\n+        files.sort()\n         if mask_folder is not None:\n             mask_files = os.listdir(mask_folder)\n \n@@ -137,6 +138,8 @@\n \n             files = [os.path.join(folder, file) for file in all_files]\n             mask_files = [os.path.join(mask_folder, file) for file in all_files]\n+            files.sort()\n+            mask_files.sort()\n             return super().load_data(files, mask_files)\n         return super().load_data(files)\n", "issue": "Is there a way to seed experiments?\n## \u2753 Questions and Help\r\n\r\n#### What is your question?\r\nIs there a way to seed experiments? Attempts at using `seed_everything` from pytorch lightning do not appear to work (also with the the workers argument set to True).\r\n\r\n#### What's your environment?\r\n\r\n - OS: Linux\r\n - Packaging: pip\r\n - Version: 0.5.2\r\n\n", "before_files": [{"content": "# Copyright The PyTorch Lightning team.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport os\nfrom typing import Any, Dict, List, Optional, Tuple, TYPE_CHECKING, Union\n\nimport torch\nfrom pytorch_lightning.utilities import rank_zero_warn\n\nfrom flash.core.data.io.input import DataKeys, ImageLabelsMap, Input\nfrom flash.core.data.utilities.paths import filter_valid_files, PATH_TYPE\nfrom flash.core.data.utilities.samples import to_samples\nfrom flash.core.data.utils import image_default_loader\nfrom flash.core.integrations.fiftyone.utils import FiftyOneLabelUtilities\nfrom flash.core.utilities.imports import _FIFTYONE_AVAILABLE, _TORCHVISION_AVAILABLE, lazy_import\nfrom flash.image.data import ImageDeserializer, IMG_EXTENSIONS\nfrom flash.image.segmentation.output import SegmentationLabelsOutput\n\nSampleCollection = None\nif _FIFTYONE_AVAILABLE:\n    fo = lazy_import(\"fiftyone\")\n    if TYPE_CHECKING:\n        from fiftyone.core.collections import SampleCollection\nelse:\n    fo = None\n\nif _TORCHVISION_AVAILABLE:\n    import torchvision\n    import torchvision.transforms.functional as FT\n\n\nclass SemanticSegmentationInput(Input):\n    def load_labels_map(\n        self, num_classes: Optional[int] = None, labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None\n    ) -> None:\n        if num_classes is not None:\n            self.num_classes = num_classes\n            labels_map = labels_map or SegmentationLabelsOutput.create_random_labels_map(num_classes)\n\n        if labels_map is not None:\n            self.set_state(ImageLabelsMap(labels_map))\n            self.labels_map = labels_map\n\n    def load_sample(self, sample: Dict[str, Any]) -> Dict[str, Any]:\n        sample[DataKeys.INPUT] = sample[DataKeys.INPUT].float()\n        if DataKeys.TARGET in sample:\n            sample[DataKeys.TARGET] = sample[DataKeys.TARGET].float()\n        sample[DataKeys.METADATA] = {\"size\": sample[DataKeys.INPUT].shape[-2:]}\n        return sample\n\n\nclass SemanticSegmentationTensorInput(SemanticSegmentationInput):\n    def load_data(\n        self,\n        tensor: Any,\n        masks: Any = None,\n        num_classes: Optional[int] = None,\n        labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None,\n    ) -> List[Dict[str, Any]]:\n        self.load_labels_map(num_classes, labels_map)\n        return to_samples(tensor, masks)\n\n\nclass SemanticSegmentationNumpyInput(SemanticSegmentationInput):\n    def load_data(\n        self,\n        array: Any,\n        masks: Any = None,\n        num_classes: Optional[int] = None,\n        labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None,\n    ) -> List[Dict[str, Any]]:\n        self.load_labels_map(num_classes, labels_map)\n        return to_samples(array, masks)\n\n    def load_sample(self, sample: Dict[str, Any]) -> Dict[str, Any]:\n        sample[DataKeys.INPUT] = torch.from_numpy(sample[DataKeys.INPUT])\n        if DataKeys.TARGET in sample:\n            sample[DataKeys.TARGET] = torch.from_numpy(sample[DataKeys.TARGET])\n        return super().load_sample(sample)\n\n\nclass SemanticSegmentationFilesInput(SemanticSegmentationInput):\n    def load_data(\n        self,\n        files: Union[PATH_TYPE, List[PATH_TYPE]],\n        mask_files: Optional[Union[PATH_TYPE, List[PATH_TYPE]]] = None,\n        num_classes: Optional[int] = None,\n        labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None,\n    ) -> List[Dict[str, Any]]:\n        self.load_labels_map(num_classes, labels_map)\n        if mask_files is None:\n            files = filter_valid_files(files, valid_extensions=IMG_EXTENSIONS)\n        else:\n            files, masks = filter_valid_files(files, mask_files, valid_extensions=IMG_EXTENSIONS)\n        return to_samples(files, mask_files)\n\n    def load_sample(self, sample: Dict[str, Any]) -> Dict[str, Any]:\n        filepath = sample[DataKeys.INPUT]\n        sample[DataKeys.INPUT] = FT.to_tensor(image_default_loader(filepath))\n        if DataKeys.TARGET in sample:\n            sample[DataKeys.TARGET] = torchvision.io.read_image(sample[DataKeys.TARGET])[0]\n        sample = super().load_sample(sample)\n        sample[DataKeys.METADATA][\"filepath\"] = filepath\n        return sample\n\n\nclass SemanticSegmentationFolderInput(SemanticSegmentationFilesInput):\n    def load_data(\n        self,\n        folder: PATH_TYPE,\n        mask_folder: Optional[PATH_TYPE] = None,\n        num_classes: Optional[int] = None,\n        labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None,\n    ) -> List[Dict[str, Any]]:\n        self.load_labels_map(num_classes, labels_map)\n        files = os.listdir(folder)\n        if mask_folder is not None:\n            mask_files = os.listdir(mask_folder)\n\n            all_files = set(files).intersection(set(mask_files))\n            if len(all_files) != len(files) or len(all_files) != len(mask_files):\n                rank_zero_warn(\n                    f\"Found inconsistent files in input folder: {folder} and mask folder: {mask_folder}. Some files\"\n                    \" have been dropped.\",\n                    UserWarning,\n                )\n\n            files = [os.path.join(folder, file) for file in all_files]\n            mask_files = [os.path.join(mask_folder, file) for file in all_files]\n            return super().load_data(files, mask_files)\n        return super().load_data(files)\n\n\nclass SemanticSegmentationFiftyOneInput(SemanticSegmentationFilesInput):\n    def load_data(\n        self,\n        sample_collection: SampleCollection,\n        label_field: str = \"ground_truth\",\n        num_classes: Optional[int] = None,\n        labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None,\n    ) -> List[Dict[str, Any]]:\n        self.load_labels_map(num_classes, labels_map)\n\n        self.label_field = label_field\n        label_utilities = FiftyOneLabelUtilities(label_field, fo.Segmentation)\n        label_utilities.validate(sample_collection)\n\n        self._fo_dataset_name = sample_collection.name\n        return to_samples(sample_collection.values(\"filepath\"))\n\n    def load_sample(self, sample: Dict[str, Any]) -> Dict[str, Any]:\n        filepath = sample[DataKeys.INPUT]\n        sample = super().load_sample(sample)\n        if not self.predicting:\n            fo_dataset = fo.load_dataset(self._fo_dataset_name)\n            fo_sample = fo_dataset[filepath]\n            sample[DataKeys.TARGET] = torch.from_numpy(fo_sample[self.label_field].mask).float()  # H x W\n        return sample\n\n\nclass SemanticSegmentationDeserializer(ImageDeserializer):\n    def serve_load_sample(self, data: str) -> Dict[str, Any]:\n        result = super().serve_load_sample(data)\n        result[DataKeys.INPUT] = FT.to_tensor(result[DataKeys.INPUT])\n        result[DataKeys.METADATA] = {\"size\": result[DataKeys.INPUT].shape[-2:]}\n        return result\n", "path": "flash/image/segmentation/input.py"}], "after_files": [{"content": "# Copyright The PyTorch Lightning team.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nimport os\nfrom typing import Any, Dict, List, Optional, Tuple, TYPE_CHECKING, Union\n\nimport torch\nfrom pytorch_lightning.utilities import rank_zero_warn\n\nfrom flash.core.data.io.input import DataKeys, ImageLabelsMap, Input\nfrom flash.core.data.utilities.paths import filter_valid_files, PATH_TYPE\nfrom flash.core.data.utilities.samples import to_samples\nfrom flash.core.data.utils import image_default_loader\nfrom flash.core.integrations.fiftyone.utils import FiftyOneLabelUtilities\nfrom flash.core.utilities.imports import _FIFTYONE_AVAILABLE, _TORCHVISION_AVAILABLE, lazy_import\nfrom flash.image.data import ImageDeserializer, IMG_EXTENSIONS\nfrom flash.image.segmentation.output import SegmentationLabelsOutput\n\nSampleCollection = None\nif _FIFTYONE_AVAILABLE:\n    fo = lazy_import(\"fiftyone\")\n    if TYPE_CHECKING:\n        from fiftyone.core.collections import SampleCollection\nelse:\n    fo = None\n\nif _TORCHVISION_AVAILABLE:\n    import torchvision\n    import torchvision.transforms.functional as FT\n\n\nclass SemanticSegmentationInput(Input):\n    def load_labels_map(\n        self, num_classes: Optional[int] = None, labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None\n    ) -> None:\n        if num_classes is not None:\n            self.num_classes = num_classes\n            labels_map = labels_map or SegmentationLabelsOutput.create_random_labels_map(num_classes)\n\n        if labels_map is not None:\n            self.set_state(ImageLabelsMap(labels_map))\n            self.labels_map = labels_map\n\n    def load_sample(self, sample: Dict[str, Any]) -> Dict[str, Any]:\n        sample[DataKeys.INPUT] = sample[DataKeys.INPUT].float()\n        if DataKeys.TARGET in sample:\n            sample[DataKeys.TARGET] = sample[DataKeys.TARGET].float()\n        sample[DataKeys.METADATA] = {\"size\": sample[DataKeys.INPUT].shape[-2:]}\n        return sample\n\n\nclass SemanticSegmentationTensorInput(SemanticSegmentationInput):\n    def load_data(\n        self,\n        tensor: Any,\n        masks: Any = None,\n        num_classes: Optional[int] = None,\n        labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None,\n    ) -> List[Dict[str, Any]]:\n        self.load_labels_map(num_classes, labels_map)\n        return to_samples(tensor, masks)\n\n\nclass SemanticSegmentationNumpyInput(SemanticSegmentationInput):\n    def load_data(\n        self,\n        array: Any,\n        masks: Any = None,\n        num_classes: Optional[int] = None,\n        labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None,\n    ) -> List[Dict[str, Any]]:\n        self.load_labels_map(num_classes, labels_map)\n        return to_samples(array, masks)\n\n    def load_sample(self, sample: Dict[str, Any]) -> Dict[str, Any]:\n        sample[DataKeys.INPUT] = torch.from_numpy(sample[DataKeys.INPUT])\n        if DataKeys.TARGET in sample:\n            sample[DataKeys.TARGET] = torch.from_numpy(sample[DataKeys.TARGET])\n        return super().load_sample(sample)\n\n\nclass SemanticSegmentationFilesInput(SemanticSegmentationInput):\n    def load_data(\n        self,\n        files: Union[PATH_TYPE, List[PATH_TYPE]],\n        mask_files: Optional[Union[PATH_TYPE, List[PATH_TYPE]]] = None,\n        num_classes: Optional[int] = None,\n        labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None,\n    ) -> List[Dict[str, Any]]:\n        self.load_labels_map(num_classes, labels_map)\n        if mask_files is None:\n            files = filter_valid_files(files, valid_extensions=IMG_EXTENSIONS)\n        else:\n            files, masks = filter_valid_files(files, mask_files, valid_extensions=IMG_EXTENSIONS)\n        return to_samples(files, mask_files)\n\n    def load_sample(self, sample: Dict[str, Any]) -> Dict[str, Any]:\n        filepath = sample[DataKeys.INPUT]\n        sample[DataKeys.INPUT] = FT.to_tensor(image_default_loader(filepath))\n        if DataKeys.TARGET in sample:\n            sample[DataKeys.TARGET] = torchvision.io.read_image(sample[DataKeys.TARGET])[0]\n        sample = super().load_sample(sample)\n        sample[DataKeys.METADATA][\"filepath\"] = filepath\n        return sample\n\n\nclass SemanticSegmentationFolderInput(SemanticSegmentationFilesInput):\n    def load_data(\n        self,\n        folder: PATH_TYPE,\n        mask_folder: Optional[PATH_TYPE] = None,\n        num_classes: Optional[int] = None,\n        labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None,\n    ) -> List[Dict[str, Any]]:\n        self.load_labels_map(num_classes, labels_map)\n        files = os.listdir(folder)\n        files.sort()\n        if mask_folder is not None:\n            mask_files = os.listdir(mask_folder)\n\n            all_files = set(files).intersection(set(mask_files))\n            if len(all_files) != len(files) or len(all_files) != len(mask_files):\n                rank_zero_warn(\n                    f\"Found inconsistent files in input folder: {folder} and mask folder: {mask_folder}. Some files\"\n                    \" have been dropped.\",\n                    UserWarning,\n                )\n\n            files = [os.path.join(folder, file) for file in all_files]\n            mask_files = [os.path.join(mask_folder, file) for file in all_files]\n            files.sort()\n            mask_files.sort()\n            return super().load_data(files, mask_files)\n        return super().load_data(files)\n\n\nclass SemanticSegmentationFiftyOneInput(SemanticSegmentationFilesInput):\n    def load_data(\n        self,\n        sample_collection: SampleCollection,\n        label_field: str = \"ground_truth\",\n        num_classes: Optional[int] = None,\n        labels_map: Optional[Dict[int, Tuple[int, int, int]]] = None,\n    ) -> List[Dict[str, Any]]:\n        self.load_labels_map(num_classes, labels_map)\n\n        self.label_field = label_field\n        label_utilities = FiftyOneLabelUtilities(label_field, fo.Segmentation)\n        label_utilities.validate(sample_collection)\n\n        self._fo_dataset_name = sample_collection.name\n        return to_samples(sample_collection.values(\"filepath\"))\n\n    def load_sample(self, sample: Dict[str, Any]) -> Dict[str, Any]:\n        filepath = sample[DataKeys.INPUT]\n        sample = super().load_sample(sample)\n        if not self.predicting:\n            fo_dataset = fo.load_dataset(self._fo_dataset_name)\n            fo_sample = fo_dataset[filepath]\n            sample[DataKeys.TARGET] = torch.from_numpy(fo_sample[self.label_field].mask).float()  # H x W\n        return sample\n\n\nclass SemanticSegmentationDeserializer(ImageDeserializer):\n    def serve_load_sample(self, data: str) -> Dict[str, Any]:\n        result = super().serve_load_sample(data)\n        result[DataKeys.INPUT] = FT.to_tensor(result[DataKeys.INPUT])\n        result[DataKeys.METADATA] = {\"size\": result[DataKeys.INPUT].shape[-2:]}\n        return result\n", "path": "flash/image/segmentation/input.py"}]}