Update file_name
Browse files- NuCLS_dataset.py +7 -0
NuCLS_dataset.py
CHANGED
@@ -76,6 +76,7 @@ class NuCLSDataset(GeneratorBasedBuilder):
|
|
76 |
|
77 |
# Define features
|
78 |
features = Features({
|
|
|
79 |
'rgb_image': Image(decode=True),
|
80 |
'mask_image': Image(decode=True),
|
81 |
'visualization_image': Image(decode=True),
|
@@ -176,6 +177,7 @@ class NuCLSDataset(GeneratorBasedBuilder):
|
|
176 |
'visualization': os.path.join(visualization_dir, filename + '.png'),
|
177 |
'mask': os.path.join(mask_dir, filename + '.png'),
|
178 |
'csv': os.path.join(csv_dir, filename + '.csv'),
|
|
|
179 |
}
|
180 |
return filepaths
|
181 |
|
@@ -183,6 +185,10 @@ class NuCLSDataset(GeneratorBasedBuilder):
|
|
183 |
"""Yield examples as (key, example) tuples."""
|
184 |
|
185 |
for key, paths in filepaths.items():
|
|
|
|
|
|
|
|
|
186 |
# Read the images using a method to handle the image files
|
187 |
rgb_image = self._read_image_file(paths['rgb'])
|
188 |
mask_image = self._read_image_file(paths['mask'])
|
@@ -193,6 +199,7 @@ class NuCLSDataset(GeneratorBasedBuilder):
|
|
193 |
|
194 |
# Yield the example
|
195 |
yield key, {
|
|
|
196 |
'rgb_image': rgb_image,
|
197 |
'mask_image': mask_image,
|
198 |
'visualization_image': visualization_image,
|
|
|
76 |
|
77 |
# Define features
|
78 |
features = Features({
|
79 |
+
'file_name': Value("string"),
|
80 |
'rgb_image': Image(decode=True),
|
81 |
'mask_image': Image(decode=True),
|
82 |
'visualization_image': Image(decode=True),
|
|
|
177 |
'visualization': os.path.join(visualization_dir, filename + '.png'),
|
178 |
'mask': os.path.join(mask_dir, filename + '.png'),
|
179 |
'csv': os.path.join(csv_dir, filename + '.csv'),
|
180 |
+
'file_name': filename
|
181 |
}
|
182 |
return filepaths
|
183 |
|
|
|
185 |
"""Yield examples as (key, example) tuples."""
|
186 |
|
187 |
for key, paths in filepaths.items():
|
188 |
+
|
189 |
+
# Extract the file name
|
190 |
+
file_name = paths['file_name']
|
191 |
+
|
192 |
# Read the images using a method to handle the image files
|
193 |
rgb_image = self._read_image_file(paths['rgb'])
|
194 |
mask_image = self._read_image_file(paths['mask'])
|
|
|
199 |
|
200 |
# Yield the example
|
201 |
yield key, {
|
202 |
+
'file_name': file_name,
|
203 |
'rgb_image': rgb_image,
|
204 |
'mask_image': mask_image,
|
205 |
'visualization_image': visualization_image,
|