def __init__(self, model_path): os.chdir(model_path) self._app = web.Application() config_path = os.path.join(model_path, "config.json") log_path = self._set_up_log(model_path) with open(log_path, 'a+') as file: named_tuple = time.localtime() time_string = time.strftime("%m/%d/%Y, %H:%M:%S", named_tuple) file.write(f'--Starting Server--\n'\ f'{time_string}\n\n') with open(config_path, 'r') as file: config = json.loads(file.read()) self._app['nmt'] = Pangeanmt(model_path) self._app['pipeline'] = Pipeline(config['pipeline_config'],\ config['src_lang'], config['tgt_lang']) self._app['pipeline_tgt'] = Pipeline(config['pipeline_config_tgt'],\ config['tgt_lang']) self._app['model_path'] = model_path self._app['lock'] = asyncio.Lock() self._app['sem'] = asyncio.Semaphore() self._app['ol'] = config['online_learning']['active'] self._app['log_path'] = log_path self._app.router.add_post('/save', save) self._app.router.add_post('/train', train) self._app.router.add_post('/isready', ready) self._app.router.add_post('/translate', translate)
def __init__(self, in_file, ref_file): with open('config.json', 'r') as file: self._config = json.loads(file.read()) self._src_pipeline = Pipeline(self._config['pipeline_config'],\ self._config['src_lang'], self._config['tgt_lang']) self._tgt_pipeline = Pipeline(self._config['pipeline_config_tgt'],\ self._config['tgt_lang']) self._in_file = os.path.join('data', in_file) self._ref_file = os.path.join('data', ref_file)
def __init__(self): with open('config.json', 'r') as file: self._config = json.loads(file.read()) self._src_pipeline = Pipeline(self._config['pipeline_config'], self._config['src_lang'], self._config['tgt_lang']) self._tgt_pipeline = Pipeline(self._config['pipeline_config_tgt'], self._config['tgt_lang'])
def __init__(self): with open("config.json", "r") as file: self._config = json.loads(file.read()) self._src_pipeline = Pipeline( self._config["pipeline_config"], self._config["src_lang"], self._config["tgt_lang"], ) self._tgt_pipeline = Pipeline(self._config["pipeline_config_tgt"], self._config["tgt_lang"])