def load_language(app, tokenizer_service, tag, model_dir):
config = Config.load(['./default.conf', './default.' + tag + '.conf', os.path.join(model_dir, 'model.conf')])
model = create_model(config)
graph = tf.Graph()
session = tf.Session(graph=graph)
with graph.as_default():
# Force everything to run on CPU, we run on single inputs so there is not much point
# on going through the GPU
with tf.device('/cpu:0'):
model.build()
loader = tf.train.Saver()
with session.as_default():
loader.restore(session, os.path.join(model_dir, 'best'))
tokenizer = Tokenizer(tokenizer_service, tag)
app.add_language(tag, LanguageContext(tag, tokenizer, session, config, model))
print('Loaded language ' + tag)
run_server.py 文件源码
python
阅读 33
收藏 0
点赞 0
评论 0
评论列表
文章目录