| 1 | class argHandler(dict): |
| 2 | #A super duper fancy custom made CLI argument handler!! |
| 3 | __getattr__ = dict.get |
| 4 | __setattr__ = dict.__setitem__ |
| 5 | __delattr__ = dict.__delitem__ |
| 6 | _descriptions = {'help, --h, -h': 'show this super helpful message and exit'} |
| 7 | |
| 8 | def setDefaults(self): |
| 9 | self.define('imgdir', './sample_img/', 'path to testing directory with images') |
| 10 | self.define('binary', './bin/', 'path to .weights directory') |
| 11 | self.define('config', './cfg/', 'path to .cfg directory') |
| 12 | self.define('dataset', '../pascal/VOCdevkit/IMG/', 'path to dataset directory') |
| 13 | self.define('labels', 'labels.txt', 'path to labels file') |
| 14 | self.define('backup', './ckpt/', 'path to backup folder') |
| 15 | self.define('summary', './summary/', 'path to TensorBoard summaries directory') |
| 16 | self.define('annotation', '../pascal/VOCdevkit/ANN/', 'path to annotation directory') |
| 17 | self.define('threshold', -0.1, 'detection threshold') |
| 18 | self.define('model', '', 'configuration of choice') |
| 19 | self.define('trainer', 'rmsprop', 'training algorithm') |
| 20 | self.define('momentum', 0.0, 'applicable for rmsprop and momentum optimizers') |
| 21 | self.define('verbalise', True, 'say out loud while building graph') |
| 22 | self.define('train', False, 'train the whole net') |
| 23 | self.define('load', '', 'how to initialize the net? Either from .weights or a checkpoint, or even from scratch') |
| 24 | self.define('savepb', False, 'save net and weight to a .pb file') |
| 25 | self.define('gpu', 0.0, 'how much gpu (from 0.0 to 1.0)') |
| 26 | self.define('gpuName', '/gpu:0', 'GPU device name') |
| 27 | self.define('lr', 1e-5, 'learning rate') |
| 28 | self.define('keep',20,'Number of most recent training results to save') |
| 29 | self.define('batch', 16, 'batch size') |
| 30 | self.define('epoch', 1000, 'number of epoch') |
| 31 | self.define('save', 2000, 'save checkpoint every ? training examples') |
| 32 | self.define('demo', '', 'demo on webcam') |
| 33 | self.define('queue', 1, 'process demo in batch') |
| 34 | self.define('json', False, 'Outputs bounding box information in json format.') |
| 35 | self.define('saveVideo', False, 'Records video from input video or camera') |
| 36 | self.define('pbLoad', '', 'path to .pb protobuf file (metaLoad must also be specified)') |
| 37 | self.define('metaLoad', '', 'path to .meta file generated during --savepb that corresponds to .pb file') |
| 38 | |
| 39 | def define(self, argName, default, description): |
| 40 | self[argName] = default |
| 41 | self._descriptions[argName] = description |
| 42 | |
| 43 | def help(self): |
| 44 | print('Example usage: flow --imgdir sample_img/ --model cfg/yolo.cfg --load bin/yolo.weights') |
| 45 | print('') |
| 46 | print('Arguments:') |
| 47 | spacing = max([len(i) for i in self._descriptions.keys()]) + 2 |
| 48 | for item in self._descriptions: |
| 49 | currentSpacing = spacing - len(item) |
| 50 | print(' --' + item + (' ' * currentSpacing) + self._descriptions[item]) |
| 51 | print('') |
| 52 | exit() |
| 53 | |
| 54 | def parseArgs(self, args): |
| 55 | print('') |
| 56 | i = 1 |
| 57 | while i < len(args): |
| 58 | if args[i] == '-h' or args[i] == '--h' or args[i] == '--help': |
| 59 | self.help() #Time for some self help! :) |
| 60 | if len(args[i]) < 2: |
no outgoing calls
no test coverage detected