Diff of /darkflow/cli.py [000000] .. [d34869]

Switch to unified view

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