forked from thtrieu/darkflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flow
executable file
·63 lines (53 loc) · 2.57 KB
/
flow
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /usr/bin/env python
from net.build import TFNet
from tensorflow import flags
import os
flags.DEFINE_string("test", "./test/", "path to testing directory")
flags.DEFINE_string("binary", "./bin/", "path to .weights directory")
flags.DEFINE_string("config", "./cfg/", "path to .cfg directory")
flags.DEFINE_string("dataset", "../pascal/VOCdevkit/IMG/", "path to dataset directory")
flags.DEFINE_string("backup", "./ckpt/", "path to backup folder")
flags.DEFINE_string("summary", "./summary/", "path to TensorBoard summaries directory")
flags.DEFINE_string("annotation", "../pascal/VOCdevkit/ANN/", "path to annotation directory")
flags.DEFINE_float("threshold", 0.1, "detection threshold")
flags.DEFINE_string("model", "", "configuration of choice")
flags.DEFINE_string("trainer", "rmsprop", "training algorithm")
flags.DEFINE_float("momentum", 0.0, "applicable for rmsprop and momentum optimizers")
flags.DEFINE_boolean("verbalise", True, "say out loud while building graph")
flags.DEFINE_boolean("train", False, "train the whole net")
flags.DEFINE_string("load", "", "how to initialize the net? Either from .weights or a checkpoint, or even from scratch")
flags.DEFINE_boolean("savepb", False, "save net and weight to a .pb file")
flags.DEFINE_float("gpu", 0.0, "how much gpu (from 0.0 to 1.0)")
flags.DEFINE_float("lr", 1e-5, "learning rate")
flags.DEFINE_integer("keep",20,"Number of most recent training results to save")
flags.DEFINE_integer("batch", 16, "batch size")
flags.DEFINE_integer("epoch", 1000, "number of epoch")
flags.DEFINE_integer("save", 2000, "save checkpoint every ? training examples")
flags.DEFINE_string("demo", '', "demo on webcam")
flags.DEFINE_boolean("profile", False, "profile")
flags.DEFINE_boolean("json", False, "Outputs bounding box information in json format.")
flags.DEFINE_boolean("saveVideo", False, "Records video from input video or camera")
FLAGS = flags.FLAGS
# make sure all necessary dirs exist
def get_dir(dirs):
for d in dirs:
this = os.path.abspath(os.path.join(os.path.curdir, d))
if not os.path.exists(this): os.makedirs(this)
get_dir([FLAGS.test, FLAGS.binary, FLAGS.backup, os.path.join(FLAGS.test,'out'), FLAGS.summary])
# fix FLAGS.load to appropriate type
try: FLAGS.load = int(FLAGS.load)
except: pass
tfnet = TFNet(FLAGS)
if FLAGS.profile:
tfnet.framework.profile(tfnet)
exit()
if FLAGS.demo:
tfnet.camera(FLAGS.demo, FLAGS.saveVideo)
exit()
if FLAGS.train:
print('Enter training ...'); tfnet.train()
if not FLAGS.savepb: exit('Training finished')
if FLAGS.savepb:
print('Rebuild a constant version ...')
tfnet.savepb(); exit('Done')
tfnet.predict()