From a5e5af2196713a7bc383e05a1dc5491114ec6781 Mon Sep 17 00:00:00 2001 From: Kai Labusch Date: Fri, 29 Nov 2019 10:04:09 +0100 Subject: [PATCH] enable per model choice of training epoch;make config file exchangeable --- qurator/sbb_ner/webapp/app.py | 4 ++-- qurator/sbb_ner/webapp/config.json | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/qurator/sbb_ner/webapp/app.py b/qurator/sbb_ner/webapp/app.py index 0e01bf0..50f8b3a 100644 --- a/qurator/sbb_ner/webapp/app.py +++ b/qurator/sbb_ner/webapp/app.py @@ -18,7 +18,7 @@ from pytorch_pretrained_bert.modeling import (CONFIG_NAME, app = Flask(__name__) -app.config.from_json('config.json') +app.config.from_json('config.json' if not os.environ.get('CONFIG') else os.environ.get('CONFIG')) logger = logging.getLogger(__name__) @@ -161,7 +161,7 @@ class PredictorStore: if self._model_id != model_id: self._predictor = NERPredictor(model_dir=model['model_dir'], - epoch=app.config['EPOCH'], + epoch=model['epoch'], batch_size=app.config['BATCH_SIZE'], no_cuda=False if not os.environ.get('USE_CUDA') else os.environ.get('USE_CUDA').lower() == 'false') diff --git a/qurator/sbb_ner/webapp/config.json b/qurator/sbb_ner/webapp/config.json index 76c8d81..4601ac2 100644 --- a/qurator/sbb_ner/webapp/config.json +++ b/qurator/sbb_ner/webapp/config.json @@ -1,30 +1,33 @@ { "DATA_PATH": "data/digisam/fulltext.sqlite3", - "EPOCH": 7, "BATCH_SIZE": 256, "MODELS": [ { "name": "DC-SBB + CONLL + GERMEVAL", "id": 1, "model_dir": "data/konvens2019/build-wd_0.03/bert-all-german-de-finetuned", + "epoch": 7, "default": true }, { "name": "DC-SBB + CONLL + GERMEVAL + SBB", "id": 2, "model_dir": "data/konvens2019/build-on-all-german-de-finetuned/bert-sbb-de-finetuned", + "epoch": 7, "default": false }, { "name": "DC-SBB + SBB", "id": 3, "model_dir": "data/konvens2019/build-wd_0.03/bert-sbb-de-finetuned", + "epoch": 7, "default": false }, { "name": "CONLL + GERMEVAL", "id": 4, "model_dir": "data/konvens2019/build-wd_0.03/bert-all-german-baseline", + "epoch": 7, "default": false } ],