Skip to content

Commit 2788557

Browse files
committed
tfds new template
1 parent 2b575b8 commit 2788557

File tree

9 files changed

+361
-0
lines changed

9 files changed

+361
-0
lines changed

tensorflow_datasets/image_classification/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,4 @@
9696
from tensorflow_datasets.image_classification.svhn import SvhnCropped
9797
from tensorflow_datasets.image_classification.uc_merced import UcMerced
9898
from tensorflow_datasets.image_classification.visual_domain_decathlon import VisualDomainDecathlon
99+
from tensorflow_datasets.image_classification.wake_vision import WakeVision
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// TODO(wake_vision): To be added after dataset upload and paper publishing.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
TODO(wake_vision): Markdown description of that will appear on the catalog page.
2+
Description is **formatted** as markdown.
3+
4+
It should also contain any processing which has been applied (if any),
5+
(e.g. corrupted example skipped, images cropped,...):

tensorflow_datasets/image_classification/wake_vision/TAGS.txt

Lines changed: 281 additions & 0 deletions
Large diffs are not rendered by default.

tensorflow_datasets/image_classification/wake_vision/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# TODO(wake_vision): If your dataset downloads files, then the checksums
2+
# will be automatically added here when running
3+
# `tfds build --register_checksums`.

tensorflow_datasets/image_classification/wake_vision/dummy_data/TODO-add_fake_data_in_this_directory.txt

Whitespace-only changes.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""wake_vision dataset."""
2+
3+
import tensorflow_datasets.public_api as tfds
4+
5+
6+
class Builder(tfds.core.GeneratorBasedBuilder):
7+
"""DatasetBuilder for wake_vision dataset."""
8+
9+
VERSION = tfds.core.Version('1.0.0')
10+
RELEASE_NOTES = {
11+
'1.0.0': 'Initial release.',
12+
}
13+
14+
def _info(self) -> tfds.core.DatasetInfo:
15+
"""Returns the dataset metadata."""
16+
# TODO(wake_vision): Specifies the tfds.core.DatasetInfo object
17+
return self.dataset_info_from_configs(
18+
features=tfds.features.FeaturesDict({
19+
# These are the features of your dataset like images, labels ...
20+
'image': tfds.features.Image(shape=(None, None, 3)),
21+
'label': tfds.features.ClassLabel(names=['no', 'yes']),
22+
}),
23+
# If there's a common (input, target) tuple from the
24+
# features, specify them here. They'll be used if
25+
# `as_supervised=True` in `builder.as_dataset`.
26+
supervised_keys=('image', 'label'), # Set to `None` to disable
27+
homepage='https://dataset-homepage/',
28+
)
29+
30+
def _split_generators(self, dl_manager: tfds.download.DownloadManager):
31+
"""Returns SplitGenerators."""
32+
# TODO(wake_vision): Downloads the data and defines the splits
33+
path = dl_manager.download_and_extract('https://todo-data-url')
34+
35+
# TODO(wake_vision): Returns the Dict[split names, Iterator[Key, Example]]
36+
return {
37+
'train': self._generate_examples(path / 'train_imgs'),
38+
}
39+
40+
def _generate_examples(self, path):
41+
"""Yields examples."""
42+
# TODO(wake_vision): Yields (key, example) tuples from the dataset
43+
for f in path.glob('*.jpeg'):
44+
yield 'key', {
45+
'image': f,
46+
'label': 'yes',
47+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"""wake_vision dataset."""
2+
3+
from tensorflow_datasets.image_classification.wake_vision import wake_vision_dataset_builder
4+
import tensorflow_datasets.public_api as tfds
5+
6+
class WakeVisionTest(tfds.testing.DatasetBuilderTestCase):
7+
"""Tests for wake_vision dataset."""
8+
# TODO(wake_vision):
9+
DATASET_CLASS = wake_vision_dataset_builder.Builder
10+
SPLITS = {
11+
'train': 3, # Number of fake train example
12+
'test': 1, # Number of fake test example
13+
}
14+
15+
# If you are calling `download/download_and_extract` with a dict, like:
16+
# dl_manager.download({'some_key': 'http://a.org/out.txt', ...})
17+
# then the tests needs to provide the fake output paths relative to the
18+
# fake data directory
19+
# DL_EXTRACT_RESULT = {'some_key': 'output_file1.txt', ...}
20+
21+
22+
if __name__ == '__main__':
23+
tfds.testing.test_main()

0 commit comments

Comments
 (0)