| 3 | from .net.build import TFNet |
| 4 | |
| 5 | def cliHandler(args): |
| 6 | FLAGS = argHandler() |
| 7 | FLAGS.setDefaults() |
| 8 | FLAGS.parseArgs(args) |
| 9 | |
| 10 | # make sure all necessary dirs exist |
| 11 | def _get_dir(dirs): |
| 12 | for d in dirs: |
| 13 | this = os.path.abspath(os.path.join(os.path.curdir, d)) |
| 14 | if not os.path.exists(this): os.makedirs(this) |
| 15 | _get_dir([FLAGS.imgdir, FLAGS.binary, FLAGS.backup, |
| 16 | os.path.join(FLAGS.imgdir,'out'), FLAGS.summary]) |
| 17 | |
| 18 | # fix FLAGS.load to appropriate type |
| 19 | try: FLAGS.load = int(FLAGS.load) |
| 20 | except: pass |
| 21 | |
| 22 | tfnet = TFNet(FLAGS) |
| 23 | |
| 24 | if FLAGS.demo: |
| 25 | tfnet.camera() |
| 26 | exit('Demo stopped, exit.') |
| 27 | |
| 28 | if FLAGS.train: |
| 29 | print('Enter training ...'); tfnet.train() |
| 30 | if not FLAGS.savepb: |
| 31 | exit('Training finished, exit.') |
| 32 | |
| 33 | if FLAGS.savepb: |
| 34 | print('Rebuild a constant version ...') |
| 35 | tfnet.savepb(); exit('Done') |
| 36 | |
| 37 | tfnet.predict() |