当前位置: 首页>>代码示例>>Python>>正文


Python config.Config方法代码示例

本文整理汇总了Python中utils.config.Config方法的典型用法代码示例。如果您正苦于以下问题:Python config.Config方法的具体用法?Python config.Config怎么用?Python config.Config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.config的用法示例。


在下文中一共展示了config.Config方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from utils import config [as 别名]
# 或者: from utils.config import Config [as 别名]
def run(self):
        config = Config()

        version = config.read("version")
        if version.startswith("TC"):
            if version.endswith("USB"):
                interface = TcSerialInterface(config.read("port"))
            else:
                interface = TcBleInterface(config.read("ble_address"))
        else:
            interface = UmInterface(config.read("port"))
            if version == "UM25C":
                interface.enable_higher_resolution()

        while True:
            message = self.command.get()
            if message == "connect":
                self.result.put(self.call(interface.connect, "connected"))
            if message == "disconnect":
                self.result.put(self.call(interface.disconnect, "disconnected"))
            if message == "read":
                self.result.put(self.call(interface.read)) 
开发者ID:kolinger,项目名称:rd-usb,代码行数:24,代码来源:wrapper.py

示例2: run_server

# 需要导入模块: from utils import config [as 别名]
# 或者: from utils.config import Config [as 别名]
def run_server(config: lsConfig.Config):
	loop = asyncio.get_event_loop()

	listenAddr = net.Address(config.localAddr, config.localPort)
	remoteAddr = net.Address(config.serverAddr, config.serverPort)
	server = LsLocal(
		loop=loop,
		password=config.password,
		listenAddr=listenAddr,
		remoteAddr=remoteAddr)

	def didListen(address):
		print('Listen to %s:%d\n' % address)

	asyncio.ensure_future(server.listen(didListen))
	loop.run_forever() 
开发者ID:nanqinlang-mogic,项目名称:lightsocks,代码行数:18,代码来源:lslocal.py

示例3: init

# 需要导入模块: from utils import config [as 别名]
# 或者: from utils.config import Config [as 别名]
def init(self):
        self.config = Config()
        self.storage = Storage() 
开发者ID:kolinger,项目名称:rd-usb,代码行数:5,代码来源:index.py

示例4: init

# 需要导入模块: from utils import config [as 别名]
# 或者: from utils.config import Config [as 别名]
def init(self):
        self.config = Config() 
开发者ID:kolinger,项目名称:rd-usb,代码行数:4,代码来源:backend.py

示例5: run

# 需要导入模块: from utils import config [as 别名]
# 或者: from utils.config import Config [as 别名]
def run(self):
        self.storage = Storage()
        self.config = Config()

        self.interface = Wrapper()

        try:
            self.log("Connecting")
            self.retry(self.interface.connect)
            self.emit("connected")
            self.log("Connected")

            while self.running:
                data = self.retry(self.interface.read)
                self.log(json.dumps(data))
                if data:
                    data["name"] = self.config.read("name")
                    self.update(data)
                self.storage.store_measurement(data)
                sleep(self.config.read("rate"))

        except (KeyboardInterrupt, SystemExit):
            raise
        except:
            logging.exception(sys.exc_info()[0])
            self.emit("log", traceback.format_exc())
            self.emit("log-error")
        finally:
            self.interface.disconnect()
            self.emit("disconnected")
            self.log("Disconnected")
            self.thread = None 
开发者ID:kolinger,项目名称:rd-usb,代码行数:34,代码来源:backend.py

示例6: main

# 需要导入模块: from utils import config [as 别名]
# 或者: from utils.config import Config [as 别名]
def main():
  config = Config()
  parser = argparse.ArgumentParser(
    description='Code for evaluating dialog models\' responses with ' +
                '17 evaluation metrics (arxiv.org/abs/1905.05471)')
  parser.add_argument('-tns', '--train_source', default=config.train_source,
                      help='Path to the train source file, where each line ' +
                      'corresponds to one train input',
                      metavar='')
  parser.add_argument('-tts', '--test_source', default=config.test_source,
                      help='Path to the test source file, where each line ' +
                      'corresponds to one test input',
                      metavar='')
  parser.add_argument('-ttt', '--test_target', default=config.test_target,
                      help='Path to the test target file, where each line ' +
                      'corresponds to one test target',
                      metavar='')
  parser.add_argument('-r', '--test_responses', default=config.test_responses,
                      help='Path to the test model responses file',
                      metavar='')
  parser.add_argument('-tv', '--text_vocab', default=config.text_vocab,
                      help='A file where each line is a word in the vocab',
                      metavar='')
  parser.add_argument('-vv', '--vector_vocab', default=config.vector_vocab,
                      help='A file where each line is a word in the vocab ' +
                      'followed by a vector',
                      metavar='')
  parser.add_argument('-s', '--bleu_smoothing', default=config.bleu_smoothing,
                      help='Bleu smoothing method (choices: %(choices)s)',
                      metavar='',
                      choices=[0, 1, 2, 3, 4, 5, 6, 7])
  parser.add_argument('-t', '--t', default=config.t,
                      help='t value for confidence level calculation ' +
                      '(default: %(default)s)',
                      metavar='', type=int)

  parser.parse_args(namespace=config)

  m = Metrics(config)
  m.run() 
开发者ID:ricsinaruto,项目名称:dialog-eval,代码行数:42,代码来源:main.py

示例7: run_server

# 需要导入模块: from utils import config [as 别名]
# 或者: from utils.config import Config [as 别名]
def run_server(config: lsConfig.Config):
	loop = asyncio.get_event_loop()

	listenAddr = net.Address(config.serverAddr, config.serverPort)
	server = LsServer(loop=loop, password=config.password, listenAddr=listenAddr)

	def didListen(address):
		print('Listen to %s:%d\n' % address)
		print('Please use:\n')
		print('''lslocal -u "http://hostname:port/#'''
			  f'''{dumpsPassword(config.password)}"''')
		print('\nto config lslocal')

	asyncio.ensure_future(server.listen(didListen))
	loop.run_forever() 
开发者ID:nanqinlang-mogic,项目名称:lightsocks,代码行数:17,代码来源:lsserver.py

示例8: run

# 需要导入模块: from utils import config [as 别名]
# 或者: from utils.config import Config [as 别名]
def run(browser=True):
    port = 5000
    if len(sys.argv) > 1:
        port = int(sys.argv[1])

    app = Flask(__name__, static_folder=static_path)
    app.register_blueprint(Index().register())

    logger = logging.getLogger()
    logger.setLevel(logging.INFO)
    formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")

    console = StreamHandler()
    console.setLevel(logging.DEBUG)
    console.setFormatter(formatter)
    logger.addHandler(console)

    if not app.debug:
        file = TimedRotatingFileHandler(data_path + "/error.log", when="w0", backupCount=14)
        file.setLevel(logging.ERROR)
        file.setFormatter(formatter)
        logger.addHandler(file)

    try:
        config = Config()
        secret_key = config.read("secret_key")
        if not secret_key:
            secret_key = "".join(random.choice(string.ascii_uppercase + string.digits) for _ in range(16))
            config.write("secret_key", secret_key)
        app.secret_key = secret_key

        Storage().init()

        sockets = socketio.Server()
        app.wsgi_app = socketio.Middleware(sockets, app.wsgi_app)
        sockets.register_namespace(Backend())

        def open_in_browser():
            logging.info("Application is starting...")

            url = "http://127.0.0.1:%s" % port
            while not url_ok(url):
                sleep(0.5)

            logging.info("Application is available at " + url)

            if not app.debug and browser:
                webbrowser.open(url)

        Thread(target=open_in_browser, daemon=True).start()

        app.run(host="0.0.0.0", port=port, threaded=True, use_reloader=False)

    except (KeyboardInterrupt, SystemExit):
        raise
    except:
        logging.exception(sys.exc_info()[0]) 
开发者ID:kolinger,项目名称:rd-usb,代码行数:59,代码来源:web.py

示例9: __init__

# 需要导入模块: from utils import config [as 别名]
# 或者: from utils.config import Config [as 别名]
def __init__(self, training=True):
        super(LightHeadRCNN_Learner, self).__init__()
        self.conf = Config()
        self.class_2_color = get_class_colors(self.conf)   
        self.rpn = RegionProposalNetwork().to(self.conf.device)
        self.loc_normalize_mean=(0., 0., 0., 0.),
        self.loc_normalize_std=(0.1, 0.1, 0.2, 0.2)
        self.head = LightHeadRCNNResNet101_Head(self.conf.class_num + 1, self.conf.roi_size).to(self.conf.device)
        self.class_2_color = get_class_colors(self.conf)
        self.detections = namedtuple('detections', ['roi_cls_locs', 'roi_scores', 'rois'])
             
        if training:
            self.extractor = ResNet101Extractor(self.conf.pretrained_model_path).to(self.conf.device)
            self.train_dataset = coco_dataset(self.conf, mode = 'train')
            self.train_length = len(self.train_dataset)
            self.val_dataset =  coco_dataset(self.conf, mode = 'val')
            self.val_length = len(self.val_dataset)
            self.anchor_target_creator = AnchorTargetCreator()
            self.proposal_target_creator = ProposalTargetCreator(loc_normalize_mean = self.loc_normalize_mean, 
                                                                 loc_normalize_std = self.loc_normalize_std)
            self.step = 0
            self.optimizer = SGD([
                {'params' : get_trainables(self.extractor.parameters())},
                {'params' : self.rpn.parameters()},
                {'params' : [*self.head.parameters()][:8], 'lr' : self.conf.lr*3},
                {'params' : [*self.head.parameters()][8:]},
            ], lr = self.conf.lr, momentum=self.conf.momentum, weight_decay=self.conf.weight_decay)
            self.base_lrs = [params['lr'] for params in self.optimizer.param_groups]
            self.warm_up_duration = 5000
            self.warm_up_rate = 1 / 5
            self.train_outputs = namedtuple('train_outputs',
                                            ['loss_total', 
                                             'rpn_loc_loss', 
                                             'rpn_cls_loss', 
                                             'ohem_roi_loc_loss', 
                                             'ohem_roi_cls_loss',
                                             'total_roi_loc_loss',
                                             'total_roi_cls_loss'])                                      
            self.writer = SummaryWriter(self.conf.log_path)
            self.board_loss_every = self.train_length // self.conf.board_loss_interval
            self.evaluate_every = self.train_length // self.conf.eval_interval
            self.eva_on_coco_every = self.train_length // self.conf.eval_coco_interval
            self.board_pred_image_every = self.train_length // self.conf.board_pred_image_interval
            self.save_every = self.train_length // self.conf.save_interval
            # only for debugging
#             self.board_loss_every = 5
#             self.evaluate_every = 6
#             self.eva_on_coco_every = 7
#             self.board_pred_image_every = 8
#             self.save_every = 10
        else:
            self.extractor = ResNet101Extractor().to(self.conf.device) 
开发者ID:TreB1eN,项目名称:Lighthead-RCNN-in-Pytorch0.4.1,代码行数:54,代码来源:LightheadRCNN_Learner.py


注:本文中的utils.config.Config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。