Update soybean_dataset.py
Browse files- soybean_dataset.py +11 -9
soybean_dataset.py
CHANGED
@@ -98,20 +98,22 @@ class SoybeanDataset(datasets.GeneratorBasedBuilder):
|
|
98 |
citation=_CITATION,
|
99 |
)
|
100 |
|
101 |
-
def _split_generators(self, dl_manager: datasets.DownloadManager):
|
|
|
|
|
|
|
|
|
102 |
urls_to_download = self._URLs
|
103 |
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
104 |
-
|
|
|
105 |
return [
|
106 |
datasets.SplitGenerator(
|
107 |
-
name=datasets.Split.TRAIN,
|
108 |
-
gen_kwargs={"filepath": os.path.join(downloaded_files["train"], 'some_subfolder_if_exists')}),
|
109 |
datasets.SplitGenerator(
|
110 |
-
name=datasets.Split.TEST,
|
111 |
-
gen_kwargs={"filepath": os.path.join(downloaded_files["test"], 'some_subfolder_if_exists')}),
|
112 |
datasets.SplitGenerator(
|
113 |
-
name=datasets.Split.VALIDATION,
|
114 |
-
gen_kwargs={"filepath": os.path.join(downloaded_files["valid"], 'some_subfolder_if_exists')}),
|
115 |
]
|
116 |
|
117 |
|
@@ -133,7 +135,7 @@ class SoybeanDataset(datasets.GeneratorBasedBuilder):
|
|
133 |
if filename.endswith('_original.jpg'):
|
134 |
# Construct the unique ID and the corresponding segmentation image name
|
135 |
unique_id = filename.split('_')[0]
|
136 |
-
segmentation_image_name = filename.replace('_original.jpg', '_segmentation.
|
137 |
|
138 |
# Construct full paths to the image files
|
139 |
original_image_path = os.path.join(filepath, filename)
|
|
|
98 |
citation=_CITATION,
|
99 |
)
|
100 |
|
101 |
+
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
102 |
+
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLs
|
103 |
+
# Since the dataset is on Google Drive, you need to implement a way to download it using the Google Drive API.
|
104 |
+
|
105 |
+
# The path to the dataset file in Google Drive
|
106 |
urls_to_download = self._URLs
|
107 |
downloaded_files = dl_manager.download_and_extract(urls_to_download)
|
108 |
+
|
109 |
+
# Since we're using a local file, we don't need to download it, so we just return the path.
|
110 |
return [
|
111 |
datasets.SplitGenerator(
|
112 |
+
name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
|
|
113 |
datasets.SplitGenerator(
|
114 |
+
name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
|
|
|
115 |
datasets.SplitGenerator(
|
116 |
+
name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_files["valid"]}),
|
|
|
117 |
]
|
118 |
|
119 |
|
|
|
135 |
if filename.endswith('_original.jpg'):
|
136 |
# Construct the unique ID and the corresponding segmentation image name
|
137 |
unique_id = filename.split('_')[0]
|
138 |
+
segmentation_image_name = filename.replace('_original.jpg', '_segmentation.jpg')
|
139 |
|
140 |
# Construct full paths to the image files
|
141 |
original_image_path = os.path.join(filepath, filename)
|