-
Notifications
You must be signed in to change notification settings - Fork 16
/
dataset.py
47 lines (30 loc) · 995 Bytes
/
dataset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import json
import tensorflow as tf
from data import datasets
from patchy import PatchySan
FLAGS = tf.app.flags.FLAGS
tf.app.flags.DEFINE_string('config', None,
"""Path to the configuration json file of the
dataset.""")
def dataset(config):
"""Reads and initializes a dataset specified by a passed configuration.
Args:
config: Configuration object.
Returns:
A dataset.
"""
if config['name'] in datasets:
return datasets[config['name']].create(config)
elif config['name'] == 'patchy_san':
return PatchySan.create(config)
else:
raise ValueError('Dataset not found.')
def main(argv=None):
"""Runs the script."""
if not tf.gfile.Exists(FLAGS.config):
raise ValueError('{} does not exist.'.format(FLAGS.config))
with open(FLAGS.config, 'r') as f:
config = json.load(f)
dataset(config)
if __name__ == '__main__':
tf.app.run()