def read_config(): config = Config('argument parser for classification training') config.add_argument('--topk', type=int, default=5) config.add_argument('--backbone', type=str, default='resnet101') config.add_argument('--groups', type=int, default=1) config.add_argument('--conv', type=str, default='conv', choices=['conv', 'seperable', 'deform']) config.add_argument('--dilation', type=int, nargs='+', default=1) return config.parse_args()
def read_config(): config = Config('argument parser for object detection training') config.add_argument('--backbone', type=str, default='resnet101') config.add_argument('--groups', type=int, default=1) config.add_argument('--dilation', type=int, nargs='+', default=1) config.add_argument('--conv', type=str, default='conv', choices=['conv', 'seperable', 'deform']) config.add_argument('--fpn_layer', type=int, default=4) config.add_argument('--num_anchors', type=int, default=9) config.add_argument('--no_fix_backbone_bn', action='store_true', default=False) config.add_argument('--use_bn', action='store_true', default=False) config.add_argument('--use_residual', action='store_true', default=False) config.add_argument('--use_postprocessing', action='store_true', default=False) config.add_argument('--cls_thresh', type=float, default=0.05) config.add_argument('--nms_thresh', type=float, default=0.5) config.add_argument('--bbox_min_size', type=int, default=4, help='minimum bbox size for ground truth') config.add_argument('--rpn_pos_overlap', type=float, default=0.5, help='rpn positive overlap threshold') config.add_argument('--rpn_low_neg_overlap', type=float, default=0.3, help='the lower bound of rpn negative overlap') config.add_argument('--rpn_high_neg_overlap', type=float, default=0.4, help='the higher bound of rpn negative overlap') config.add_argument('--crowd_overlap', type=float, default=0.3, help='remove anchors if they ovelap with crowds') config.add_argument('--border_ratio', type=float, default=0.8, help='filter border anchors') config.add_argument('--use_mask', action='store_true', help='whether to use mask targets in dataloader') return config.parse_args()
def start(argv): print argv start = time.time() pa = argparse.ArgumentParser(description='Open Data Portal Watch API service.', prog='pwapi') logg = pa.add_argument_group("Logging") logg.add_argument( '-d', '--debug', help="Print lots of debugging statements", action="store_const", dest="loglevel", const=logging.DEBUG, default=logging.WARNING ) logg.add_argument( '-v', '--verbose', help="Be verbose", action="store_const", dest="loglevel", const=logging.INFO, default=logging.WARNING ) config = pa.add_argument_group("Config") config.add_argument('-c', '--config', help="config file", dest='config') args = pa.parse_args(args=argv) if args.config: try: with open(args.config) as f_conf: config = yaml.load(f_conf) if 'logging' in config: print "setup logging" logging.config.dictConfig(config['logging']) else: ##load basic logging logconf = os.path.join(odpw.__path__[0], 'resources/logging', 'logging.yaml') with open(logconf) as f: logging.config.dictConfig(yaml.load(f)) except Exception as e: print "Exception during config initialisation", e return else: ##load basic logging logconf = os.path.join(odpw.__path__[0], 'resources/logging', 'logging.yaml') with open(logconf) as f: logging.config.dictConfig(yaml.load(f)) logging.basicConfig(level=args.loglevel) # config the structlog config_logging() log = structlog.get_logger() #try: log.info("CMD ARGS", args=str(args)) cli(args) #except Exception as e: # log.fatal("Uncaught exception", exc_info=True) end = time.time() secs = end - start msecs = secs * 1000 log.info("END MAIN", time_elapsed=msecs) Timer.printStats() ErrorHandler.printStats()
def start (argv): print argv start= time.time() pa = argparse.ArgumentParser(description='Open Portal Watch toolset.', prog='odpw') logg=pa.add_argument_group("Logging") logg.add_argument( '-d', '--debug', help="Print lots of debugging statements", action="store_const", dest="loglevel", const=logging.DEBUG, default=logging.WARNING ) logg.add_argument( '-v', '--verbose', help="Be verbose", action="store_const", dest="loglevel", const=logging.INFO, default=logging.WARNING ) config=pa.add_argument_group("Config") config.add_argument('-c','--config', help="config file", dest='config') sp = pa.add_subparsers(title='Modules', description="Available sub modules") for sm in submodules: smpa = sp.add_parser(sm.name(), help=sm.help()) sm.setupCLI(smpa) smpa.set_defaults(func=sm.cli) m=set([]) for k,v in sys.modules.items(): if v is not None: if '.' in k: m.add(k.split('.')[0]) else: m.add(k) #for i in m: # print i args = pa.parse_args(args=argv) db=readDBConfFromFile(args.config) if args.config: try: with open(args.config) as f_conf: config = yaml.load(f_conf) if 'logging' in config: print "setup logging" logging.config.dictConfig(config['logging']) else: ##load basic logging logconf = os.path.join(odpw.__path__[0], 'resources/logging', 'logging.yaml') with open(logconf) as f: logging.config.dictConfig(yaml.load(f)) except Exception as e: print "Exception during config initialisation",e return else: ##load basic logging logconf = os.path.join(odpw.__path__[0], 'resources/logging', 'logging.yaml') with open(logconf) as f: logging.config.dictConfig(yaml.load(f)) logging.basicConfig(level=args.loglevel) #config the structlog config_logging() log = structlog.get_logger() try: log.info("CMD ARGS", args=str(args)) dbm = DBManager(**db) args.func(args , dbm) except OperationalError as e: log.fatal("DB Connection Exception: ", msg=e.message) except Exception as e: log.fatal("Uncaught exception", exc_info=True) end = time.time() secs = end - start msecs = secs * 1000 log.info("END MAIN", time_elapsed=msecs) Timer.printStats() ErrorHandler.printStats()
def read_config(): config = Config('argument parser for semantic segmentation training') config.add_argument('--backbone', type=str, default='resnet101') config.add_argument('--groups', type=int, default=1) config.add_argument('--conv', type=str, default='conv', choices=['conv', 'seperable', 'deform']) config.add_argument('--fpn_layer', type=int, default=3) config.add_argument('--dilation', type=int, nargs='+', default=1) config.add_argument('--use_postprocessing', action='store_true', default=False) config.add_argument('--use_aug', action='store_true', default=False) return config.parse_args()