I am trying to write a custom TFDS dataset.
Here is the file my_dataset_dataset_builder.py:
"""my_dataset dataset."""
import tensorflow_datasets as tfds
class Builder(tfds.core.GeneratorBasedBuilder):
"""DatasetBuilder for my_dataset dataset."""
VERSION = tfds.core.Version('1.0.0')
RELEASE_NOTES = {
'1.0.0': 'Initial release.',
}
def _info(self) -> tfds.core.DatasetInfo:
"""Returns the dataset metadata."""
# TODO(my_dataset): Specifies the tfds.core.DatasetInfo object
return self.dataset_info_from_configs(
features=tfds.features.FeaturesDict({
# These are the features of your dataset like images, labels ...
'image': tfds.features.Image(shape=(256, 256, 3)),
#'label': tfds.features.ClassLabel(names=['no', 'yes']),
'label': tfds.features.ClassLabel(names=['actinic keratosis', 'basal cell carcinoma', 'benign keratosis', 'dermatofibroma', 'melanocytic nevus', 'melanoma', 'vascular lesion']),
}),
# If there's a common (input, target) tuple from the
# features, specify them here. They'll be used if
# `as_supervised=True` in `builder.as_dataset`.
supervised_keys=('image', 'label'), # Set to `None` to disable
)
def _split_generators(self, dl_manager: tfds.download.DownloadManager):
"""Download the data and define splits."""
extracted_path = '/home/user/Documents/data_formatted.zip'
return {
'train': self._generate_examples(path=extracted_path / 'train_images'),
'test': self._generate_examples(path=extracted_path / 'test_images'),
}
def _generate_examples(self, path):
"""Generator of examples for each split."""
for img_path in path.glob('*.jpeg'):
# Yields (key, example)
yield img_path.name, {
'image': img_path,
'label': 'actinic keratosis' if img_path.name.startswith('akiec_') else 'unknown',
}
I am getting the error:
TypeError: unsupported operand type(s) for /: ‘str’ and ‘str’
Says the problem is with this line:
‘train’: self._generate_examples(path=extracted_path / ‘train_images’),
Any help or advice would be appreciated. Thanks.