fix split generator for task1 config
Browse files- skin-lesion.py +26 -1
skin-lesion.py
CHANGED
@@ -245,7 +245,7 @@ class LesionDataset(datasets.GeneratorBasedBuilder):
|
|
245 |
|
246 |
yield base_name, yield_result
|
247 |
|
248 |
-
|
249 |
for filename in os.listdir(filepath):
|
250 |
if filename.endswith('.jpg') or filename.endswith('.jpeg'):
|
251 |
base_name = os.path.splitext(filename)[0]
|
@@ -270,6 +270,31 @@ class LesionDataset(datasets.GeneratorBasedBuilder):
|
|
270 |
|
271 |
yield base_name, yield_result
|
272 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
|
274 |
|
275 |
# datasets-cli test /Users/jon/code/school/t8/DeepLearning/proj/lesion-dataset.py --save_info --all_configs
|
|
|
245 |
|
246 |
yield base_name, yield_result
|
247 |
|
248 |
+
elif self.config.name in ['globules', 'milia_like_cyst', 'negative_network', 'pigment_network', 'streaks']:
|
249 |
for filename in os.listdir(filepath):
|
250 |
if filename.endswith('.jpg') or filename.endswith('.jpeg'):
|
251 |
base_name = os.path.splitext(filename)[0]
|
|
|
270 |
|
271 |
yield base_name, yield_result
|
272 |
|
273 |
+
elif self.config.name == "task1":
|
274 |
+
for filename in os.listdir(filepath):
|
275 |
+
if filename.endswith('.jpg') or filename.endswith('.jpeg'):
|
276 |
+
base_name = os.path.splitext(filename)[0]
|
277 |
+
|
278 |
+
yield_result = {"image": os.path.join(filepath, filename)}
|
279 |
+
label_filename = f'{base_name}_segmentation.png'
|
280 |
+
label_file_path = os.path.join(labelpath, label_filename)
|
281 |
+
|
282 |
+
# if attribute label does not exist, create a black mask for it
|
283 |
+
if not os.path.exists(label_file_path):
|
284 |
+
# Load the corresponding image to get its size
|
285 |
+
img = Image.open(yield_result['image'])
|
286 |
+
width, height = img.size
|
287 |
+
|
288 |
+
# Create a black image of the same size
|
289 |
+
black_img = Image.fromarray(np.zeros((height, width), dtype=np.uint8))
|
290 |
+
|
291 |
+
# Save the black image
|
292 |
+
black_img.save(label_file_path)
|
293 |
+
|
294 |
+
yield_result["label"] = label_file_path
|
295 |
+
|
296 |
+
yield base_name, yield_result
|
297 |
+
|
298 |
|
299 |
|
300 |
# datasets-cli test /Users/jon/code/school/t8/DeepLearning/proj/lesion-dataset.py --save_info --all_configs
|